如何使用python脚本输出.pdb文件?
我目前正在处理python中的.pdb()文件。我的最终目标是将python脚本转换回pdb文件,以便我可以在VMD或PyMol中运行模拟。有人能帮忙吗?这似乎是您想要的: 相关部分是:如何使用python脚本输出.pdb文件?,python,bioinformatics,protein-database,pymol,Python,Bioinformatics,Protein Database,Pymol,我目前正在处理python中的.pdb()文件。我的最终目标是将python脚本转换回pdb文件,以便我可以在VMD或PyMol中运行模拟。有人能帮忙吗?这似乎是您想要的: 相关部分是: import sys from Bio.PDB import PDBIO from Bio.PDB.PDBParser import PDBParser PDB_input = sys.argv[1] parser = PDBParser() structure = parser.get_structure('
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')
将列表中的每个元素在每一行上的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')
你能详细说明你的问题是什么吗?你只是想知道如何编写一个
.pdb
文件,或者这个问题还有其他微妙之处吗?我感觉你有一个pdb文件作为脚本的输入,然后你对数据进行一些操作,然后想再次输出pdb和更新的maniuplated信息,对吗?如果是,你试过biopython吗?是的,这正是我想要做的。我使用biopython从原始pdb文件中提取坐标。但是我对很多东西都是新手,我不知道如何使用它来输出pdb和更新的操作信息。如果你提供一个你写的代码示例,帮助我们了解你的困境,这会有所帮助。这也可能有帮助: