I'm currently in the process of manipulating a .pdb (protein data bank) file in python. My end goal is to turn the python script back into a pdb file so that I can run simulations in either VMD or PyMol.Can someone please help?
Asked
Active
Viewed 4,869 times
3
-
2Can you elaborate on what the issue you're having is? Are you just wondering how to write a `.pdb` file, or is there some additional subtlety to the issue? – Blckknght Jul 22 '13 at 19:47
-
I have the feeling that you have a pdb file as input to your script, then you do some manipulation of the data, and then want to output the pdb again with the updated maniuplated info, right? If so, have you tried biopython? http://biopython.org/wiki/Documentation – arturomp Jul 22 '13 at 19:50
-
Yes, that's exactly what I am trying to do. I used biopython to pull coordinates from the original pdb file. But I'm really new to a lot of this stuff and I'm not sure how to used it to output the pdb with the updated manipulated info. – Alicia Burns Jul 22 '13 at 21:01
-
2it would help if you put up a sample of the code you've written to help us see where you're stuck. this might help, too: http://biopython.org/wiki/The_Biopython_Structural_Bioinformatics_FAQ#Can_I_write_PDB_files.3F – arturomp Jul 22 '13 at 22:31
2 Answers
2
Change each element in list to something like this inside a for/while loop over each new line This is a rough way but BioPDB reads the output in just fine. I assume you have the data that you want to write out in various arrays.
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]))
then check if file written out can be read with PDBParser in BioPython as suggested by others.
p=PDBParser(PERMISSIVE=1)
structure=p.get_structure('test', 'test.pdb')

sridharn
- 111
- 7
0
This example code appears to do what you want:
Relevant part is:
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')

Vince
- 3,325
- 2
- 23
- 41