[Biopython] chanding res id

Peter biopython at maubp.freeserve.co.uk
Wed Apr 29 09:26:26 UTC 2009


On Wed, Apr 29, 2009 at 10:15 AM, Bala subramanian
<bala.biophysics at gmail.com> wrote:
> Friends,
> Following is a script that i wrote to change the resid. This works with
> single pdb file but if i use a NMR with multiple models i get an error
> message. I hope there shd be a loop or some fancy way to iterate over all
> the models in the NMR structure. Kindly help me in doing the same.
> #!/usr/bin/env python
> from Bio.PDB import PDBParser
> from Bio.PDB import PDBIO
> from sys import argv
> outfile=raw_input('enter outfile name: ')
> par=PDBParser()
> s=par.get_structure('x',argv[1])
> for index, residue in enumerate(s.get_residues()):

I would add a loop here, because you want to reset the index for each
model - something like this (untested):

for model in s :
   for index, residue in enumerate(model.get_residues()):

>     residue.id=(" ", index, " ")

Should you be using index+1 here?  I don't recall if PDB files allow
an index of zero or not.

> out=PDBIO()
> out.set_structure(s)
> out.save(outfile)
>
> Bala

Peter




More information about the Biopython mailing list