[Biopython] PDBParser

João Rodrigues anaryin at gmail.com
Tue May 8 08:16:44 UTC 2012


Hello George,

You want to write only a part of the PDB file? What do you mean by 'all the
info'? If it is header information as well, then this is not possible, but
coordinates it is. You can do it in two ways:

1. Delete all residues/chains/models that are not part of your region of
interest and then write the structure with PDBIO.

2. Use the 'Select' class from PDBIO.py and trim the region of interest.
For example, for residues 1-10 you could do something like this:

from Bio.PDB import PDBIO
from Bio.PDB import Select

class ResidueFilter(Select):
    def accept_residue(self, residue):
        if residue.id[1] in range(1,11):
            return 1

P = PDBParser()
s = P.get_structure('dummy', 'foo.pdb')

io = PDBIO()

io.set_structure(s)
io.save('foo_1-10.pdb', ResidueFilter())


Check the FAQ for a more detailed explanation:

http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf

Cheers,

João [...] Rodrigues
http://nmr.chem.uu.nl/~joao



2012/5/8 George Devaniranjan <devaniranjan at gmail.com>

> Hi,
>
> I have a question about using  PDBParser
>
>
> from Bio.PDB.PDBParser import PDBParser
>
> parser=PDBParser()
>
> structure=parser.get_structure("test", "1fat.pdb")
> model=structure[0]
> chain=model["A"]
> residue=chain[1]
>
> I want to use it to extract and WRITE to a file the coordinates of residues
> 10 to 20 only.
> (or whatever residue range I specify)
>
> Using the PDB Parser file I can extract residue id  in the range but how to
> I back trace and write the file in the exact format that is found in the
> PDB so that I can view it in a program like VMD/Pymol?
> (that is I want to write the coordinates and all information as found in
> the PDB but only for selected residues that I pass into it )
> I know I can do it using VMD but I want to do it for thousands of PDB and
> would like to write a database of such extracted fragments.
>
> The other alternative is of course to go line by line in each file and
> write the lines that match the residue range specified but I was wondering
> if there is a way of doing the same thing using the PDBParser?
>
> Thank you,
> George
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>




More information about the Biopython mailing list