Home > FR3DSource > xListCandidates.m

xListCandidates

PURPOSE ^

xListCandidates(Search) prints a candidate list to the screen

SYNOPSIS ^

function [Text] = xListCandidates(Search,NumToOutput,WheretoOutput,Param)

DESCRIPTION ^

 xListCandidates(Search) prints a candidate list to the screen
 The optional argument NumToOutput limits the list's length
 The optional argument WheretoOutput has this effect:
   Value 1 : prints a wide listing to the Matlab command window
   Value 2 : prints a wide listing to an Editbox
   Value 3 : prints a narrow listing to an Editbox
   Value 5 : returns a wide listing, doesn't print anything
   Value 6 : returns the text of the narrow listing
   Value 7 : narrow listing with information on the organism

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xListCandidates(Search) prints a candidate list to the screen
0002 % The optional argument NumToOutput limits the list's length
0003 % The optional argument WheretoOutput has this effect:
0004 %   Value 1 : prints a wide listing to the Matlab command window
0005 %   Value 2 : prints a wide listing to an Editbox
0006 %   Value 3 : prints a narrow listing to an Editbox
0007 %   Value 5 : returns a wide listing, doesn't print anything
0008 %   Value 6 : returns the text of the narrow listing
0009 %   Value 7 : narrow listing with information on the organism
0010 
0011 % The PC compiled version does both 2 and 3.
0012 
0013 % It may be run directly from Matlab using the command:
0014 %   xListCandidates(Search);
0015 
0016 function [Text] = xListCandidates(Search,NumToOutput,WheretoOutput,Param)
0017 
0018 File        = Search.File;
0019 Candidates  = Search.Candidates;
0020 
0021 if ~isfield(Search,'Query'),
0022   Query.Geometric = 0;
0023   Query.Name = '';
0024 else
0025   Query = Search.Query;
0026 end
0027 
0028 [s,t]       = size(Candidates);
0029 N           = t-1;
0030 
0031 if s == 0,
0032   fprintf('There are no candidates to list\n');
0033   return
0034 end
0035 
0036 if N == 2,
0037   CP = zeros(1,s);
0038 end
0039 
0040 if nargin < 2,
0041   NumToOutput = Inf;                    % limit on number printed to screen
0042 end
0043 
0044 if (nargin < 3),
0045   if isdeployed,
0046     WheretoOutput = 2;
0047     xListCandidates(Search,NumToOutput,3);
0048   else
0049     WheretoOutput = 1;                    % make a wide listing
0050   end
0051 end
0052 
0053 % -------------------------------------- print header line
0054 
0055 t = 4;
0056 
0057 if isfield(Search,'SaveName'),
0058   Text{1} = Search.SaveName;
0059 else
0060   Text{1} = '';
0061 end
0062 
0063 if isfield(Search.Query,'Name'),
0064   Text{2} = Search.Query.Name;
0065 else
0066   Text{2} = '';
0067 end
0068 
0069 if isfield(Search.Query,'Description'),
0070   Text{3} = Search.Query.Description;
0071 else
0072   Text{3} = '';
0073 end
0074 
0075 Text{t} = '';
0076 
0077 if isfield(Search,'AvgDisc'),
0078   Text{t} = [Text{t} sprintf('  Filename Avg Discrep ')];
0079 elseif Query.Geometric > 0,
0080   Text{t} = [Text{t} sprintf('  Filename Discrepancy ')];
0081 else
0082   Text{t} = [Text{t} sprintf('  Filename Number Nucl ')];
0083 end
0084 
0085 for i=1:N,
0086   Text{t} = [Text{t} sprintf('%7d ', i)];
0087 end
0088 
0089 c = 'Chains                                             ';
0090 Text{t} = [Text{t} sprintf('%s', c(1:N))];
0091 
0092 if isfield(Search,'GroupLabel'),
0093   Text{t} = [Text{t} ' Group    '];
0094 end
0095 
0096 if any(WheretoOutput == [1 2 5]),
0097   for i=1:N,
0098     for j=(i+1):N,
0099       Text{t} = [Text{t} sprintf('%6s', [num2str(i) '-' num2str(j)])];
0100     end
0101   end
0102   
0103   c = 'Configuration                                      ';
0104   Text{t} = [Text{t} sprintf(' %s', c(1:N))];
0105   
0106   for i=1:N,
0107     for j=(i+1):N,
0108       Text{t} = [Text{t} sprintf('%6s', [num2str(i) '-' num2str(j)])];
0109     end
0110   end
0111 
0112   for i=1:N,
0113     for j=1:N,
0114       if j ~= i,
0115         Text{t} = [Text{t} sprintf('%6s', [num2str(i) '-' num2str(j)])];
0116       end
0117     end
0118   end
0119 
0120   for i=1:N,
0121     for j=(i+1):N,
0122       Text{t} = [Text{t} sprintf('%6s', [num2str(i) '-' num2str(j)])];
0123     end
0124   end
0125   
0126 end   
0127 
0128 if N == 2,
0129   Text{t} = [Text{t} sprintf(' Pair data')];
0130 end
0131   
0132 % -------------------------------------- list candidates
0133 
0134 Config = {'A' , 'S'};
0135 
0136 for i=1:min(s,NumToOutput),
0137 
0138   f = double(Candidates(i,N+1));               % file number for this candidate
0139   Indices = Candidates(i,1:N);                 % indices of nucleotides
0140 
0141   Text{i+t} = '';
0142   Text{i+t} = [Text{i+t} sprintf('%10s', File(f).Filename)];
0143 
0144   if isfield(Search,'DisttoCenter'),
0145     Text{i+t} = [Text{i+t} sprintf('%12.4f',Search.DisttoCenter(i))];
0146   elseif Query.Geometric > 0,
0147     Text{i+t} = [Text{i+t} sprintf('%12.4f',Search.Discrepancy(i))];
0148   else
0149     Text{i+t} = [Text{i+t} sprintf('%12d',Search.Discrepancy(i))];      % original candidate number
0150   end
0151 
0152   for j=1:N,
0153     Text{i+t} = [Text{i+t} sprintf('%3s',File(f).NT(Indices(j)).Base)];    
0154     Text{i+t} = [Text{i+t} sprintf('%5s',File(f).NT(Indices(j)).Number)];    
0155   end
0156 
0157   Text{i+t} = [Text{i+t} ' '];
0158 
0159   for j=1:N,
0160     Text{i+t} = [Text{i+t} sprintf('%s',File(f).NT(Indices(j)).Chain)];
0161   end
0162 
0163   if isfield(Search,'GroupLabel'),
0164     GL = Search.GroupLabel{i};
0165     Text{i+t} = [Text{i+t} ' ' GL(1:10)];
0166   end
0167 
0168   if any(WheretoOutput == [1 2 5]),
0169     for k=1:length(Indices),
0170       for j=(k+1):length(Indices),
0171         C1 = File(f).NT(Indices(k)).Code;
0172         C2 = File(f).NT(Indices(j)).Code;
0173         Text{i+t} = [Text{i+t} sprintf('%6s', zEdgeText(File(f).Edge(Indices(k),Indices(j)),0,C1,C2))];
0174       end
0175     end
0176     
0177     Text{i+t} = [Text{i+t} sprintf(' ')];
0178     
0179     for k=1:length(Indices),
0180       Text{i+t} = [Text{i+t} sprintf('%c', Config{File(f).NT(Indices(k)).Syn+1})];
0181     end
0182     
0183     for k=1:length(Indices),
0184       for j=(k+1):length(Indices),
0185         Text{i+t} = [Text{i+t} sprintf('%6d', abs(double(Indices(k))-double(Indices(j))))];
0186       end
0187     end
0188 
0189     for k=1:length(Indices),
0190       for j=1:length(Indices),
0191         if j ~= k,
0192          Text{i+t} = [Text{i+t} sprintf('%6s', zBasePhosphateText(File(f).BasePhosphate(Indices(k),Indices(j))))];
0193         end
0194       end
0195     end
0196 
0197     for k=1:length(Indices),
0198       for j=(k+1):length(Indices),
0199         bbc = max(File(f).Backbone(Indices(j),Indices(k)),File(f).Backbone(Indices(k),Indices(j)));
0200         Text{i+t} = [Text{i+t} sprintf('%6s', zBackboneText(bbc))];
0201       end
0202     end
0203 
0204   end
0205     
0206   if N == 2,                        % special treatment for basepairs
0207 
0208     CP(i) = norm(File(f).NT(Candidates(i,1)).Sugar(1,:) - ...
0209                           File(f).NT(Candidates(i,2)).Sugar(1,:));
0210     Text{i+t} = [Text{i+t} sprintf('   C1*-C1*: %8.4f', CP(i))];
0211     NT1 = File(f).NT(Candidates(i,1));
0212     NT2 = File(f).NT(Candidates(i,2));
0213     Edge= full(File(f).Edge(Candidates(i,1),Candidates(i,2)));
0214     Text{i+t} = [Text{i+t} sprintf('%7.1f ', Edge)];
0215 %    BP  = full(File(f).BasePhosphate(Candidates(i,1),Candidates(i,2)));
0216 %    Text{i+t} = [Text{i+t} sprintf(' %4s ', zBasePhosphateText(BP))];
0217     SA = {'A', 'S'};
0218     Text{i+t} = [Text{i+t} sprintf('%c', SA{1+File(f).NT(Candidates(i,1)).Syn})];
0219     Text{i+t} = [Text{i+t} sprintf('%c', SA{1+File(f).NT(Candidates(i,2)).Syn})];
0220     if isfield(File,'Range'),
0221       ii = Candidates(i,1);
0222       jj = Candidates(i,2);
0223       if (File(f).Range(ii,jj) == 0) % && abs(File(f).Edge(ii,jj)) < 15,
0224         r = ' Nested';
0225       elseif File(f).Range(ii,jj) > 0,
0226         r = sprintf(' Range %4d', full(File(f).Range(ii,jj)));
0227       else
0228         r = '';
0229       end
0230       Text{i+t} = [Text{i+t} r];
0231     end
0232   end
0233 
0234   if isfield(File,'Nucl') && (WheretoOutput < 4),
0235     a = {};
0236     for j = 1:N,
0237       if ~isempty(File(f).Nucl(Candidates(i,j)).Motif),
0238         a = [a File(f).Nucl(Candidates(i,j)).Motif(1).Name];
0239       end
0240     end
0241 %    u = unique(a);
0242     u = a;
0243     for uu = 1:length(u),
0244       Text{i+t} = [Text{i+t} ' ' u{uu}];
0245     end
0246   end
0247 
0248   if WheretoOutput == 7,
0249     Text{i+t} = [Text{i+t} ' ' File(f).Info.Source ' | ' File(f).Info.Descriptor];
0250   end
0251 end
0252 
0253 % -------------------------------------- Additional notifications and info
0254 if (Query.Geometric > 0),
0255   if (Query.RelCutoff > Query.DiscCutoff) && ~isfield(Search,'AvgDisc'),
0256     L = length(Text);
0257     Text{L+1} = sprintf('Some motifs with discrepancy between %7.4f and %7.4f might not appear above\n\n', Query.DiscCutoff, Query.RelCutoff);
0258   end
0259 end
0260 
0261 if s > NumToOutput,
0262   L = length(Text);
0263   Text{L+1} = sprintf('Only the first %d candidates were listed.\n', NumToOutput);
0264 end
0265 
0266 if (N == 2) && (WheretoOutput < 4),
0267   figure
0268   clf
0269   hist(CP,30)
0270   title('Histogram of C1''-C1'' distance for these pairs');
0271   fprintf('Average C1''-C1'' distance is: %8.4f\n', mean(CP));
0272 end
0273 
0274 % -------------------------------------- Display the listing
0275 
0276 if WheretoOutput == 3,
0277   mEditbox(Text,'List of Candidates',10);
0278 elseif WheretoOutput == 2,
0279   mEditbox(Text,'Wide list of Candidates',7);
0280 elseif any(WheretoOutput == [1 7]),
0281   for i=1:length(Text),
0282     fprintf('%s\n',Text{i});
0283   end
0284 end

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003