atomSelAction |
index |
modify or analyze an AtomSel
Member classes perform actions on atom objects associated with an
atomSel.AtomSel object. These are invoked using the apply() method
of an AtomSel object. A user-defined AtomSelAction can be defined by
creating a class which derives from the PyAtomSelAction class.
Constituent classes:
SetProperty(name,value)
set named property of all atom.Atoms in a selection
The arguments are the name is a property of an Atom (e.g. pos) and
new value to use. The argument value can be a sequence of items of
the appropriate type, such that different values can be assigned to
each atom. In this case, the array must have length at least as large
as the size of the AtomSel. Also note the order of atoms as documented
in the atomSel.AtomSel documentation.
Example:
sel = AtomSel("name HN")
sel.apply( SetProperty("atomName","H") )
from vec3 import Vec3
sel.apply( SetProperty("pos",Vec3(0,0,0)) )
GetProperty(name)
get the named property of all atoms in a selection as a list-like object.
The arguments is the name is a property of an Atom (e.g. pos). One must
instantiate a GetProperty object, and then call the appropriate accessor
from this list:
stringVals() - for atomName, residueName, segmentName, chemType
floatVals() - for mass, charge
intVals() - for residueNum
vec3Vals() - for pos, vel
*Or*
simply use apply's returned value.
Example:
sel = AtomSel("name CA")
getter = GetProperty("residueNum")
sel.apply( getter )
print( getter.intVals() )
vs.
print( AtomSel("name CA").apply( GetProperty("residueNum") ) )
SetVelAction(velVal)
will set velocities of all atoms in the atom selection to the
value velVal, of type vec3.Vec3.
Translate(transVal)
will translate coordinates of all atoms in the selection to the
value transVal, of type vec3.Vec3.
Rotate(rotMat,centerVec)
will apply the rotation operation q = rotMat * (q-centerVec)
to the positions of all atoms in the selection, where q is the atom
position. If centerVec is omitted, it is taken to be the origin.
rotMat is of type mat3.Mat3, and centerVec is of type vec3.Vec3.
Fit(fitTo,fitBy,altCoords)
will perform an rmsd fitting to the list of atomic coordinates
specified in fitTo using the algorithm of Kabsch, Acta Cryst. A34, 827
(1978). fitBy is an atomSel.AtomSel which specifies which
coordinates are used in the rmsd calculation (all known atoms by
default). If altCoords is specified, use these instead of those in the
selection to calculate the fit (but still perform the fit
transformation on the coordinates of the AtomSel). Once constructed a
Fit object contains the methods rotation() and translation() which
return R and T, the rotation matrix and translation vector which
transform the initial coordinates into the fit coordinates by the
expression:
qFit = R q + T
The actual transformation is applied using an AtomSel's apply()
method. In this form, fitTo must have an entry for every atom in the
simulation.Simulation. Alternately, fitTo can be an AtomSel (with
the same number of atoms as fitBy). Using an AtomSel allows one to fit
different coordinates within a Simulation, or within different
Simulations. An additional method, transDiff() returns the distance
between the centers of mass of the two selections.
RMSD(compare)
compute the rmsd of the atoms of the AtomSel with the contents of
compare. Compare can be a list of atomic coordinates (of length
sel.simulation().numAtoms()) or an atomSel.AtomSel with the correct
number of atoms. Using an AtomSel allows one to compare different
coordinates within a Simulation, or within different Simulations. No
property of the AtomSel is modified. Rather, after calling the
AtomSel's apply() method, one can access two methods of the RSMD
object:
rmsd()
the overall rmsd. This is the value returned by the AtomSel's apply
method.
perResidue()
returns a ordered list of (string,value) tuples which specify
residue identity (via segmetName residueNum) and per-residue RMSD
value.
byResidue()
returns a dictionary, which contains per-residue RMSD values
indexed by residue number.
examples:
#translate all atoms 3 angstroms in the x direction
#
from atomSelAction import Translate
AtomSel("all").apply( Translate(Vec3(3,0,0)) )
#move all atoms in residues 1-30 such that the CA atoms of those
#residues best-fit the corresponding CA atoms in residues 61-90.
#
AtomSel("resid 1:30").apply( Fit("name CA and resid 61:90",
"name CA and resid 1:30") )
#compute the backbone rmsd with the coordinates stored in otherCoords
#the
#
comparer=RMSD(otherCoords)
rmsd = AtomSel("name C or name CA or name N").apply(comparer)
for resid,val in comparer.perResidue():
print resid, val
standalone function:
minDistance(sel1,sel2) - computes the minimum distance between atoms
in the two given atomSel.AtomSels.
# 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 | ||
|
Data | ||
__CDSVector_hh__ = 1 atomName = 2 atomNameVec = 12 charge = 9 chargeVec = 19 chemType = 3 chemTypeVec = 13 fric = 8 fricVec = 18 mass = 7 massVec = 17 pos = 5 posVec = 15 residueName = 1 residueNameVec = 11 residueNum = 4 residueNumVec = 14 segmentName = 0 segmentNameVec = 10 vel = 6 velVec = 16 |