Home > FR3DSource > zDisplayNT.m

zDisplayNT

PURPOSE ^

zDisplayNT(File,NTList,ViewParam) is a general-purpose nucleotide plotting program. It can be called in several ways, for example,

SYNOPSIS ^

function [void] = zDisplayNT(File,NTList,ViewParam)

DESCRIPTION ^

 zDisplayNT(File,NTList,ViewParam) is a general-purpose nucleotide plotting program.  It can be called in several ways, for example,
 zDisplayNT('1s72',{'27','28','29'},ViewParam), and it will load the
 named datafile and plot the nucleotides by nucleotide number.  Or, if
 data files have already been loaded, one can use zDisplayNT(File(1),[32
 34 35],ViewParam) to plot the nucleotides in File(1) having indices 32,
 34, and 35.  Defaults for ViewParam are defined in zDisplayNT; see there
 for the fields of ViewParam.
 One can also use ranges of nucleotide numbers, as in
 zDisplayNT('rr0033_23S',{'2548:2555','2557','2559:2566'},VP);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % zDisplayNT(File,NTList,ViewParam) is a general-purpose nucleotide plotting program.  It can be called in several ways, for example,
0002 % zDisplayNT('1s72',{'27','28','29'},ViewParam), and it will load the
0003 % named datafile and plot the nucleotides by nucleotide number.  Or, if
0004 % data files have already been loaded, one can use zDisplayNT(File(1),[32
0005 % 34 35],ViewParam) to plot the nucleotides in File(1) having indices 32,
0006 % 34, and 35.  Defaults for ViewParam are defined in zDisplayNT; see there
0007 % for the fields of ViewParam.
0008 % One can also use ranges of nucleotide numbers, as in
0009 % zDisplayNT('rr0033_23S',{'2548:2555','2557','2559:2566'},VP);
0010 
0011 function [void] = zDisplayNT(File,NTList,ViewParam)
0012 
0013 % set default values
0014 
0015 VP.Sugar     = 0;
0016 VP.LabelSugar= 0;
0017 VP.az        = 51;
0018 VP.el        = 14;
0019 VP.LineStyle = '-';              % default - thick solid lines
0020 VP.LineThickness = '2';          
0021 VP.AtOrigin  = 0;                % rotate all so first is at origin
0022 VP.Title     = 1;                % title with nucleotide numbers, filename
0023 VP.Grid      = 1;                % add a grid to the graph
0024 VP.FontSize  = 10;               % will use Matlab's default unless overridden
0025 VP.Rotation  = eye(3);
0026 VP.Shift     = zeros(1,3);
0027 VP.LabelBases = 10;              % font size; use 0 to not label bases at all
0028 VP.WritePDB      = 0;
0029 VP.Animate   = 0;
0030 VP.AnimationFilename = '';
0031 
0032 if nargin == 1,
0033   ViewParam = VP;
0034 end
0035 
0036 if nargin == 2,
0037   ViewParam = VP;
0038 end
0039 
0040 % replace defaults with defined values
0041 
0042 if isfield(ViewParam,'Sugar'),
0043   VP.Sugar = ViewParam.Sugar;
0044 end
0045 
0046 if isfield(ViewParam,'LabelSugar'),
0047   VP.LabelSugar = ViewParam.LabelSugar;
0048 end
0049 
0050 if isfield(ViewParam,'az'),
0051   VP.az = ViewParam.az;
0052 end
0053 
0054 if isfield(ViewParam,'el'),
0055   VP.el = ViewParam.el;
0056 end
0057 
0058 if isfield(ViewParam,'LineStyle'),
0059   VP.LineStyle = ViewParam.LineStyle;
0060 end
0061 
0062 if isfield(ViewParam,'LineThickness'),
0063   VP.LineThickness = ViewParam.LineThickness;
0064 end
0065 
0066 if isfield(ViewParam,'Color'),
0067   VP.Color = ViewParam.Color;
0068 end
0069 
0070 if isfield(ViewParam,'AtOrigin'),
0071   VP.AtOrigin = ViewParam.AtOrigin;
0072 end
0073 
0074 if isfield(ViewParam,'Title'),
0075   VP.Title = ViewParam.Title;
0076 end
0077 
0078 if isfield(ViewParam,'Grid'),
0079   VP.Grid = ViewParam.Grid;
0080 end
0081 
0082 if isfield(ViewParam,'FontSize'),
0083   h=gca;
0084   set(h,'FontSize',ViewParam.FontSize);
0085 end
0086 
0087 if isfield(ViewParam,'Rotation'),
0088   VP.Rotation = ViewParam.Rotation;
0089 end
0090 
0091 if isfield(ViewParam,'Shift'),
0092   VP.Shift = ViewParam.Shift;
0093 end
0094 
0095 if isfield(ViewParam,'LabelBases'),
0096   VP.LabelBases = ViewParam.LabelBases;
0097 end
0098 
0099 if isfield(ViewParam,'WritePDB'),
0100   VP.WritePDB = ViewParam.WritePDB;
0101 end
0102 
0103 if isfield(ViewParam,'Animate'),
0104   VP.Animate = ViewParam.Animate;
0105 end
0106 
0107 if isfield(ViewParam,'AnimationFilename'),
0108   VP.AnimationFilename = ViewParam.AnimationFilename;
0109 end
0110 
0111 if isfield(ViewParam,'Colors'),
0112   VP.Colors = ViewParam.Colors;
0113 end
0114 
0115 % if File is a text string (filename), load the file and display
0116 
0117 if strcmp(class(File),'char'),
0118   Filename = File;
0119   File = zGetNTData(Filename,0);
0120 end
0121 
0122 if nargin == 1 || isempty(NTList),
0123   NTList = 1:length(File.NT);                  % display them all
0124 end
0125 
0126 % if NTList is a cell array of numbers, look up the indices
0127 
0128 if strcmp(class(NTList),'char'),
0129   NTList = {NTList};
0130 end
0131 
0132 if strcmp(class(NTList),'cell'),
0133   Indices = zIndexLookup(File,NTList);
0134 else
0135   Indices = NTList;
0136 end
0137 
0138 % plot the nucleotides, at the origin or in original positions
0139 
0140 %set(gcf,'Renderer','OpenGL');
0141 
0142 if VP.AtOrigin == 1,
0143   R = File.NT(Indices(1)).Rot;             % Rotation matrix for first base
0144   S = File.NT(Indices(1)).Fit(1,:);        % Location of glycosidic atom
0145 else
0146   R = VP.Rotation;
0147   S = VP.Shift;
0148 end
0149 
0150 for j=1:length(Indices),                 % Loop through all nucleotides
0151   k = Indices(j);                        % index of current nucleotide
0152   zPlotOneNTRotated(File.NT(k),VP,R,S);
0153 end
0154 
0155 Title = strcat(File.NT(Indices(1)).Base,File.NT(Indices(1)).Number);
0156 for j=2:length(Indices),
0157   nt = File.NT(Indices(j));
0158   Title = strcat(Title,'-',nt.Base,nt.Number);
0159 end;
0160 
0161 if isfield(File,'Filename'),
0162   FN = File.Filename;
0163 else
0164   FN = '';
0165 end
0166 
0167 Title = strcat(Title,[' ' strrep(FN,'_','\_')]);
0168 
0169 title(Title);
0170 axis equal
0171 view(VP.az,VP.el);
0172 
0173 if VP.Grid == 1,
0174   grid on
0175 else
0176   grid off
0177 end
0178 
0179 rotate3d on
0180 
0181 if VP.WritePDB == 1,
0182   if VP.AtOrigin == 1,
0183     G = eye(3);
0184     R = File.NT(Indices(1)).Rot * G(:,[2 3 1]);% Rotation matrix for first base
0185     S = File.NT(Indices(1)).Fit(1,:);        % Location of glycosidic atom
0186   else
0187     R = VP.Rotation;
0188     S = VP.Shift;
0189   end
0190 
0191   a = 1;
0192   fid = fopen('PDBFile.pdb','w');
0193 
0194   for j=1:length(Indices),                 % Loop through all nucleotides
0195     k = Indices(j);                        % index of current nucleotide
0196     a = zWriteNucleotidePDB(fid,File.NT(k),a,0,R,S);
0197   end
0198 
0199   fclose(fid);
0200 end
0201 
0202 if VP.Animate == 1,
0203   NumFrames = 90;
0204   S = zeros(1,3);
0205   for j = 1:length(Indices);
0206     S = S + File.NT(Indices(j)).Center;
0207   end
0208   S = S / length(Indices);
0209 
0210   th = 0.1;
0211   Spin = [[cos(th) sin(th) 0]; [-sin(th) cos(th) 0]; [0 0 1]];
0212 
0213   if isfield(ViewParam,'Rotation'),
0214     R = VP.Rotation;
0215   else
0216     R = File.NT(Indices(1)).Rot * Spin([3 1 2], [3 1 2]);
0217   end
0218 
0219   maxradius = 0;
0220   minheight = 0;
0221   maxheight = 0;
0222   for j = 1:length(Indices);
0223     L  = length(File.NT(Indices(j)).Fit(:,1));         % Number of base atoms
0224     V  = (File.NT(Indices(j)).Fit - ones(L,1)*S) * R;
0225     maxradius = max(maxradius,max(sqrt(V(:,1).^2+V(:,2).^2)));
0226     minheight = min(minheight,min(V(:,3)));
0227     maxheight = max(maxheight,max(V(:,3)));
0228     L  = length(File.NT(Indices(j)).Sugar(:,1));         % Number of base atoms
0229     V  = (File.NT(Indices(j)).Sugar - ones(L,1)*S) * R;
0230     maxradius = max(maxradius,max(sqrt(V(:,1).^2+V(:,2).^2)));
0231     minheight = min(minheight,min(V(:,3)));
0232     maxheight = max(maxheight,max(V(:,3)));
0233   end
0234   maxradius = maxradius + 1;
0235   minheight = minheight - 1;
0236   maxheight = maxheight + 1;
0237 
0238   th = 2*pi/NumFrames;
0239   Spin = [[cos(th) sin(th) 0]; [-sin(th) cos(th) 0]; [0 0 1]];
0240 
0241   for g = 1:NumFrames,
0242 
0243     R = R * Spin;
0244     clf
0245     for j=1:length(Indices),                 % Loop through all nucleotides
0246       k = Indices(j);                        % index of current nucleotide
0247       if isfield(VP,'Colors'),
0248         VP.Color = VP.Colors(k,:);
0249       end
0250       zPlotOneNTRotated(File.NT(k),VP,R,S);
0251     end
0252   
0253     Title = strcat(File.NT(Indices(1)).Base,File.NT(Indices(1)).Number);
0254     for j=2:length(Indices),
0255       nt = File.NT(Indices(j));
0256       Title = strcat(Title,'-',nt.Base,nt.Number);
0257     end;
0258 
0259     if isfield(File,'Filename'),
0260       FN = File.Filename;
0261     else
0262       FN = '';
0263     end
0264   
0265     Title = strcat(Title,[' ' strrep(FN,'_','\_')]);
0266   
0267 %    title(Title);
0268     axis equal
0269     axis([-maxradius maxradius -maxradius maxradius minheight maxheight]);
0270     set(gca,'TickLength',[0 0]);
0271     grid off  
0272 %    axis off
0273     view(0,0);
0274     drawnow
0275 
0276     Image = getframe;        % get current pseudo color image
0277     Image.cdata = Image.cdata(1:(end-1),2:end,:);
0278     P = frame2im(Image);        % Convert to a image representation that Matlab can handle
0279     filename = ['Animation/' VP.AnimationFilename num2str(g+100) '.bmp'];
0280     imwrite(P,filename, 'bmp')  % Finally write the individual images
0281 
0282   end
0283 end

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