GetNamesInSel

From PyMOLWiki
Revision as of 09:48, 20 March 2009 by Inchoate (talk | contribs) (New page: = Overview = This script returns the list of object names that exist in any given selection. For example, if you have 100 objects loaded (viz. ligand poses from small molecule docking) an...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

This script returns the list of object names that exist in any given selection. For example, if you have 100 objects loaded (viz. ligand poses from small molecule docking) and select all atoms w/in some cutoff, then you have a selection. What objects are actually in that selection? This script will tell you.

The Code

from pymol import cmd, stored
getNamesInSel(sel):
    stored.tempNames = set()
    cmd.iterate_state(1, sel, "stored.tempNames.add(model)")
    rList = list(stored.tempNames)

    # if you want the list reversed or sorted,
    # uncomment the following lines
    #rList.sort()
    #rList.reverse()

    return rList

See Also