This is a read-only mirror of pymolwiki.org

Selection Macros

From PyMOL Wiki
Revision as of 11:23, 7 September 2010 by Speleo3 (talk | contribs) (adjust indent)
Jump to navigation Jump to search

Selection Macros

General

Macros make it possible to represent a long atom selection phrase such as

PyMOL> select pept and segi lig and chain b and resi 142 and name ca

in a more compact form:

PyMOL> select /pept/lig/b/142/ca

An atom selection macro uses slashes to define fields corresponding to identifiers. The macro is used to select atoms using the boolean "and," that is, the selected atoms must have all the matching identifiers:

/object-name/segi-identifier/chain-identifier/resi-identifier/name-identifier

These identifiers form a hierarchy from the object-name at the top, down to the name-identifier at the bottom. PyMOL has to be able to recognize the macro as one word, so no spaces are allowed within it.

Macros come in two flavors: those that begin with a slash and those that don't. The presence or absence of a slash at the beginning of the macro determines how it is interpreted. If the macro begins with a slash, PyMOL expects to find the fields starting from the top of the hierarchy: the first field to the right of the slash is interpreted as an object-name; the second field as an identifier to segi; the third as an identifier to chain, and so on. It may take any of the following forms:

Macros Beginning With a Slash

  
   /object-name/segi-identifier/chain-identifier/resi-identifier/name-identifier
   /object-name/segi-identifier/chain-identifier/resi-identifier
   /object-name/segi-identifier/chain-identifier
   /object-name/segi-identifier
   /object-name


EXAMPLES
   PyMOL> zoom /pept
   PyMOL> show spheres, /pept/lig/
   PyMOL> show cartoon, /pept/lig/a
   PyMOL> color pink, /pept/lig/a/10
   PyMOL> color yellow, /pept/lig/a/10/ca    

Macros Not Beginning With a Slash

If the macro does not begin with a slash, it is interpreted differently. In this case, PyMOL expects to find the fields ending with the bottom of the hierarchy. Macros that don't start with a slash may take the following forms:

                                             resi-identifier/name-identifier
                            chain-identifier/resi-identifier/name-identifier
            segi-identifier/chain-identifier/resi-identifier/name-identifier
object-name/segi-identifier/chain-identifier/resi-identifier/name-identifier


EXAMPLES
   PyMOL> zoom 10/cb
   PyMOL> show spheres, a/10-12/ca
   PyMOL> show cartoon, lig/b/6+8/c+o
   PyMOL> color pink, pept/enz/c/3/n


Omitting Fields in a Macro

You can also omit fields between slashes. Omitted fields will be interpreted as wildcards, as in the following forms:

   
   resi-identifier/
   resi-identifier/name-identifier
   chain-identifier//
   object-name//chain-identifier                

   
EXAMPLES
   PyMOL> zoom 142/                  # Residue 142 fills the viewer. 
   
   PyMOL> show spheres, 156/ca       # The alpha carbon of residue 156
                                     # is shown as a sphere     
                                     
   PyMOL> show cartoon, a//          # Chain "A" is shown as a cartoon.  
   
   PyMOL> color pink, /pept//b       # Chain "B" in object "pept"
                                     # is colored pink.


Selection macros must contain at least one forward slash in order to distinguish them from other words in the selection language. Being words, they must not contain any spaces. When using macros, it is also important to understand that they are converted into long form before being submitted to the selection engine. This can help in the interpretation of error messages.