Home > FR3DSource > xAddFiletoSearch.m

xAddFiletoSearch

PURPOSE ^

xAddFiletoSearch(File,Search) adds data on nucleotides found in Search. It assumes that File is in the proper order for the index in Candidates

SYNOPSIS ^

function [Search] = xAddFiletoSearch(File,Search)

DESCRIPTION ^

 xAddFiletoSearch(File,Search) adds data on nucleotides found in Search.  It assumes that File is in the proper order for the index in Candidates

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xAddFiletoSearch(File,Search) adds data on nucleotides found in Search.  It assumes that File is in the proper order for the index in Candidates
0002 
0003 function [Search] = xAddFiletoSearch(File,Search)
0004 
0005 Query       = Search.Query;
0006 Candidates  = Search.Candidates;
0007 
0008 [s,t]       = size(Candidates);
0009 N           = Query.NumNT;
0010 
0011 if (s==0),                                % no candidates
0012   Search.CandidateFilenames{1} = '';
0013   Search.File(1).Filename = '';
0014 else
0015 
0016   [y,p] = sort(double(Candidates(1,1:N))); % put nucleotides of first candidate in increasing order
0017   
0018   Cand = double(Candidates(:,p));     % re-order nucleotides acc to first
0019 
0020   if isfield(Query,'MaxDiffMat'),
0021     MaxDiff = diag(Query.MaxDiffMat(p,p),1);
0022   else
0023     MaxDiff = Inf*ones(1,N-1);
0024   end
0025   
0026   % ---------------------------- Calculate maximum gaps between cand. nucleotides
0027   
0028   maxinsert = zeros(1,N-1);
0029   for c = 1:s,
0030     maxinsert = max(maxinsert,abs(diff(double(Cand(c,1:N))))-1);
0031   end
0032   
0033   % ---------------------------- Add nucleotide information
0034   
0035   if ~isempty(File),
0036     for f = 1:max(Candidates(:,N+1)),            % loop through files
0037       Search.File(f).Edge     = sparse(zeros(1,1));
0038       Search.File(f).BasePhosphate = sparse(zeros(1,1));
0039       Search.File(f).Range    = sparse(zeros(1,1));
0040       Search.File(f).Crossing = sparse(zeros(1,1));
0041       Search.File(f).Covalent = sparse(zeros(1,1));
0042       Search.File(f).Backbone = sparse(zeros(1,1));
0043 
0044     end
0045   
0046     for i = 1:s,
0047       f = double(Candidates(i,N+1));             % file number for this candidate
0048   
0049       Search.CandidateFilenames{f} = File(f).Filename;
0050       Search.File(f).Filename      = File(f).Filename;
0051       Search.File(f).NumNT         = File(f).NumNT; % max number, some empty
0052       Search.File(f).Info          = File(f).Info;
0053   
0054       Indices = Cand(i,1:N);               % indices of nucleotides
0055   
0056       for j = Indices,
0057         Search.File(f).NT(j) = File(f).NT(j);
0058         for k = Indices,
0059           Search.File(f).Edge(j,k) = File(f).Edge(j,k);
0060           Search.File(f).Edge(k,j) = File(f).Edge(k,j);
0061           Search.File(f).BasePhosphate(j,k) = File(f).BasePhosphate(j,k);
0062           Search.File(f).BasePhosphate(k,j) = File(f).BasePhosphate(k,j);
0063           Search.File(f).Range(j,k) = File(f).Range(j,k);
0064           Search.File(f).Range(k,j) = File(f).Range(k,j);
0065           Search.File(f).Covalent(j,k) = File(f).Covalent(j,k);
0066           Search.File(f).Covalent(k,j) = File(f).Covalent(k,j);
0067           Search.File(f).Crossing(j,k) = File(f).Crossing(j,k);
0068           Search.File(f).Crossing(k,j) = File(f).Crossing(k,j);
0069           Search.File(f).Backbone(j,k) = File(f).Backbone(j,k);
0070           Search.File(f).Backbone(k,j) = File(f).Backbone(k,j);
0071         end
0072       end
0073   
0074       % include intervening nucleotides, if only a few, for alignments
0075   
0076       for n = 1:(N-1),                               % loop through nucleotides
0077        if (MaxDiff(n) < Inf) | (maxinsert(n) < 5),   % if only few insertions
0078         if double(Indices(n+1)) - double(Indices(n)) > 1,   % increasing order
0079           for i = (Indices(n)+1):(Indices(n+1)-1),
0080             Search.File(f).NT(i) = File(f).NT(i);
0081           end
0082         elseif double(Indices(n+1)) - double(Indices(n)) < -1, % dec order
0083           for i = (Indices(n)-1):-1:(Indices(n+1)+1),
0084             Search.File(f).NT(i) = File(f).NT(i);
0085           end
0086         end
0087        end
0088       end
0089     end
0090   elseif ~isfield(Search,'CandidateFilenames'),
0091     List = {};
0092     fprintf('Attempting to convert filenames and lists to current format\n');
0093     for j=1:length(Search.Filenames),
0094       if strfind(Search.Filenames{j},'_list'),
0095         fprintf('If %s has changed or is no longer present, this may fail!\n',Search.Filenames{j});
0096       end
0097       List = [List; zReadPDBList(Search.Filenames{j},1)];
0098     end
0099     Search.CandidateFilenames = List;
0100   end
0101 end

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