Discussion:
[PyMOL] list residues in a selection
Sebastien Gerega
2005-07-06 04:59:33 UTC
Permalink
Is there a way to list the residues that are in a selection? For example
if I use the command "select near, sel01 around 6" how can I obtain a
list of the residues in the "near" selection?
thanks,
Sebastien
l***@ultr.vub.ac.be
2005-07-06 05:28:32 UTC
Permalink
Post by Sebastien Gerega
Is there a way to list the residues that are in a selection? For example
if I use the command "select near, sel01 around 6" how can I obtain a
list of the residues in the "near" selection?
Using

cmd.get_pdbstr("near")

(after "import cmd" if required) you get a list of lines in PDB ATOM format
for all the atoms in the selection. In principle, you can extract any
information you want from these lines.

Hope this helps,
--
Lieven Buts
Ultrastructure Laboratory
Vrije Universiteit Brussel
Michael George Lerner
2005-07-06 11:29:28 UTC
Permalink
I asked a similar question a while ago, and Kristan Rother archived the
answer at <http://www.rubor.de/bioinf/tips_python.html#insel>. Here it
is:

Using PyMOL commands:

list=[]
iterate (name ca),list.append((resi,resn))
print list

[('ASP', '1'), ('CYS', '2'), ('ALA', '3'), ('TRP', '4'), ('HIS', '5'), ('LEU',
'6'), ('GLY', '7'), ('GLU', '8'), ('LEU', '9'), ('VAL', '10'), ('TRP', '11'),
('CYS', '12'), ('THR', '13')]

or using a Python script (in PyMOL):

from pymol import cmd,stored
stored.list=[]
cmd.iterate("(name ca)","stored.list.append((resi,resn))")
print stored.list

[('1', 'ASP'), ('2', 'CYS'), ('3', 'ALA'), ('4', 'TRP'), ('5', 'HIS'), ('6', '
LEU'), ('7', 'GLY'), ('8', 'GLU'), ('9', 'LEU'), ('10', 'VAL'), ('11', 'TRP'),
('12', 'CYS'), ('13', 'THR')]


--
www.umich.edu/~mlerner | _ |Michael Lerner
This isn't a democracy;| ASCII ribbon campaign ( ) | Michigan
it's a cheer-ocracy. | - against HTML email X | Biophysics
Is there a way to list the residues that are in a selection? For example if I
use the command "select near, sel01 around 6" how can I obtain a list of the
residues in the "near" selection?
thanks,
Sebastien
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
PyMOL-users mailing list
https://lists.sourceforge.net/lists/listinfo/pymol-users
Robert Campbell
2005-07-07 18:44:06 UTC
Permalink
Hi,

* Michael George Lerner <***@umich.edu> [2005-07-06 09:28] wrote:
<with my editing to put the original e-mail in the correct location>
Post by Michael George Lerner
Post by Sebastien Gerega
Is there a way to list the residues that are in a selection? For example
if I use the command "select near, sel01 around 6" how can I obtain a list
of the residues in the "near" selection?
I asked a similar question a while ago, and Kristan Rother archived the
answer at <http://www.rubor.de/bioinf/tips_python.html#insel>. Here it
list=[]
iterate (name ca),list.append((resi,resn))
print list
[('ASP', '1'), ('CYS', '2'), ('ALA', '3'), ('TRP', '4'), ('HIS', '5'), ('LEU',
'6'), ('GLY', '7'), ('GLU', '8'), ('LEU', '9'), ('VAL', '10'), ('TRP', '11'),
('CYS', '12'), ('THR', '13')]
from pymol import cmd,stored
stored.list=[]
cmd.iterate("(name ca)","stored.list.append((resi,resn))")
print stored.list
[('1', 'ASP'), ('2', 'CYS'), ('3', 'ALA'), ('4', 'TRP'), ('5', 'HIS'), ('6', '
LEU'), ('7', 'GLY'), ('8', 'GLU'), ('9', 'LEU'), ('10', 'VAL'), ('11', 'TRP'),
('12', 'CYS'), ('13', 'THR')]
Or as a variation on the first method, you don't need to make the list,
just do (using the original questions selection "near":


iterate near, print resi,resn,name
(to get all atoms)

or

iterate near & n. ca, print resi,resn
(for just the alpha-carbons, though if the "near" selection wasn't
created with the "byres" option, then some residues in the
selection may not have a CA included)

Cheers,
Rob
--
Robert L. Campbell, Ph.D. <***@post.queensu.ca>
Senior Research Associate phone: 613-533-6821
Dept. of Biochemistry, Queen's University, fax: 613-533-2497
Kingston, ON K7L 3N6 Canada http://adelie.biochem.queensu.ca/~rlc
PGP Fingerprint: 9B49 3D3F A489 05DC B35C 8E33 F238 A8F5 F635 C0E2
Continue reading on narkive:
Loading...