Import system modules used in this example.
Import Chimera modules used in this example.
Define a regular expression for matching the names of protein
backbone atoms (we do not include the carbonyl oxygens because
they tend to clutter up the graphics display without adding
much information).
Do the actual work of setting the display status of atoms and
bonds. The following
The following
Set the display status of atom
By default, bonds are displayed if and only if both endpoint
atoms are displayed, so therefore we don't have to explicitly
set bond display modes; they will automatically "work right".
import re
import chimera
MAINCHAIN = re.compile("^(N|CA|C)$", re.I)
for
statement iterates over molecules.
The function call
chimera.openModels.list(modelTypes=[chimera.Molecule])
returns a list of all open molecules; non-molecular models such
as surfaces and graphics objects will not appear in the list.
The loop variable m
refers to each model successively.
for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
for
statement iterates over atoms. The
attribute reference m.atoms
returns a list of all atoms
in model m
, in no particular order. The loop variable
a
refers to each atom successively.
for a in m.atoms:
a
. First, we match
the atom name, a.name
, against the backbone atom
name regular expression, MAINCHAIN
. The function
call MAINCHAIN.match(a.name)
returns an re.Match
object if the atom name matches the regular expression
or None
otherwise. The display status of the atom
is set to true if there is a match (return value is not
None
) and false otherwise.
a.display = MAINCHAIN.match(a.name) != None