[Biopython-dev] changing PDB file chains

John Berrisford jmb at ebi.ac.uk
Fri Jun 14 09:48:21 UTC 2013


Hi João and David

Thank you for the help.
The part that confused me is how do I change a chain ID for a specific 
water?

eg. I can select a water with
atom = pdbFile[0]['W']['W', 1031, ' ']['O']
or maybe
residue = pdbFile[0]['W']['W', 1031, ' ']
now, how do I update the chain ID for this water?

alternatively I can select a water with
for model in pdbFile:
    for chain in model:
       for residue in chain:
          if residue.id[0] == 'W':
            if residue.id[1] == '1031':
I presume that I can then do...
                chain.id = 'A'
and will this change the chain ID for this specific water or all atoms?

Regards

John

On 14/06/13 10:05, João Rodrigues wrote:
> Hi,
>
> If you simply want to update ids, you can just change them (chain.id 
> <http://chain.id> = newvalue) and then output the structure like David 
> suggested. No need to remove/add atoms. If you wish to play with the 
> structure then you should modify the SMCRA hierarchy indeed.
>
> Cheers,
>
> João
>
>
> 2013/6/13 David Cain <davidjosephcain at gmail.com 
> <mailto:davidjosephcain at gmail.com>>
>
>     Yes, John, it's possible!
>
>     You'll first want to modify the parsed structure. Add your water
>     molecules
>     to the desired chain (removing from the old, of course). To
>     actually do
>     this, you may want to look at the source (
>     http://biopython.org/DIST/docs/api/Bio.PDB-module.html),
>     specifically how
>     the SMRCA hierarchy is constructed.
>
>     Once you've modified your Structure (say it's in a variable
>     `struct`), you
>     should create an instance of PDBIO(), then save your structure
>     like so:
>
>     pdb_writer = PDB.PDBIO()
>     pdb_writer.set_structure(struct)
>     pdb_writer.save("output_path.pdb")
>
>     Do not that PDBIO has some limitations (e.g. it cannot write out
>     PDB header
>     data). It should probably suffice for your needs, though.
>
>     If you're not able to figure it out, feel free to email me back
>     (preferably
>     with your code!) and I can help you out.
>     StackOverflow<http://stackoverflow.com> works
>     particularly well for me, if you're amenable to that.
>
>
>
>     David Cain
>     +1 (339) 222 4452 <tel:%2B1%20%28339%29%20222%204452>
>
>
>     On Thu, Jun 13, 2013 at 3:01 PM, John Berrisford <jmb at ebi.ac.uk
>     <mailto:jmb at ebi.ac.uk>> wrote:
>
>     > Hi
>     >
>     >
>     >
>     > I'm trying to use biopython to update a PDB file.
>     >
>     >
>     >
>     > I'm trying to update the chain ID of a series of waters in a PDB
>     file. I
>     > have the original chain ID, new chain ID and water residue
>     number in an
>     > mmcif file which I parse using a separate parser. Then for each
>     water I
>     > have
>     > in the mmcif file I want to update the chain ID from the cif file.
>     >
>     > I then want to write out the updated water line (to test it
>     works) or write
>     > out the updated PDB file.
>     >
>     >
>     >
>     > Is this possible with biopython?
>     >
>     >
>     >
>     > Regards
>     >
>     >
>     >
>     > John
>     >
>     > _______________________________________________
>     > Biopython-dev mailing list
>     > Biopython-dev at lists.open-bio.org
>     <mailto:Biopython-dev at lists.open-bio.org>
>     > http://lists.open-bio.org/mailman/listinfo/biopython-dev
>     >
>     _______________________________________________
>     Biopython-dev mailing list
>     Biopython-dev at lists.open-bio.org
>     <mailto:Biopython-dev at lists.open-bio.org>
>     http://lists.open-bio.org/mailman/listinfo/biopython-dev
>
>


-- 
John Berrisford
PDBe
EMBL-EBI
Wellcome Trust Genome Campus
Hinxton, Cambridge
CB10 1SD

Tel: 01223 492529
http://www.facebook.com/proteindatabank
http://twitter.com/PDBeurope




More information about the Biopython-dev mailing list