2015-03-18 225 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上找到答案。