[Biopython-dev] changing PDB file chains

John Berrisford jmb at ebi.ac.uk
Sun Jun 16 20:33:26 UTC 2013


Thanks for the advice

 

Can you help in how to set a chain using the add method?

 

Also the PDBIO writer appears to remove aniso records. Is there anyway to stop it doing this?

 

Currently my code is:

pdbFile = PDBParser().get_structure(pdbid, pdbPath)

waterChain = pdbFile[0]['W']

newChain = pdbFile[0]['A']

waterAtom = pdbFile[0]['W']['W', 1031, ' ']['O']

waterResidue = pdbFile[0]['W']['W', 1031, ' ']

print waterChain.id

print waterResidue.get_parent()

waterResidue.detach_parent()    #this bit seems to work

print waterResidues.get_parent()

waterResidue.add(pdbid[0]["A"])  #i’m not sure exactly how to get a chainID. 

print waterResidue.get_parent()

print waterResidue.id

 

which returns:

W

<Chain id=W>  #original parent (chain) of the residue. 

None    #detach parent seems to work fine

Traceback (most recent call last):

  File “water_orig.py", line 53, in <module>

    waterResidue.add(pdbid[0]["A"])

TypeError: string indices must be integers, not str

 

 

My writer commands are:

pdb_writer = PDBIO()

pdb_writer.set_structure(pdbFile)

pdb_writer.save("output_path.pdb")

 

 

Regards

 

John

 

From: João Rodrigues [mailto:anaryin at gmail.com] 
Sent: 14 June 2013 10:50
To: John Berrisford
Cc: David Cain; biopython-dev at lists.open-bio.org
Subject: Re: [Biopython-dev] changing PDB file chains

 

Hi John,

 

Actually, David is absolutely right.. I didn't really think it through. You need to move the water atoms to the chain where you want them to be. So, if they are in chain A and should be in chain B, you need to detach them from chain A (detach_child method on the residue, easier) and re-attach it to chain B (add method).





More information about the Biopython-dev mailing list