This is a read-only mirror of pymolwiki.org

Difference between revisions of "Get object list"

From PyMOL Wiki
Jump to navigation Jump to search
(created)
 
m (1 revision)
(No difference)

Revision as of 02:00, 28 March 2014

cmd.get_object_list is an API only command which returns the list of all molecular objects in selection. It will not return selection names or objects which are not of type molecule.

PyMOL API

list cmd.get_object_list(string selection='(all)')

Important: Always put the selection in parenthesis to force PyMOL to interpret it as an atom selection. Otherwise this might fail on name wildcards, groups, etc.

For proper atom selections this should be identical to:

list cmd.get_names('objects', 0, string selection='(all)')

Examples

PyMOL> fetch 2x19 2xwu 1d7q, async=0
PyMOL> print cmd.get_object_list('solvent')
['2x19', '2xwu']
PyMOL> print cmd.get_object_list('hydro')
['1d7q']
PyMOL> print cmd.get_object_list('2x*')    # FAIL!!!
['2x19']
PyMOL> print cmd.get_object_list('(2x*)')  # correct, with parenthesis
['2x19', '2xwu']

See Also