2013-07-22 48 views
1

我目前正在使用python操縱.pdb(protein data bank)文件。我的最終目標是將python腳本轉換回pdb文件,以便我可以在VMD或PyMol中運行模擬。有人請幫忙嗎?如何使用python腳本輸出.pdb文件?

+2

您能詳細說明您遇到的問題是什麼嗎?你只是想知道如何編寫一個'.pdb'文件,還是有一些額外的微妙問題? – Blckknght

+0

我有一種感覺,你有一個pdb文件作爲你的腳本的輸入,然後你做了一些數據操作,然後想要再次用更新後的maniplated信息輸出pdb,對吧?如果是這樣,你有沒有嘗試biopython? http://biopython.org/wiki/Documentation – arturomp

+0

是的,這正是我想要做的。我使用biopython從原始pdb文件中拉出座標。但我對很多這類東西都很陌生,我不確定如何使用它來輸出帶有更新操作信息的pdb。 –

回答

0

example code似乎做你想要什麼:

相關部分:

import sys 
from Bio.PDB import PDBIO 
from Bio.PDB.PDBParser import PDBParser 
PDB_input = sys.argv[1] 
parser = PDBParser() 
structure = parser.get_structure('self', PDB_input) 
# DELETED CODE THAN MANIPULATED PDB OBJECT 
w = PDBIO() 
w.set_structure(structure) 
w.save('corrected_from_CHARMM_to_PDB.pdb') 
0

變化列表中的每個元素這樣的事情在for/while循環在每個新線這是一個粗略的方式,但BioPDB只讀取輸出。我假設你有想要寫入各種陣列的數據。

j[0] = j[0].ljust(6)#atom#6s 
    j[1] = j[1].rjust(5)#aomnum#5d 
    j[2] = j[2].center(4)#atomname$#4s 
    j[3] = j[3].ljust(3)#resname#1s 
    j[4] = j[4].rjust(1) #Astring 
    j[5] = j[5].rjust(4) #resnum 
    j[6] = str('%8.3f' % (float(coords[i][0]))).rjust(8) #x 
    j[7] = str('%8.3f' % (float(coords[i][1]))).rjust(8)#y 
    j[8] = str('%8.3f' % (float(coords[i][2]))).rjust(8) #z\ 
    j[9] =str('%6.2f'%(float(j[9]))).rjust(6)#occ 
    j[10]=str('%6.2f'%(float(j[10]))).ljust(6)#temp 
    j[11]=j[11].rjust(12)#elname  
    f1.write("%s%s %s %s %s%s %s%s%s%s%s%s\n"% j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],j[8],j[9],j[10],j[11])) 

然後檢查是否寫出文件可以在PDBParser被BioPython閱讀別人的建議。

p=PDBParser(PERMISSIVE=1) 
    structure=p.get_structure('test', 'test.pdb')