Visualizing the 3D Structure of a Molecule in Matlab without using the Bioinformatics Toolbox -
i'd produce plot of 3d structure of molecule, using "balls , sticks". matlab bioinformatics toolbox show's how accomplish (and more) using example:
ubi = getpdb('1ubi'); h1 = molviewer(ubi);
is there way load pdb files matlab and\or visualize 3d structure without bioinformatics toolbox?
here 2 examples of plotting pdb file in matlab:
- "publication-quality protein , molecule rendering in matlab" (author: keith callenberg)
- molecule viewer (author: joe hicklin)
sample code (1) above:
function draw_protein(pdbfile) pdb=fopen(pdbfile,'r'); l=fgets(pdb); q=1; resolution = 5; while l~=-1 if (l(1:4) == 'atom') & (l(14) ~= 'h' & l(13) ~= 'h') if (strncmp('phe',l(18:20),3)==1 & strncmp('c',l(14),1)==1) | ... (strncmp('tyr',l(18:20),3)==1 & strncmp('c',l(14),1)==1) | ... (strncmp('trp',l(18:20),3)==1 & strncmp('c',l(14),1)==1) if strncmp('cg',l(14:15),2)==1 | strncmp('cd ',l(14:16),3)==1 | ... strncmp('ce',l(14:15),2)==1 | strncmp('cz',l(14:15),2)==1 | ... strncmp('cd2',l(14:16),3)==1 r(q,4)=1.85; elseif strncmp('c',l(14),1)==1 r(q,4)=2.0; end elseif strncmp('n',l(14),1)==1 r(q,4)=1.5; elseif strncmp('c',l(14),1)==1 r(q,4)=2.0; elseif strncmp('o',l(14),1)==1 r(q,4)=1.4; elseif strncmp('s',l(14),1)==1 r(q,4)=1.85; elseif strncmp('pot',l(14:16),3)==1 r(q,4)=1.49 %r(q,4)=3.31 elseif (l(14) == 'h' | l(13) == 'h') if l(64) == '1' r(q,4) = 1; %else % r(q,4) = 0; end else %display('unknown atom type') l r(q,4)=2.0; % call unknown atom carbon end r(q,1)=str2num(l(31:38)); % x r(q,2)=str2num(l(39:46)); % y r(q,3)=str2num(l(47:54)); % z if strncmp('arg',l(18:20),3)==1 | strncmp('lys',l(18:20),3)==1 | strncmp('hsp',l(18:20),3)==1 r(q,5:7)=[0.2 0.1 0.90]; %blue positively charged elseif strncmp('thr',l(18:20),3)==1 | strncmp('asn',l(18:20),3)==1 | strncmp('ser',l(18:20),3)==1 | strncmp('gln',l(18:20),3)==1 r(q,5:7)=[0.2 0.90 0.1]; %green uncharged polar elseif strncmp('asp',l(18:20),3)==1 | strncmp('glu',l(18:20),3)==1 r(q,5:7)=[0.90 0.2 0.1]; %red negatively charged else r(q,5:7)=[1 0.95 0.9]; %white hydrophobic end q=q+1; end l=fgets(pdb); end display 'done loading pdb coordinates'; figure; hold all; i=1:length(r(:,1)) draw_sphere(r(i,1),r(i,2),r(i,3),r(i,4),r(i,5:7),resolution); end light camlight('right'); end function draw_sphere(xd,yd,zd,rad,color,resolution) n = resolution; % -pi theta pi row vector. % -pi/2 phi pi/2 column vector. theta = (-n:2:n)/n*pi; phi = (-n:2:n)'/n*pi/2; cosphi = cos(phi); cosphi(1) = 0; cosphi(n+1) = 0; sintheta = sin(theta); sintheta(1) = 0; sintheta(n+1) = 0; x = cosphi*cos(theta); y = cosphi*sintheta; z = sin(phi)*ones(1,n+1); surf(rad*x+xd,rad*y+yd,rad*z+zd,'edgecolor','none','facecolor',color,'facelighting','phong','ambientstrength',0.1,'diffusestrength',0.8,'specularstrength',0.2); end
Comments
Post a Comment