我目前正在使用 python 操作 .pdb ( protein data bank ) 文件。我的最终目标是将 python 脚本转回 pdb 文件,以便我可以在 VMD 或 PyMol 中运行模拟。有人可以帮忙吗?
请您参考如下方法:
在每个新行的 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]))
然后检查写出的文件是否可以按照其他人的建议在 BioPython 中使用 PDBParser 读取。
p=PDBParser(PERMISSIVE=1)
structure=p.get_structure('test', 'test.pdb')
