Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I think a simple and useful extension to cmd.get_names() would be a pattern or grep string to filter the names. We could then make a call like,
to only get the objects names "ligand" back.
nb. This would also be useful in a for-loop situation,
for ligOnly in cmd.get_names("objects", grep="lig"):
this already works like this:
This is already available with the selection argument, but special attention is required for object vs. atom selections. This will not properly evaluate object patterns, only atom selections. This can be achieved by parenthesis or with the "model" operator.
This will fail (only returns first matching name):
cmd.get_names('all', selection='model lig*')
The latter might include object names which do not match "lig*" themselves, but have atoms in a named selection which matches "lig*".
For a strict name "grepping", I suggest a pythonic solution:
[name for name in cmd.get_names('all') if 'lig' in name]