Home > FR3DSource > xFR3DSearch.m

xFR3DSearch

PURPOSE ^

xFR3DSearch conducts the search given in xSpecifyQuery in the PDB files

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 xFR3DSearch conducts the search given in xSpecifyQuery in the PDB files 
 listed in zFileNameList

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xFR3DSearch conducts the search given in xSpecifyQuery in the PDB files
0002 % listed in zFileNameList
0003 
0004 % Change the list of PDB files to be searched by editing zFileNameList
0005 % Change the query by editing xSpecifyQuery
0006 
0007 % The result of running xFR3DSearch is a variable Search with these fields:
0008 %
0009 %    .Query                     % a description of the search parameters
0010 %    .Filenames                 % names of files that were searched
0011 %    .TotalTime                 % how much time the search took
0012 %    .Date                      % date of the search
0013 %    .Time                      % time the search was started
0014 %    .SaveName                  % name for the saved search file
0015 %    .Candidates                % L x N+1 matrix of indices of candidates
0016                                 % L is the number of candidates found
0017                                 % N is the number of search nucleotides
0018                                 % the last column of Candidates is the index
0019                                 % of the file in which the candidate was found
0020 %    .Discrepancy               % geometric discrepancy of each candidate
0021                                 % from the query, for geometric searches
0022 
0023 if ~exist('Verbose'),
0024   Verbose = 1;                               % default is to print output
0025 end
0026 
0027 if ~exist('GUIactive') && ~exist('UsingLibrary'),  % FR3D should just search
0028   Query     = xSpecifyQuery;                 % get search parameters
0029   if isfield(Query,'SearchFiles'),           % if query specifies files
0030     Filenames = Query.SearchFiles;
0031   else
0032     Filenames = {'1s72'};                    % default
0033   end
0034 end
0035 
0036 % ----------------------------------------- Load PDB files if needed --------
0037 
0038 if ~exist('File'),                           % if no molecule data is loaded,
0039   [File,SIndex] = zAddNTData(Filenames,0,[],Verbose);   % load PDB data
0040 else
0041   [File,SIndex] = zAddNTData(Filenames,0,File,Verbose); %add PDB data if needed
0042 end                       % SIndex tells which elements of File to search
0043 
0044 % ------------------------------------------- Store actual filenames
0045 %                                             rather than list name(s)
0046 
0047 clear Filenames
0048 
0049 for i = 1:length(SIndex),
0050   Filenames{i} = File(SIndex(i)).Filename;
0051 end
0052 
0053 % ------------------------------------------- Construct details of search ---
0054 
0055 if ~exist('UsingLibrary'),
0056  if isfield(Query,'Filename'),                % if query motif is from a file
0057   [File,QIndex] = zAddNTData(Query.Filename,0,File);  
0058                                              % load data for Query, if needed
0059   Query = xConstructQuery(Query,File(QIndex)); % preliminary calculations
0060  else
0061   Query = xConstructQuery(Query);              % preliminary calculations
0062  end
0063 
0064 end
0065 
0066 clear Search
0067 Search.SaveName = [datestr(now,31) '-' Query.Name];  
0068                                   % use date and time to identify this search
0069 
0070 %Query
0071 %Search
0072 
0073 if isfield(Query,'NumNT'),                    % if query is specified OK
0074 
0075 % ------------------------------------------- Display query information------
0076 
0077 if Verbose > 0,
0078   fprintf('Query %s:', Query.Name);             % display query name
0079 
0080   if isfield(Query,'Description'),
0081     fprintf(' %s\n', Query.Description);
0082   else
0083     fprintf('\n');
0084   end
0085 end
0086 
0087 % ------------------------------------------- Calc more distances if needed -
0088 
0089 for f=1:length(SIndex),
0090   i = SIndex(f);
0091   if isempty(File(i).Distance),
0092     dmin = 0;
0093   else
0094     dmin = ceil(max(max(File(i).Distance)));
0095   end
0096 
0097   if (ceil(Query.DistCutoff) > dmin) && (File(i).NumNT > 0),
0098     c = cat(1,File(i).NT(1:File(i).NumNT).Center);
0099     File(i).Distance = zMutualDistance(c,Query.DistCutoff); 
0100              % sparse matrix of center-center distances, up to Query.DistCutoff
0101   end
0102 end
0103 
0104 drawnow
0105 
0106 % ------------------------------------------- Find candidates ---------------
0107 
0108 starttime = cputime;
0109 
0110 Candidates = xFindCandidates(File(SIndex),Query,Verbose);  % screen for candidates
0111 
0112 if ~isempty(Candidates),                         % some candidate(s) found
0113  if Query.Geometric > 0,
0114   [Discrepancy, Candidates] = xRankCandidates(File(SIndex),Query,Candidates,Verbose);
0115   if Verbose > 0,
0116     fprintf('Found %d candidates in the desired discrepancy range\n',length(Discrepancy));
0117   end
0118 
0119    if (Query.ExcludeOverlap > 0) & (length(Discrepancy) > 0) ...
0120      & (Query.NumNT > 2),
0121      [Candidates, Discrepancy] = xReduceOverlap(Candidates,Discrepancy); 
0122                                                  % quick reduction in number
0123      [Candidates, Discrepancy] = xExcludeOverlap(Candidates,Discrepancy,400); 
0124                                                 % find top 400 distinct ones
0125      if Verbose > 0,
0126        fprintf('Removed highly overlapping candidates, kept %d\n', length(Candidates(:,1)));
0127      end
0128    end
0129 
0130  elseif Query.NumNT > 2,
0131   A = [Candidates sum(Candidates')'];        % compute sum of indices
0132   N = Query.NumNT;                           % number of nucleotides
0133   [y,i] = sortrows(A,[N+1 N+2 1:N]);         % sort by file, then this sum
0134   Candidates = Candidates(i,:);              % put all permutations together
0135   Discrepancy = (1:length(Candidates(:,1)))';% helps identify candidates
0136  else
0137   N = Query.NumNT;                           % number of nucleotides
0138   [y,i] = sortrows(Candidates,[N+1 1 2]);
0139   Candidates = Candidates(i,:);              % put all permutations together
0140   Discrepancy = (1:length(Candidates(:,1)))';% helps identify candidates
0141  end
0142 
0143 % -------------------------------------------------- Save results of search
0144 
0145   Search.Query       = Query;
0146   Search.Filenames   = Filenames;
0147   Search.TotalTime   = cputime - starttime;
0148   Search.Date        = Search.SaveName(1:10);
0149   Search.Time        = Search.SaveName(12:18);
0150   Search.SaveName    = strrep(Search.SaveName,' ','_');
0151   Search.SaveName    = strrep(Search.SaveName,':','_');
0152   Search.SaveName    = strrep(Search.SaveName,'<','_');
0153   Search.SaveName    = strrep(Search.SaveName,'>','_');
0154   Search.SaveName    = strrep(Search.SaveName,'?','_');
0155   Search.SaveName    = strrep(Search.SaveName,'*','_');
0156   Search.SaveName    = strrep(Search.SaveName,'&','_');
0157   Search.Candidates  = Candidates;
0158   Search.Discrepancy = Discrepancy;
0159 
0160   Search = xAddFiletoSearch(File(SIndex),Search);
0161 
0162   if ~exist('UsingLibrary'),
0163 
0164     if ~(exist('SearchSaveFiles') == 7),     % if directory doesn't yet exist
0165       mkdir('SearchSaveFiles');
0166     end
0167 
0168     save(['SearchSaveFiles' filesep Search.SaveName], 'Search');
0169  end
0170 % ------------------------------------------------ Display results
0171 
0172  if Verbose > 0,
0173    fprintf('Entire search took %8.4f seconds, or %8.4f minutes\n', (cputime-starttime), (cputime-starttime)/60);
0174  end
0175 
0176  if (~exist('GUIactive')) && (~isempty(Candidates)) && ~exist('UsingLibrary'),
0177    xListCandidates(Search,Inf,1);
0178    Search = xDisplayCandidates(File(SIndex),Search);
0179    save(['SearchSaveFiles' filesep Search.SaveName], 'Search');
0180  end
0181 
0182 end
0183 
0184 end

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