atomSel |
index |
select a subset of atoms
An atom selection consists of selection string and list of
corresponding atoms. The object emulates a Python sequence, so that
the selected atom.Atoms, or a subset thereof, can be accessed
through the Python [] operator. The selection language is defined in
the atomSelLang module. Note that the outer parentheses are not
necessary in AtomSel contruction.
Constructor:
AtomSel(string, simulation, ordered=False)
string is a selection string in the XPLOR selection language.
simulation is an optional simulation.Simulation specification;
it defaults to the current Simulation. Normally AtomSels are use PSF
order, i.e. the atoms are indexed in order of their index values. If
the optional argument ordered is set to True, then the atoms will instead
reflect the order specified by ``or'' statements in the selection
string. See the atomSelLang module documentation to read a description
of how order is preserved with overlapping selections. Do note that
ordered selections are tricky as the order of keywords separated by
``and'' become significant.
Alternatively the string argument can be replaced with a sequence of
atom indices to manually generate an atom selection. In this case
the ordered argument cannot be specified.
If there is an error in the selection string, an exception is raised.
methods:
string() return the selection string associated with this AtomSel.
simulation() return the simulation associated with the selection
indices() return list of atom indices associated with the selection
setIndices(list)
manually set the list of atom indices.
apply(apply_instance):
invoke apply_instance's run() function on
each atom in the selection. apply_instance is either
an instance of a class defined in the atomSelAction
module, or a user-defined class which derives from the
atomSelAction.PyAtomSelAction class. Please see
the documentation for the atomSelAction module for
more information. This method returns the result of
calling the argument's returnMethodName() member, if
not an empty string.
removeBySelIndex(index)
remove the index-th atom from this instance, where index
is 0 through one less than the number of atoms in this
instance.
reevaluate() some selections depend on mutable properties
like coordinates. This member reevaluates such a
selection.
containsIndex(index)
returns true if the selection includes the atom with the
specified index.
containsIndex(list)
returns true if the selection includes any atom with an
index specified in list.
containsAtom(atom)
return True if the selection includes the specified atom.
allValid() return False if any atoms are invalid. Otherwise, return
True.
deleteAtoms(doSync=True)
Delete all atom in this selection from the underlaying
simulation.Simulation, i.e. call
simulation.deleteAtoms(self.indices(), !doSync)
ordered() whether or not the atoms use OR ordered. If this value is
changed, reevaluate() must be called to update the
object.
Functions:
intersect(AtomSel1, AtomSel2)
Evaluate whether the two AtomSels select one or more of the same atoms.
equals(atomSel1, atomSel2)
returns True if the two arguments contain the same atoms, regardless of
order. Python's __eq__ ( a == b ) returns equals(a,b)
monomericallyEqual(AtomSel1, AtomSel2)
Evaluate whether the two AtomSels select atoms with the same resid,
resname, and atom names, ignoring any difference in segid.
minResidDiff(AtomSel1, AtomSel2)
Return minimum number of residues between atoms in the two AtomSels.
intersection(AtomSel1, ..., createString=True)
Return an AtomSel whose indices() consists of the intersection of
the of the selection arguments. By default, the returned AtomSel can
be reevaluated because a selection string is generated from the input
AtomSels. The computational expense of this can be removed by specifying
createString=False, but then the returned AtomSel cannot be
reevaluated.
difference(AtomSel1, AtomSel2)
Return an AtomSel with indices() of AtomSel1 that are not in AtomSel2.
union(AtomSel1, ...)
Return an AtomSel whose indices() consists of the union of
all the arguments, which should be AtomSel objects or strings. An
arbitrary number of arguments can be specified. The returned AtomSel cannot be
reevaluated.
notSelection(sel)
Return an AtomSel whose indices() consists of all those argument sel's
Simulation but, not in its indices().
AtomSel_fromPtr(string)
Return an AtomSel object from a raw SWIG pointer string. This object
is not managed by Python (i.e. its thisown==False).
Example
Print out positions of alpha carbons in residues 40-43, inclusive.
sel = AtomSel("name CA and resid 40:43")
for atom in sel:
print sel.pos()
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
Classes | ||||||||||
|
Functions | ||
|