2015-03-18 230 views
1

我想用Python中的Matplotlib绘图,因此从PDB文件(蛋白质数据库)读取一些数据。我想从文件中提取每一列,并将这些列存储在不同的向量中。 PDB文件由包含文本和浮动的列组成。我对Matplotlib很陌生,我尝试了几种方法来提取这些列,但似乎没有任何工作。提取这些列的最佳方法是什么?我将在稍后的阶段加载大量数据,所以如果方法效率不高,这很好。从蛋白质数据库(PDB)文本文件中提取列

的PDB-文件看起来是这样的:

ATOM  1 CA MET A 1  38.012 8.932 -1.253 
ATOM  2 CA GLU A 2  39.809 5.652 -1.702 
ATOM  3 CA ALA A 3  43.007 5.013 0.368 
ATOM  4 CA ALA A 4  41.646 7.577 2.820 
ATOM  5 CA HIS A 5  42.611 4.898 5.481 
ATOM  6 CA SER A 6  46.191 5.923 5.090 
ATOM  7 CA LYS A 7  45.664 9.815 5.134 
ATOM  8 CA SER A 8  45.898 12.022 8.181 
ATOM  9 CA THR A 9  42.528 13.075 9.570 
ATOM  10 CA GLU A 10  43.330 16.633 8.378 
ATOM  11 CA GLU A 11  44.171 15.729 4.757 
ATOM  12 CA CYS A 12  40.589 14.150 4.745 
ATOM  13 CA LEU A 13  38.984 17.314 6.105 
ATOM  14 CA ALA A 14  40.633 19.053 3.220 
ATOM  15 CA TYR A 15  39.740 16.682 0.505 
ATOM  16 CA PHE A 16  36.138 17.421 1.566 
ATOM  17 CA GLY A 17  36.536 20.854 2.826 
ATOM  18 CA VAL A 18  34.184 20.012 5.553 
ATOM  19 CA SER A 19  34.483 20.966 9.177 
+0

看起来你会使用数字数据,在这种情况下['numpy'](http://www.numpy.org/)是事实上使用的模块。那或['pandas'](http://pandas.pydata.org/),它建立在'numpy'之上。看看['np.genfromtxt'](http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html),它可以吃早餐的分隔文件。另外,如果你提到“没有任何东西可以工作”,那么在StackOverflow上显示你已经尝试过的东西以及你得到的错误是个不错的主意...... – 2015-03-18 22:01:24

+1

有很多已经处理PDB的Python包。查看[BioPython](http://biopython.org/wiki/Main_Page),[OpenMM](https://simtk.org/home/openmm)或[OpenBabel](http://openbabel.org/wiki/蟒蛇)。 或者,如果您确定您的PDB将采用正确的格式,那么您可以使用[规范](http://www.rcsb.org/pdb/static.do?p=file_formats/pdb /index.html)并挑出每行的相关位。 – 2015-03-18 23:00:05

+0

我应该补充说,数据库中的PDB文件也会变得复杂(不同的链ID,B因子,多个可能的原子位置),上面列出的软件包似乎具有'numpy'支持,这是标准的@OliverW。提示。 – 2015-03-18 23:07:28

回答

0

去关@ Kyle_S-C的建议,这里有一个方法使用Biopython做。

首先阅读您的文件转换成Biopython Structure对象:

import Bio.PDB 
path = '/path/to/PDB/file' # your file path here 
p = Bio.PDB.PDBParser() 
structure = p.get_structure('myStructureName', path) 

然后,例如,你可以得到公正的凌动IDS这样的列表:

ids = [a.get_id() for a in structure.get_atoms()] 

Biopython Structural Bioinformatics FAQ为更多,包括以下用于访问Atom的PDB列的方法:

如何从Atom对象提取信息?

使用以下方法:

# a.get_name()   # atom name (spaces stripped, e.g. 'CA') 
# a.get_id()    # id (equals atom name) 
# a.get_coord()   # atomic coordinates 
# a.get_vector()   # atomic coordinates as Vector object 
# a.get_bfactor()  # isotropic B factor 
# a.get_occupancy()  # occupancy 
# a.get_altloc()   # alternative location specifier 
# a.get_sigatm()   # std. dev. of atomic parameters 
# a.get_siguij()   # std. dev. of anisotropic B factor 
# a.get_anisou()   # anisotropic B factor 
# a.get_fullname()  # atom name (with spaces, e.g. '.CA.') 
1

蛋白质数据库(PDB)的文件格式是描述在蛋白质数据银行持有的分子的三维结构的文本文件格式。 pdb格式相应地提供了蛋白质和核酸结构的描述和注释,包括原子坐标,观察到的侧链旋转异构体,二级结构分配以及原子连通性。我在谷歌上找到它。

至于提取列,你也可以在google或wiki上找到答案。