Home > FR3DSource > zAddNTData.m

zAddNTData

PURPOSE ^

zAddNTData(Filenames,ReadCode,File,Verbose,PDBStart) reads RNA structure

SYNOPSIS ^

function [File,Index] = zAddNTData(Filenames,ReadCode,File,Verbose,PDBStart)

DESCRIPTION ^

 zAddNTData(Filenames,ReadCode,File,Verbose,PDBStart) reads RNA structure 
 data files, if
 necessary, so that all molecules listed in Filenames are present in File.
 The parameter Index is a non-redundant list of indices of File
 corresponding to names in Filenames.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % zAddNTData(Filenames,ReadCode,File,Verbose,PDBStart) reads RNA structure
0002 % data files, if
0003 % necessary, so that all molecules listed in Filenames are present in File.
0004 % The parameter Index is a non-redundant list of indices of File
0005 % corresponding to names in Filenames.
0006 
0007 % ReadCode = 0,1,2 : load .mat files
0008 % ReadCode = 3     : load, but do not append to File (for reclassification)
0009 % ReadCode = 4     : load _small.mat files, do not compute distances
0010 
0011 % F = zAddNTData('AllFiles_list',3,[],1);
0012 % F = zAddNTData('AllFiles_list',3,[],1,'back');
0013 % F = zAddNTData('NonRedundant_2008_02_21_list',0,[],1);
0014 
0015 function [File,Index] = zAddNTData(Filenames,ReadCode,File,Verbose,PDBStart)
0016 
0017 if nargin < 2,
0018   ReadCode = 0;                           % default is to read .mat files
0019 end
0020 
0021 if nargin < 4,
0022   Verbose = 0;
0023 end
0024 
0025 LoadedFiles = {};
0026 F = 0;
0027 
0028 if nargin >= 3,
0029   F = length(File);
0030   for j = 1:length(File),
0031     LoadedFiles{j} = lower(File(j).Filename);
0032     if isempty(LoadedFiles{j}),
0033       LoadedFiles{j} = '';                     % use empty string
0034     end
0035   end
0036 end
0037 
0038 if strcmp(class(Filenames),'char'),
0039   Filenames = {Filenames};                % make into a cell array
0040 end
0041 
0042 % ----------------------------------------- Read PDB lists, if any
0043 
0044 FullList = [];
0045 
0046 for j=1:length(Filenames),
0047   FullList = [FullList; zReadPDBList(Filenames{j},1)];
0048 end
0049 
0050 % ----------------------------------------- Skip some files
0051 
0052 if nargin == 5,
0053   if strcmp(PDBStart,'back') == 1,
0054     FullList = FullList(end:-1:1);
0055   else
0056     keep = [];
0057     for j=1:length(FullList),
0058       if issorted([lower(PDBStart(1:4)); lower(FullList{j}(1:4))],'rows'),
0059         keep = [keep j];
0060       end
0061     end
0062     FullList = FullList(keep);
0063   end
0064 end
0065 
0066 % ----------------------------------------- Read PDB files
0067 
0068 if length(FullList) > 0,
0069 
0070 for f = 1:length(FullList),                       % loop through PDB list
0071   if ~isempty(FullList{f}),
0072     i = strmatch(lower(FullList{f}), LoadedFiles, 'exact');
0073     if isempty(i),                                  % if PDB not loaded,
0074       NewF = zGetNTData(FullList{f},ReadCode,Verbose); %   load it
0075       if ReadCode ~= 3,
0076         if F == 0,
0077           clear File
0078           File(1) = NewF;
0079         else
0080           File(F+1) = NewF;
0081         end
0082       end
0083       clear NewF;
0084       F = length(File);
0085       k = length(LoadedFiles);
0086       LoadedFiles{k+1} = FullList{f};
0087       Index(f) = F;                           %   point to it
0088     else                                      % but if PDB has been loaded
0089       Index(f) = i(1);                        %   point to first instance
0090       if length(File(i(1)).NT) == 0,
0091         NewF = zGetNTData(File(Index(f)).Filename,ReadCode,Verbose);
0092         if ReadCode ~= 3,
0093           File(Index(f)) = NewF;
0094           clear NewF;
0095         end
0096       end
0097     end
0098   end
0099 end
0100 
0101 % -----------------------------------  allow for File(Index)
0102 F = length(File);
0103 
0104 for i = 1:length(Index),             
0105   if Index(i) == 0,
0106     File(F+1).Filename = 'Fictitious';
0107     File(F+1).NumNT = 0;               % create a fictitious file
0108     Index(i) = F+1;                    % point to the fictitious file
0109   end
0110 end
0111 
0112 else
0113 
0114 fprintf('No files specified to read in %s\n', Filenames{1});
0115 
0116 end

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