Home > FR3DSource > zBackboneConformation.m

zBackboneConformation

PURPOSE ^

SYNOPSIS ^

function [File] = zBackboneConformation(File,Verbose)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 
0002 function [File] = zBackboneConformation(File,Verbose)
0003 
0004 if nargin < 2,
0005   Verbose = 0;
0006 end
0007 
0008 File.Backbone = sparse(zeros(length(File.NT)));
0009 
0010 if exist('chiropraxis.jar') == 2 ...       % if chiropraxis is here
0011    && File.NumNT > 1 ...                   % and there is more than one NT
0012    && exist(File.PDBFilename) == 2,        % and the PDB file is available
0013 
0014   d = which([File.Filename '.pdb']);
0015   e = which('chiropraxis.jar');
0016   g = which('suitename.0.3.070628.win.exe');
0017 
0018   fid = fopen('tempbat.bat','w');
0019 
0020   fprintf(fid,'echo off\n');
0021 
0022   fprintf(fid,'java -cp "%s" chiropraxis.dangle.Dangle rnabb < "%s" > %s_dangle.txt\n', e, d, File.Filename);
0023 
0024   fprintf(fid,'"%s" < %s_dangle.txt > %s_suitename.txt\n', g, File.Filename, File.Filename);
0025 
0026   %fprintf(fid,'pause\n');
0027 
0028   fclose(fid);
0029 
0030   !tempbat.bat
0031 
0032   fid = fopen([File.Filename '_suitename.txt'],'r');
0033 
0034   if fid > 0
0035 
0036   clear T
0037   L = 1;
0038   c = 1;
0039 
0040   while L > -1
0041     L = fgets(fid);
0042     if L > -1
0043       if L(1) == ':',
0044         T{c} = L;
0045         c = c + 1;
0046       else
0047         L = -1;                                   % stop reading file
0048       end
0049     end
0050   end
0051 
0052   else
0053 
0054   fprintf('zBackboneConformation could not open file %s\n', [File.Filename '_suitename.txt']);
0055 
0056   end
0057 
0058   fclose(fid);
0059 
0060   %123456789012345678901234567890
0061   %:1:A: 388: :  G 33 p 1a 0.630
0062 
0063   File.Backbone = sparse(zeros(length(File.NT)));
0064 
0065   zBackboneCodes;
0066 
0067   Numbers = cat(1,{File.NT(:).Number});
0068 
0069   c = 0;                                      % current index in the file
0070 
0071   for t = 1:length(T),
0072   a = T{t};
0073 
0074   h = strfind(a,':');
0075 
0076   if a(h(4)+1) ~= ' ',
0077     b = [a((h(3)+1):(h(3)+4)) a(h(4)+1)];
0078   else
0079     b = a((h(3)+1):(h(3)+4));
0080   end
0081 
0082   i = LookUpOne(File,Numbers,strrep(b,' ',''),a(h(2)+1),0);
0083 
0084   if length(i) > 1,
0085     w = find(i > c);
0086     i = i(w(1));
0087   end
0088 
0089   if ~isempty(i),
0090     c = i;
0091   end
0092 
0093   if isempty(i),
0094     if Verbose > 0,
0095       fprintf('%s has no corresponding nucleotide in FR3D\n', a(1:29));
0096     end
0097   elseif Verbose > 2,
0098     fprintf('%s becomes %s%s\n', a(1:29), File.NT(i).Base, File.NT(i).Number);
0099   end
0100 
0101   bbc = find(ismember(Codes,a((h(5)+10):(h(5)+11))));   % look up FR3D's internal code
0102 
0103   if isempty(bbc),
0104     fprintf('Found a new code, %s\n', a((h(5)+10):(h(5)+11)));
0105   elseif bbc < length(Codes) && ~isempty(i),
0106     if i > 1,
0107       if File.Covalent(i-1,i) == 1,             % linked to previous NT
0108         File.Backbone(i-1,i) = bbc;
0109       end
0110     end
0111   end
0112   end
0113 
0114   delete('tempbat.bat');
0115   delete([File.Filename '_dangle.txt']);
0116   delete([File.Filename '_suitename.txt']);
0117 
0118 else
0119 %  fprintf('Cannot determine backbone conformations for %s\n', File.Filename);
0120 end
0121 
0122 return
0123 
0124 % determine necessary codes
0125 
0126 for t = 1:length(T),
0127   g{t} = T{t}(22:23);
0128 end
0129 G = unique(g);
0130 
0131 
0132 % now read the successful output of suitename, convert the codes to numbers, store them, match the codes to numbers in zEdgeText, and implement this in xPairwiseScreen.  Also make it possible to see the backbone conformations for candidates.  Work, but not so bad.
0133 
0134 
0135 %-------------------------------------------------------------------------
0136 function [ind] = LookUpOne(File,Numbers,N,Chain,Verbose)
0137 
0138     if any(N(1) == 'ACGU'),
0139       N = N(2:end);
0140     end
0141 
0142     % later, add the ability to infer the chain from the base specified
0143 
0144     ind = [];
0145     p = find(ismember(Numbers,N));
0146     if length(p) == 0,
0147       if Verbose > 0,
0148         fprintf('Could not find nucleotide %s in %s\n',N,File.Filename);
0149       end
0150     elseif length(p) == 1 & length(Chain) == 0, % one match, no chain specified
0151       ind = [ind p];
0152     elseif length(p) > 1 & length(Chain) == 0,% two matches, no chain specified
0153       ind = [ind p];
0154       if Verbose > 0,
0155         fprintf('Multiple matches found for %s in %s, consider specifying a chain\n', N, File.Filename);
0156       end
0157       for a = 1:length(ind),
0158         if Verbose > 0,
0159           fprintf('Nucleotide %s%s Chain %5s Index %5d\n', File.NT(ind(a)).Base, File.NT(ind(a)).Number, File.NT(ind(a)).Chain, ind(a));
0160         end
0161       end
0162     elseif length(Chain) > 0,                    % chain specified
0163       c = 0;
0164       for j = 1:length(p),
0165         if strcmp(File.NT(p(j)).Chain,Chain),
0166           ind = [ind p(j)];
0167           c = c + 1;
0168         end
0169       end
0170       if c == 0,
0171         if Verbose > 0,
0172           fprintf('Could not find nucleotide %s in chain %s in %s\n',N,Chain,File.Filename);
0173         end
0174       elseif c > 1,
0175         if Verbose > 0,
0176           fprintf('Multiple matches found for %s in chain %s in %s\n', N,Chain,File.Filename);
0177         end
0178       end
0179     end

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