Home > FR3DSource > xDisplayCandidates.m

xDisplayCandidates

PURPOSE ^

xDisplayCandidates(File,Search,Level) displays candidates

SYNOPSIS ^

function [Search, File] = xDisplayCandidates(FullFile,Search,Level,UsingFull,Order,ShowNavWindow)

DESCRIPTION ^

 xDisplayCandidates(File,Search,Level) displays candidates
 graphically and allows various types of analysis

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % xDisplayCandidates(File,Search,Level) displays candidates
0002 % graphically and allows various types of analysis
0003 
0004 % It may be run directly from Matlab using the command:
0005 %    [Search,File] = xDisplayCandidates([],Search);
0006 % and after this,
0007 %    [Search,File] = xDisplayCandidates(File,Search);
0008 
0009 function [Search, File] = xDisplayCandidates(FullFile,Search,Level,UsingFull,Order,ShowNavWindow)
0010 
0011 if nargin < 6,
0012   ShowNavWindow = 0;                           % default is not to
0013 end
0014 
0015 if strcmp(class(Search),'double'),
0016   S = Search;
0017   clear Search
0018   Search.Candidates = S;
0019   Search.File = FullFile;
0020   UsingFull = 1;                             % use what was passed in
0021   File = FullFile;
0022   Search.Query.Geometric = 0;
0023   [L,N] = size(Search.Candidates);
0024   N = N - 1;                                   % number of nucleotides
0025   Search.Query.NumNT = N;
0026   Search.Discrepancy = 1:L;
0027   FIndex = 1:length(FullFile);
0028   for f = 1:length(File),
0029     Search.CandidateFilenames{f} = File(f).Filename;
0030   end
0031 end
0032 
0033 if isempty(Search.Candidates)
0034   fprintf('There are no candidates to display\n');
0035   File = FullFile;
0036   return
0037 end
0038 
0039 [L,N] = size(Search.Candidates);
0040 N = N - 1;                                   % number of nucleotides
0041 
0042 Limit = min(L,300);                          % for mutual discrep matrix
0043 p = 1:L;                                     % default permutation for display
0044 q(p) = 1:L;                                  % inverse permutation
0045                                % p : display position -> real candidate number
0046                                % q : real candidate number -> display position
0047 
0048 if ~isfield(Search,'File'),
0049   UsingFull = 1;                             % use what was passed in
0050   File = FullFile;
0051   Search.Query.Geometric = 0;
0052   Search.Query.NumNT = N;
0053   Search.Discrepancy = 1:L;
0054   FIndex = 1:length(FullFile);
0055 else
0056   UsingFull = 0;
0057   File = Search.File;                        % use what was saved w/ Search
0058   FIndex = 1:length(Search.File);
0059 end
0060 
0061 Query = Search.Query;
0062 
0063 fontsize = 10;                               % for nucleotide numbers
0064 
0065 if nargin < 3,
0066   MenuTitle  = 'Display options';
0067   Level      = 0;
0068   QuitButton = 'Quit display';
0069 else
0070   MenuTitle  = ['Subset depth ' num2str(Level)];
0071   QuitButton = 'Return to larger set';
0072 end
0073 
0074 if nargin < 5,
0075   if Query.Geometric == 0,
0076     Order = 2;
0077   else
0078     Order = 1;
0079   end
0080 end
0081 
0082 OrderText = {'by discrepancy from query', 'by file, then sum of nucleotide numbers', 'by similarity', 'by centrality', 'by pair criteria'};
0083 
0084 warning off
0085 
0086 if ~isfield(Search,'Marked'),
0087   Search.Marked = zeros(1,L);         % allow marking certain candidates
0088 end
0089 
0090 if ~isfield(Search,'Disc'),
0091   Search.Disc         = sparse(zeros(L,L));
0092   Search.DiscComputed = sparse(zeros(1,L));
0093   if Query.Geometric > 0,
0094     Search.Disc(:,1) = Search.Discrepancy;
0095     Search.Disc(1,1) = 0;
0096     Search.DiscComputed(1,1) = 1;
0097   end
0098 end
0099 
0100 NeighMax = 4;
0101 
0102 % ----------------------------- find maximum gap between candidate nucleotides
0103 
0104 [y,r] = sort(Search.Candidates(1,1:N)); % put nucleotides in increasing order
0105 
0106 if isfield(Query,'MaxDiffMat'),
0107   MaxDiff = diag(Query.MaxDiffMat(r,r),1);
0108 else
0109   MaxDiff = Inf*ones(1,N-1);
0110 end
0111 
0112 maxinsert = zeros(1,N-1);
0113 for c = 1:L,
0114   maxinsert = max(maxinsert,abs(diff(double(Search.Candidates(c,r))))-1);
0115 end
0116 
0117 Display(1).p         = r;
0118 Display(1).MaxDiff   = MaxDiff;
0119 Display(1).MaxInsert = maxinsert;
0120 
0121 % --------- if there is no geometric model, align to the central candidate
0122 
0123 if Query.Geometric == 0,
0124   [z,j] = sort(sum(Search.Disc));           % sort by average discrepancy
0125   f              = Search.Candidates(j(1),N+1);
0126   Query.Indices  = double(Search.Candidates(j(1),1:N));
0127   Query.NT       = File(f).NT(Query.Indices);
0128   Query.LocWeight= ones(1,Query.NumNT);
0129   Query          = xPrecomputeForDiscrepancy(Query);
0130   Query.Filename = 'Central candidate';
0131 end
0132 
0133 % ------------------------------------------- Parameters to display candidates
0134 
0135 Display(1).n            = 1;     % which candidate is in display window 1
0136 Display(1).sugar        = 1;     % display sugars or not
0137 Display(1).neighborhood = 0;     % how large a neighborhood to show
0138 Display(1).superimpose  = 0;     % superimpose the first candidate?
0139 Display(1).supersugar   = 0;     % show sugars of first when superimposing?
0140 Display(1).labelbases   = 10;    % show nucleotide numbers
0141 Display(1).az           = -37.5; % standard view
0142 Display(1).el           = 30;
0143 
0144 stop     = 0;                              % stop the menu?
0145 i        = 1;                              % current window
0146 nn       = 1;                              % current candidate
0147 
0148 PlotMotif(File,Search,Query,Display,i);    % graph in display window i
0149 rotate3d on
0150 DisplayTable(File,Search,Query,Display,i)
0151 drawnow
0152 
0153 % ------------------------------- display menu -----------------------------
0154 
0155 if ShowNavWindow > 0,
0156   if N == 2 && exist('zIsoDiscrepancy') ==2,              % 2-NT candidates
0157     figure(98)
0158     axis([1 Limit+1 1 Limit+1]);
0159   end
0160 
0161   figure(99)
0162   axis([1 Limit+1 1 Limit+1]);
0163 end
0164 
0165 while stop == 0,                            
0166 
0167  if ShowNavWindow > 0,
0168   % ---------------------------------------- Display table of discrepancies
0169   figure(99)
0170   ax = axis;
0171   clf
0172   pp = p(1:Limit);
0173   zGraphDistanceMatrix(Search.Disc(pp,pp),Search.Lab(pp));
0174   hold on
0175   co = {'w*','wo','wd','ws','wv','w<','w>','w^','w+','wx'};
0176   co = [co co co co co co co co];
0177   for j = 1:length(Display),
0178     plot(q(Display(j).n)+0.5,q(Display(j).n)+0.5,co{j});
0179   end
0180   m = q(find(Search.Marked));
0181   plot(m+0.5,m+0.5,'w.');
0182 %  axis(ax);
0183   if Limit < L,
0184     title(['Discrepancies between first ' num2str(Limit) ' candidates, ordered by ' OrderText{Order}]);
0185   else
0186     title(['Discrepancies between all candidates, ordered by ' OrderText{Order}]);
0187   end
0188   colormap('default');
0189   map = colormap;
0190   map = map((end-8):-1:8,:);
0191   colormap(map);
0192   caxis([0 0.8]);
0193   colorbar('location','eastoutside');
0194   set(gcf,'Name','Navigation window; click here, then click the "Navigate" button');
0195 
0196   if N == 2 && exist('zIsoDiscrepancy') ==2,              % 2-NT candidates
0197  
0198   figure(98)
0199   ax = axis;
0200   clf
0201   pp = p(1:Limit);
0202   zGraphDistanceMatrix(Search.IDI(pp,pp));
0203 %  zGraphDistanceMatrix(Search.IDI(pp,pp),Search.Lab(pp));
0204   hold on
0205   co = {'w*','wo','wd','ws','wv','w<','w>','w^','w+','wx'};
0206   co = [co co co co co co co co];
0207   for j = 1:length(Display),
0208     plot(q(Display(j).n)+0.5,q(Display(j).n)+0.5,co{j});
0209   end
0210   m = q(find(Search.Marked));
0211   plot(m+0.5,m+0.5,'w.');
0212 %  axis(ax);
0213   if Limit < L,
0214     title(['IsoDiscrepancies between first ' num2str(Limit) ' candidates, ordered by ' OrderText{Order}]);
0215   else
0216     title(['IsoDiscrepancies between all candidates, ordered by ' OrderText{Order}]);
0217   end
0218   colormap('default');
0219   map = colormap;
0220   map = map((end-8):-1:8,:);
0221   colormap(map);
0222   caxis([0 5]);
0223   colorbar('location','eastoutside');
0224   set(gcf,'Name','Navigation window; click here, then click the "Navigate" button');
0225 
0226   fprintf('Counts of base combinations found in this set.\n');
0227 
0228   counts = zeros(4,4);
0229   for i = 1:L,
0230     f = Search.Candidates(i,3);
0231     a = Search.Candidates(i,1);
0232     b = Search.Candidates(i,2);
0233     c1 = File(f).NT(a).Code;
0234     c2 = File(f).NT(b).Code;
0235     counts(c1,c2) = counts(c1,c2) + 1;
0236   end
0237 
0238   Letters = 'ACGU';
0239 
0240   fprintf('        A      C      G      U\n');
0241   for i = 1:4,
0242     fprintf('%c   %5d  %5d  %5d  %5d\n', Letters(i), counts(i,1), counts(i,2), counts(i,3), counts(i,4));
0243   end
0244   fprintf('\n');
0245 
0246   end
0247  end
0248 
0249 
0250   if (Display(1).neighborhood == NeighMax),
0251     Neighborhood = 'No Neighborhood';
0252   else
0253     Neighborhood = 'Larger Neighborhood';
0254   end
0255 
0256   Buttons = {'Next candidate','Previous Candidate', ... % 1,2
0257          'Add plot', Neighborhood, ...                % 3,4
0258          'Toggle sugar','Toggle display', ...                 % 5,6
0259          'Mark/Unmark current','Reverse all marks', ...       % 7,8
0260          'Display marked only', ...                           % 9
0261          'List to screen','Write to PDB', ...                 % 10,11
0262          'Sort by centrality', 'Order by Similarity', ...     % 12,13
0263          'Show Alignment', ...                                % 14
0264          'Show Scatterplot', 'Navigate with Fig 99', ...      % 15, 16
0265          QuitButton};                                         % 17
0266 
0267   k=menu(MenuTitle,Buttons);
0268 
0269   ii=gcf;                                 % get current active figure
0270   if (abs(ii) > length(Display)) | (ii == 0), % other window active?
0271     ii = i;
0272   end
0273   i = ii;                                 % record and save active figure
0274   i = min(i,length(Display));
0275 
0276   figure(i)
0277   [az,el]=view;                          % get current view (orientation)
0278   Display(1).az = az;
0279   Display(1).el = el;
0280   Display(1).x=XLim;                     % current x, y, z limits
0281   Display(1).y=YLim;
0282   Display(1).z=ZLim;
0283 
0284 
0285  % ------------------------------------------- Want the navigation window?
0286 
0287   if any(k == [12 13 16]),
0288     ShowNavWindow = min(2,1+ShowNavWindow);
0289   end
0290 
0291  % ------------------------------------------- Calculate distance matrix
0292 
0293  if ShowNavWindow == 1,                     % just indicated to show this
0294   fprintf('Calculating discrepancies between first %d candidates\n',Limit);
0295   Search = xMutualDiscrepancy(File,Search,Limit); % calculate some discrepancies
0296 
0297   for ii=1:L,
0298     f = Search.Candidates(ii,N+1);          % file number
0299     b = '';
0300     for j = 1:min(4,N),
0301       b = [b File(f).NT(Search.Candidates(ii,j)).Base];
0302     end
0303     n = File(f).NT(Search.Candidates(ii,1)).Number;
0304     n = sprintf('%4s',n);
0305     if Search.Query.Geometric > 0,
0306         if isfield(Search,'AvgDisc'),
0307           d = sprintf('%6.4f',Search.AvgDisc(ii));
0308         else
0309           d = sprintf('%6.4f',Search.Discrepancy(ii));
0310         end
0311       else
0312         d = sprintf('%5d',Search.Discrepancy(ii)); % orig candidate number
0313       end
0314     Search.Lab{ii} = [b n ' ' File(f).Filename];
0315   end
0316 
0317   % ------------------------------------------- Calculate IDI matrix
0318 
0319   if N == 2 && exist('zIsoDiscrepancy') == 2,              % 2-NT candidates
0320 
0321   Search = xMutualIDI(File,Search,Limit); % calculate some discrepancies
0322 
0323   for ii=1:L,
0324     f = Search.Candidates(ii,N+1);          % file number
0325     b = '';
0326     for j = 1:min(4,N),
0327       b = [b File(f).NT(Search.Candidates(ii,j)).Base];
0328     end
0329     n = File(f).NT(Search.Candidates(ii,1)).Number;
0330     n = sprintf('%4s',n);
0331     if Search.Query.Geometric > 0,
0332         if isfield(Search,'AvgDisc'),
0333           d = sprintf('%6.4f',Search.AvgDisc(ii));
0334         else
0335           d = sprintf('%6.4f',Search.Discrepancy(ii));
0336         end
0337       else
0338         d = sprintf('%5d',Search.Discrepancy(ii)); % orig candidate number
0339       end
0340     Search.Lab{ii} = [b n ' ' File(f).Filename];
0341     end
0342   end
0343  end
0344 
0345 
0346 
0347   switch k                               % k is the menu choice
0348     case 1                                      % next plot
0349       n = Display(i).n;                         % actual candidate displayed
0350       if q(n) + 1 > L,                          % q(n) is display order
0351         Display(i).n = p(1);
0352 
0353         if (ShowNavWindow > 0) && (min(Limit*2,L) > Limit),
0354           Limit = min(Limit*2,L);                 % increase limit
0355           fprintf('Increased display limit to %d; calculating more discrepancies\n',Limit);
0356           Search = xMutualDiscrepancy(File,Search,Limit); % calculate some discrepancies
0357         else
0358           Limit = min(Limit*2,L);                 % increase limit
0359         end
0360 
0361         p = 1:L;                             % default permutation for display
0362         q(p) = 1:L;                          % inverse permutation
0363 
0364       else
0365         Display(i).n = p(q(n) + 1);
0366       end
0367 
0368     case 2                                      % Previous Plot
0369       n = Display(i).n;                         % actual candidate displayed
0370       if q(n) - 1 < 1,                          % q(n) is display order
0371         Display(i).n = p(L);
0372       else
0373         Display(i).n = p(q(n) - 1);
0374       end
0375 
0376     case 3                                      % Add plot
0377       Display(end+1) = Display(i);              % use current settings
0378       i = length(Display);                      % current figure number
0379       figure(i);
0380 
0381     case 4                                      % toggle Neighborhood
0382       Display(1).neighborhood = Display(1).neighborhood + 1;
0383       if Display(1).neighborhood > NeighMax,
0384         Display(1).neighborhood = 0; 
0385       end 
0386 
0387     case 5                                      % toggle sugar
0388       if Display(1).superimpose == 0,
0389         Display(1).sugar = 1 - Display(1).sugar;
0390       elseif (Display(1).sugar == 0) & (Display(1).supersugar == 0),
0391         Display(1).sugar = 1;
0392       elseif (Display(1).sugar == 1) & (Display(1).supersugar == 0),
0393         Display(1).supersugar = 1;
0394       elseif (Display(1).sugar == 1) & (Display(1).supersugar == 1),
0395         Display(1).sugar = 0;
0396       elseif (Display(1).sugar == 0) & (Display(1).supersugar == 1),
0397         Display(1).supersugar = 0;
0398       end
0399 
0400     case 6                                      % toggle superimpose/numbers
0401       if Display(1).superimpose == 0 & Display(1).labelbases == 0,
0402         Display(1).superimpose = 1;
0403         fprintf('Superimposing candidate in darker colors');
0404       elseif Display(1).superimpose == 1 & Display(1).labelbases == 0,
0405         Display(1).labelbases = fontsize;
0406       elseif Display(1).superimpose == 1 & Display(1).labelbases > 0,
0407         Display(1).superimpose = 0;
0408       elseif Display(1).superimpose == 0 & Display(1).labelbases > 0,
0409         Display(1).labelbases = 0;
0410       end
0411 
0412     case 7                                      % mark/unmark current cand
0413       Search.Marked(Display(i).n) = 1-Search.Marked(Display(i).n); %toggle
0414       n = Display(i).n;                         % actual candidate displayed
0415       if q(n) + 1 > L,                          % q(n) is display order
0416         Display(i).n = p(1);
0417       else
0418         Display(i).n = p(q(n) + 1);
0419       end
0420 
0421     case 8                                      % reverse all marks
0422       Search.Marked = 1-Search.Marked;
0423 
0424     case 9                                      % display marked only
0425       j = find(Search.Marked);
0426       if length(j) > 0,
0427         [y,m] = sort(q(j));
0428         j = j(m);                               % put j in display order
0429         Search2 = SearchSubset(Search,j);
0430         xDisplayCandidates(File(FIndex),Search2,Level+1,UsingFull,Order,ShowNavWindow);
0431       end
0432 
0433     case 10                                      % list on screen
0434       j  = find(Search.Marked);
0435       jj = find(Search.Marked == 0);
0436       if (length(j) > 0) && (length(jj) > 0),
0437         [y,m] = sort(q(j));
0438         j = j(m);                                % put j in display order
0439         Search2 = SearchSubset(Search,j);
0440         fprintf('Marked candidates listed first\n');
0441         xListCandidates(Search2,Inf);
0442 
0443         [y,m] = sort(q(jj));
0444         jj = jj(m);                             % put jj in display order
0445         Search2 = SearchSubset(Search,jj);
0446         fprintf('Unmarked candidates listed second\n');
0447         xListCandidates(Search2,Inf);
0448       else
0449         Search2 = SearchSubset(Search,p);
0450         xListCandidates(Search2,Inf);
0451       end
0452 
0453     case 11                                     % write PDB of all
0454       SearchT = Search;
0455       Search = SearchSubset(Search,p);
0456       xWriteCandidatePDB(Search);
0457       if Level > 0,
0458         SN = [Search.SaveName '_Subset_' datestr(now,31)];
0459         SN    = strrep(SN,' ','_');
0460         SN    = strrep(SN,':','_');
0461         Search.SaveName = SN;
0462         save(['SearchSaveFiles' filesep SN], 'Search');
0463       end
0464       Search = SearchT;
0465 
0466     case 12                                     % sort by centrality
0467       [z,j] = sort(max(Search.Disc(1:Limit,1:Limit)));% sort by max discrepancy
0468 %      [z,j] = sort(sum(Search.Disc));           % sort by average discrepancy
0469       S.AvgDisc  = z / (Limit - 1);             % average discrep among these
0470       p(1:Limit) = j;
0471       p((Limit+1):L) = (Limit+1):L;      
0472       q(p) = 1:L;
0473 %      Search = xSortByCentrality(File(FIndex),Search,Level,UsingFull);
0474       Order = 4;
0475 
0476     case 13                                     % group candidates
0477 %      Search = xGroupCandidates(File(FIndex),Search,Level,UsingFull);
0478 %      Search = xOrderCandidates(File(FIndex),Search,Level,UsingFull);
0479 
0480       p(1:Limit) = zOrderbySimilarity(Search.Disc(1:Limit,1:Limit));
0481       p((Limit+1):L) = (Limit+1):L;
0482       q(p) = 1:L;
0483       Order = 3;
0484 
0485       if N == 2 && exist('zIsoDiscrepancy') ==2,              % 2-NT candidates
0486         p(1:Limit) = zOrderbySimilarity(Search.IDI(1:Limit,1:Limit));
0487         p((Limit+1):L) = (Limit+1):L;
0488         q(p) = 1:L;
0489         Order = 3;
0490       end
0491 
0492     case 14                                     % align
0493       xAlignCandidates(File(FIndex),Search,1);
0494 %      Text = xFASTACandidates(File(FIndex),Search,1);
0495 %      for t = 1:length(Text),
0496 %        fprintf('%s\n', Text{t});
0497 %      end
0498 
0499     case 15
0500       ViewParam.Color  = 6;
0501       ViewParam.FigNum = length(Display)+1;
0502       ViewParam.Normal = 0;
0503       ViewParam.ClassLimits = 1;
0504       ppp = xScatterPairs(Search,1,2,ViewParam);
0505 
0506     case 16
0507       figure(99)
0508       if ShowNavWindow == 2,                    % already displayed
0509         pt = get(gca,'CurrentPoint');
0510       else
0511         pt(1,1) = Display(i).n;                 % current candidate
0512         pt(1,2) = Display(i).n;
0513       end
0514 
0515       if abs(pt(1,1)-pt(1,2)) > Limit/20,           % clicked off the diagonal
0516         Search.Marked = 0 * Search.Marked;      % unmark all candidates
0517         a = sort(pt(1,[1 2]));
0518         j = p(max(1,floor(a(1))):min(L,floor(a(2))));      %
0519         Search.Marked(j) = ones(1,length(j));   % select these candidates
0520       else                                      % clicked near the diagonal
0521         newn = max(min(floor(pt(1,1)),L),1);
0522         Display(i).n = p(newn);
0523       end
0524 
0525     case 17                                     % quit Display
0526       if exist('fidOUT','var')
0527         fclose(fidOUT);
0528       end
0529       stop = 1;
0530 
0531   end  % switch statement for menu
0532 
0533 
0534   if any([1 2 3 7 16] == k),
0535       PlotMotif(File(FIndex),Search,Query,Display,i);
0536   end
0537 
0538   if (k == 4) && (UsingFull == 0),
0539     fprintf('Loading structure files\n');
0540     fprintf('If some are not available, Larger Neighborhood will crash\n');
0541     [File,FIndex] = zAddNTData(Search.CandidateFilenames,2,FullFile);
0542     for f = 1:length(File),
0543       if ~isfield(File,'Distance'),
0544         File(f).Distance = [];
0545       end
0546       if isempty(File(f).Distance) && ~isempty(File(f).NumNT),
0547        if (File(f).NumNT > 0),
0548         c = cat(1,File(f).NT.Center); % nucleotide centers
0549         File(f).Distance = zMutualDistance(c,16); % compute distances < 16 Angstroms
0550        end
0551       end
0552     end
0553     FullFile = [];
0554     UsingFull = 1;
0555   end
0556 
0557   if (Display(i).n ~= nn) || (k == 4),
0558     DisplayTable(File(FIndex),Search,Query,Display,i)
0559     nn = Display(i).n;
0560   end
0561 
0562   if any([4 5 6 8] == k),
0563     for j=1:length(Display)
0564       PlotMotif(File(FIndex),Search,Query,Display,j);
0565     end
0566   end
0567 
0568   if length(Display) > 1,
0569       for j=1:length(Display),
0570         figure(j)
0571         sh(j) = subplot(1,1,1);
0572         rotate3d on
0573       end
0574       linkobj = linkprop(sh,...
0575                          {'cameraposition',...
0576                           'cameraupvector',...
0577                           'cameratarget',...
0578                           'cameraviewangle'});
0579       set(gcf, 'UserData', linkobj);
0580   end
0581 
0582   if ShowNavWindow == 1,
0583     ShowNavWindow = 2;
0584   end
0585 
0586   figure(i)
0587   rotate3d on
0588   drawnow
0589 
0590 end  % end while
0591 
0592 if UsingFull == 0,
0593   File = FullFile;
0594   FullFile = [];
0595 end
0596 
0597 %-------------------------------------------------------------------------
0598 %-------------------------------------------------------------------------
0599 %-------------------------------------------------------------------------
0600 
0601 function  PlotMotif(File,Search,Query,Display,i)
0602 
0603   N = Query.NumNT;
0604 
0605   figure(i)
0606   clf
0607 
0608   if (Display(1).superimpose == 1),
0609     Indices = Query.Indices;
0610     if (Query.NumNT > 2),
0611       R = eye(3);
0612       S = mean(cat(1,Query.NT.Center));
0613     else
0614       R = Query.NT(1).Rot;
0615       S = mean(cat(1,Query.NT.Center));
0616     end
0617     MVP.Rotation      = R;
0618     MVP.Shift         = S;
0619     MVP.LineStyle     = '-.';
0620     MVP.LineThickness = '1';
0621     MVP.Sugar         = Display(1).supersugar;
0622     MVP.ConnectSugar  = 0;
0623     MVP.Grid          = 0;
0624     MVP.LabelBases    = Display(1).labelbases;
0625     zDisplayNT(Query,1:N,MVP);
0626   end
0627 
0628   [s,t] = size(Search.Candidates);
0629   n       = Display(i).n;
0630   f       = Search.Candidates(n,N+1);
0631   Indices = double(Search.Candidates(n,1:N));
0632 
0633   if isfield(File(f),'Filename'),
0634     FN = File(f).Filename;
0635   else
0636     FN = '';
0637   end
0638 
0639   nt = File(f).NT(Indices(1));
0640   Title = [strrep(FN,'_','\_') ' ' nt.Base nt.Number];
0641   for j=2:min(10,length(Indices)),
0642     nt = File(f).NT(Indices(j));
0643     Title = [Title '-' nt.Base nt.Number];
0644   end;
0645 
0646   VP.Sugar    = Display(1).sugar;
0647   VP.LabelBases = Display(1).labelbases;
0648 
0649   if Query.NumNT > 2,
0650     MC = Query.WeightedCenteredCenters;          % align to the model
0651     CandiCenters = cat(1,File(f).NT(Indices).Center);
0652     CC = CandiCenters - ones(N,1)*mean(CandiCenters);
0653 
0654     R = zBestRotation(MC, CC);
0655     S = mean(CandiCenters);
0656   else
0657     R = File(f).NT(Indices(1)).Rot;
0658     S = mean(cat(1,File(f).NT(Indices).Center));
0659   end
0660 
0661   VP.Rotation = R;
0662   VP.Shift    = S;
0663   VP.Grid     = 0;
0664 
0665   if Display(1).neighborhood > 0,
0666     v = Display(1).neighborhood;
0667     Indices = xNeighborhood(File(f),Indices,v,Display(1));
0668   end
0669 
0670   if exist('amal.txt','file') > 0,
0671      VP.AtOrigin = 1;
0672   end
0673 
0674   zDisplayNT(File(f),Indices,VP);
0675 
0676   set(gcf,'Name',Title);
0677 
0678   if isfield(Search,'AvgDisc'),   
0679     xlabel(['Candidate ',int2str(n),' of ',int2str(s),'   Average discrepancy from others ', num2str(Search.AvgDisc(n))]);
0680   elseif Query.Geometric > 0,
0681     xlabel(['Candidate ',int2str(n),' of ',int2str(s),'   Discrepancy ',...
0682           num2str(Search.Discrepancy(n))]);
0683   else
0684     xlabel(['Candidate ',int2str(n),' of ',int2str(s)]);
0685   end
0686 
0687   if Search.Marked(n) == 1;
0688     yl = 'Marked';
0689   else
0690     yl = '';
0691   end
0692   ylabel(yl);
0693 
0694   axis equal
0695   axis vis3d
0696   view([Display(1).az Display(1).el]);
0697   drawnow
0698 
0699   % Commands for Amal's study of base triples:
0700 
0701   if exist('amal.txt','file') > 0,
0702 
0703     N1 = File(f).NT(Indices(1));
0704     N2 = File(f).NT(Indices(2));
0705     N3 = File(f).NT(Indices(3));
0706 
0707     ytext = 'Interactions ';
0708     ytext = [ytext ' ' zEdgeText(File(f).Edge(Indices(1),Indices(2))) ' '];
0709     ytext = [ytext ' ' zEdgeText(File(f).Edge(Indices(2),Indices(3))) ' '];
0710     ytext = [ytext ' ' zEdgeText(File(f).Edge(Indices(1),Indices(3))) ' '];
0711 
0712     xlabel(ytext);
0713     view(2)
0714 
0715     if isfield(Search,'AvgDisc'),   
0716       ylabel(['Plot ',int2str(n),' of ',int2str(s),'   Average discrepancy from others ', num2str(Search.AvgDisc(n))]);
0717     elseif Query.Geometric > 0,
0718       ylabel(['Plot ',int2str(n),' of ',int2str(s),'   Discrepancy ',...
0719           num2str(Search.Discrepancy(n))]);
0720     else
0721       ylabel(['Plot ',int2str(n),' of ',int2str(s)]);
0722     end
0723   end
0724   % end of commands for Amal
0725 
0726 
0727 %    set(gcf,'Renderer','OpenGL')
0728 %    set(gcf,'Renderer','zbuffer')
0729 
0730 % ------------------------------------------------- Display table
0731 
0732 function  DisplayTable(File,Search,Query,Display,i)
0733 
0734     N       = Query.NumNT;
0735     n       = Display(i).n;
0736     f       = Search.Candidates(n,N+1);
0737     Indices = double(Search.Candidates(n,1:N));
0738     
0739     if isfield(Search,'AvgDisc'),
0740       fprintf('Average discrepancy from others %6.4f', Search.AvgDisc(n));
0741     elseif Query.Geometric > 0,
0742       fprintf('Discrepancy %6.4f', Search.Discrepancy(n));
0743     else
0744       fprintf('Candidate #%d', Search.Discrepancy(n));  % integer is cand num
0745     end
0746 
0747     if Display(1).neighborhood > 0,
0748       v = Display(1).neighborhood;
0749       Indices = xNeighborhood(File(f),Indices,v,Display(1));
0750     end
0751 
0752     zShowInteractionTable(File(f),double(Indices));
0753 
0754     if isfield(File(f),'BasePhosphate'),
0755       zBasePhosphateTable(File(f),double(Indices));
0756     end
0757     drawnow
0758 
0759 % -------------------------------------------------- Select subset of search
0760 
0761 function [Search2] = SearchSubset(Search,j)
0762 
0763   Search2             = Search;
0764   Search2.Candidates  = Search.Candidates(j,:);
0765   Search2.Discrepancy = Search.Discrepancy(j);
0766   Search2.Marked      = Search.Marked(j);
0767   Search2.Disc        = Search.Disc(j,j);
0768   Search2.DiscComputed= Search.DiscComputed(1,j);
0769

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