首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用生物信息学工具箱在Matlab中可视化分子的三维结构

不使用生物信息学工具箱在Matlab中可视化分子的三维结构
EN

Stack Overflow用户
提问于 2013-05-15 07:16:46
回答 1查看 2K关注 0票数 3

我想用“球和棒”画出一个分子的三维结构图。Matlab生物信息学工具箱展示了如何实现这一目标(以及更多),例如:

代码语言:javascript
复制
 ubi = getpdb('1ubi');
 h1 = molviewer(ubi);

有没有办法在没有生物信息学工具箱的情况下将pdb文件加载到matlab中并\或可视化3d结构?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-15 13:00:26

以下是在Matlab中绘制pdb文件的两个示例:

  1. "Publication-quality protein and molecule rendering in MATLAB“(作者: Callenberg)
  2. Molecule Viewer (作者: Joe Hicklin)

上面(1)中的示例代码:

代码语言:javascript
复制
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 A 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 for 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 for 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 for negatively charged
        else
            r(q,5:7)=[1 0.95 0.9]; %white for hydrophobic
        end

        q=q+1;
    end
    l=fgets(pdb);
end

display 'done loading pdb coordinates';

figure;
hold all;

for 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 to theta to pi is a row vector.
% -pi/2 to phi to pi/2 is a 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
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16554310

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档