MATLAB读取pdb文件的特定字段

时间:2015-09-05 18:19:46

标签: matlab coordinates

我必须在MATLAB中对此进行编码。我的问题是我想提取某些原子的坐标,这些原子只对应于PDB文件中的一些残基。例如,我想提取PDB文件中存在的所有丙氨酸的CA原子的坐标。我尝试使用find(strcmp(atoms,' CA'))但它只给了我所有的CA原子而不是丙氨酸的CA.如何在MATLAB中解决这个问题?请帮助。谢谢。

1 个答案:

答案 0 :(得分:3)

我对PDB文件的所有了解都是我今天在http://www.wwpdb.org/index和此处(http://www.wwpdb.org/documentation/file-format-content/format33/v3.3.html)阅读的内容。

我使用MatLab帮助提供的示例来阅读PDB文件。

根据从PDB文件读取的数据结构和文件格式的描述,在我看来,您要查找的数据包含在Model.Atom字段中。 / p>

更准确地说(glfpdbread函数读取的结构的名称):

gfl.Model.Atom(:).AtomName
gfl.Model.Atom(:).resName
gfl.Model.Atom(:).X
gfl.Model.Atom(:).Y
gfl.Model.Atom(:).Z

如果是这样,为了识别Alcaline的原子“CA”,您可以使用findstrcmp函数的组合,如下所示:

pos=find(strcmp({gfl.Model.Atom(:).AtomName},'CA') & ...
   strcmp({gfl.Model.Atom(:).resName},'ALA'))

输出数组pos包含您要查找的Atoms的索引。

要提取坐标,您可以按如下方式使用这些索引:

X=[gfl.Model.Atom(pos).X]
Y=[gfl.Model.Atom(pos).Y]
Z=[gfl.Model.Atom(pos).Z]

您可以通过将“Atom name”和Residue name定义为参数来使代码更加“通用”。

在下文中,您可以根据MatLab提供的示例文件找到完整的脚本。

% Generate a PDB file (example from MatLab help)
gfl = getpdb('1GFL','TOFILE','1gfl.pdb')
% Read the PDB file
gfl = pdbread('1gfl.pdb')


% Define the Atom Name
atom_name='CA';
% Define the Residue Name
res_name='ALA';
% Search for the couple "Atom name - Residue Name"
pos=find(strcmp({gfl.Model.Atom(:).AtomName},atom_name) & ...
   strcmp({gfl.Model.Atom(:).resName},res_name))

% Extract the coordinates of the Atoms matching the search criteria
X=[gfl.Model.Atom(pos).X]
Y=[gfl.Model.Atom(pos).Y]
Z=[gfl.Model.Atom(pos).Z]

enter image description here

希望这有帮助。