Package schrodinger :: Package application :: Package desmond :: Package packages :: Module analysis :: Class GeomCalc
[hide private]
[frames] | no frames]

Class GeomCalc

object --+
         |
        GeomCalc


We use this class to batch the geometry calculations and avoid duplications.
For example, you want to calculate the bond distance between atoms 1 and 2,
and also an dihedral angle involving these two atoms. Both calculations
require to calculate the vector between the mininum images of the two atoms,
but we don't want to do the calculation twice. With this class, we avoid
such duplications.

All geometry calculations take into account the peridoic boundary condition.

Basic usage:

  calc = GeomCalc()

  # Loads geometry-calculation requests.
  calc.addVector(...)
  calc.addDistance(...)
  calc.addAngle(...)
  calc.addTorsion(...)

  # Does calculations.
  calc(pbc, frame)

  # Gets results.
  vec = calc.getVector(...)
  dis = calc.getDistance(...)
  ang = calc.getAngle(...)
  dih = calc.getTorsion(...)

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__call__(self, pbc, fr)
Perform all registered geometry calculations.
int
addPosition(self, positer, num_pos)
Add extra position into the position array.
 
addVector(self, from_gid, to_gid)
Add a vector calculation request.
 
addDistance(self, i_gid, j_gid)
Add a distance calculation request.
 
addAngle(self, i_gid, j_gid, k_gid)
Add an angle calculation request.
 
addTorsion(self, i_gid, j_gid, k_gid, l_gid)
Add a torsion calculation request.
 
addCustom(self, cid, key=None, default=None)
Add a custom calculation item.
 
addAnalyzer(self, analyzer)
Add a custom analyzer.
 
getVector(self, from_gid, to_gid)
Get the vector between the atoms: from_gid and to_gid.
 
getDistance(self, i_gid, j_gid)
Get the distance (in Angstroms) between the atoms: i_gid and j_gid.
 
getAngle(self, i_gid, j_gid, k_gid)
Get the angle (in radians) between the two vectors: j==>i and j==>k.
 
getTorsion(self, i_gid, j_gid, k_gid, l_gid)
Get the torsion (in radians) as defined by the four atoms: i_gid, j_gid, k_gid, and l_gid.
 
getCustom(self, cid)
Return all results of the custom calculation type c

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__call__(self, pbc, fr)
(Call operator)

 

Perform all registered geometry calculations.

Parameters:

addPosition(self, positer, num_pos)

 

Add extra position into the position array.

Parameters:
  • positer (Callable, will be called as: positer(pbc, fr), where pbc is a Pbc object, and fr is a traj.Frame object.) - Function (or callable object) to append new positions into the position array of the given frame.
  • num_pos (int, must be a nonnegative number.) - The number of new positions to be added by positer
Returns: int
The gid offset of the first new position that will be generated by this positer.

addVector(self, from_gid, to_gid)

 

Add a vector calculation request.

Parameters:
  • to_gid (int)
  • from_gid (int)

addDistance(self, i_gid, j_gid)

 

Add a distance calculation request.

Parameters:
  • i_gid (int)
  • j_gid (int)

addAngle(self, i_gid, j_gid, k_gid)

 

Add an angle calculation request.

Parameters:
  • i_gid (int)
  • k_gid (int

    The angle is defined by the two vectors: j==>i and j==>k.

    )
  • j_gid (int)

addTorsion(self, i_gid, j_gid, k_gid, l_gid)

 

Add a torsion calculation request.

@type i_gid: C{int}
@type j_gid: C{int}
@type k_gid: C{int}
@type l_gid: C{int}

The torsion is defined by the four position vectors:

  i o           o l
     \         /
      \       /
     j o-----o k

In other words, it's the dihedral angle between the two planes: i-j-k
and j-k-l.

addCustom(self, cid, key=None, default=None)

 

Add a custom calculation item.

Parameters:
  • cid (Any hashable object) - Specify the type of the calculation. The results of this type of calculation can be obtained by calling .getCustom(c).
  • key (Any hashable object) - A particular calculation item of the type c. The result of this item can be obtained by this: .getCustom(c)[key].
  • default - The default result of the calculation item key.

addAnalyzer(self, analyzer)

 

Add a custom analyzer.

Parameters:
  • analyzer (Duck type that must define the following interface:
    1. _precalc(self, calc) where calc is a GeomCalc object. This method should call calc.addCustom to add an calculation item of a custom calculation type.
    2. _postcalc(self, calc, pbc, fr) where calc is a GeomCalc object, pbc is a Pbc object, and fr is a traj.Frame object. This method can get the calculation result by calling calc.getCustom and do further calculations as necessary to get the final analytic results.
    )

getTorsion(self, i_gid, j_gid, k_gid, l_gid)

 

Get the torsion (in radians) as defined by the four atoms: i_gid, j_gid, k_gid, and l_gid. See the docstring of addTorsion for more detail.

getCustom(self, cid)

 

Return all results of the custom calculation type c

Parameters:
  • cid (Any hashable object)