[Biopython] Getting a list of residue numbers

João Rodrigues j.p.g.l.m.rodrigues at gmail.com
Sun Apr 16 00:00:34 UTC 2017


Hi there,

Try residue.id[1]. The residue number is the second item in the id tuple,
first being the HETATM/Water flag, and third the altloc.

In short: resids = [r.id[1] for r in structure.get_residues()]

2017-04-15 16:27 GMT-07:00 Ahmad Abdelzaher <underoath006 at gmail.com>:

> Hi,
>
> I know I can get residue names like this:
>
> name = '1gdw.pdb'
> structure=p.get_structure(name, name)
> residue_name = []
> for model in structure:
>     for chain in model:
>         for i in *residue_number*:
>                 residue_name.append(chain[i].resname)
>
> However, I don't know of a way to get a list of *residue_number,* so I
> use Pymol to do it!
>
> import __main__
> __main__.pymol_argv = ['pymol','-qc']
> import pymol
> from pymol import cmd, stored
> pymol.finish_launching()
> cmd.delete('all')
> cmd.load(name)
> stored.residues = []
> cmd.iterate('name ca', 'stored.residues.append(resi)')
> residue_number = [ int(x) for x in stored.residues ]
>
> What is the biopython way of getting the residue numbers?
>
>
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20170415/1043bb10/attachment.html>


More information about the Biopython mailing list