Package schrodinger :: Package structutils :: Module ringspear :: Class SpearRing
[hide private]
[frames] | no frames]

Class SpearRing

object --+
         |
        SpearRing

Computes and holds information about a ring, and finds bonds that spear that ring.

Note: Objects of this class do not maintain pointers to either the Structure object or the _Ring object that were used to create them.

Instance Methods [hide private]
 
__init__(self, struct, ring, pbc=None)
Create a SpearRing object
numpy.array, numpy.array
getRingCentroid(self, struct)
Get the ring centroid.
numpy.array, numpy.array, float
getNormalsAndRadius(self, struct)
Find the average normal vector to the ring plane and compute the radius of the ring.
numpy.array
getRotationMatrix(self)
Get a rotation matrix that rotates the ring to be aligned with the positive Z-axis when the ring centroid is at the origin.
list
findSpears(self, orig_struct, atoms=None, is_ring_struct=True, distorted=False, first_only=True, cell=None, dist=4.0)
Check for ring spears - bonds that pass through the face of the ring.
schrodinger.structure.Structure or None
_roughCutAtoms(self, orig_struct, cell=None, dist=4.0, ignore=None)
A quick method for eliminating atoms that are so far from this ring that they cannot possible spear it.
None
centerAndRotate(self, struct)
Apply the same translation and rotation to the structure as would be required to place the ring centroid at the origin with the ring in the XY plane.
None
quickWeedAtoms(self, struct)
Quickly weed out any atoms that are too far away from the ring centroid to spear the ring.
list
_findSpearingPairs(self, struct, first_only)
Find atoms that spear this ring.
(float, float) or None
getBondXYIntersection(self, atom1, atom2)
Find where the bond from atom1 to atom2 intersects the XY (z=0) plane.

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

Static Methods [hide private]
 
markAtomsBeforeSpearCheck(struct)
Add an atom property to all atoms with the atom's current index.
Class Variables [hide private]
  ORIG_ATOM_INDEX = 'i_matsci_orig_atom_index'
Instance Variables [hide private]
  ring_indexes
The atom indexes of the ring atoms
  pbc
The periodic boundary condition to use if any
  origin_normal
The normal translated to the origin
  normal
The normal based at the ring centroid
  radius
The largest centroid-ring atom distance
  rotation_matrix
The rotation matrix that rotates the ring into the XY plane when the centroid is at the origin
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, struct, ring, pbc=None)
(Constructor)

 

Create a SpearRing object

Parameters:
Overrides: object.__init__

getRingCentroid(self, struct)

 

Get the ring centroid. Accounts for the fact that the ring might be broken across the periodic boundary condition

Parameters:
Returns: numpy.array, numpy.array
A 3-float numpy array giving the [X, Y, Z] coordinates of the ring centroid, and a numpy array of the XYZ coordinates of each ring atom taking into account the PBC so that the coordinates are not split by the PBC. The coordinate list is in the same order as the ring_indexes property.

getNormalsAndRadius(self, struct)

 

Find the average normal vector to the ring plane and compute the radius of the ring.

The average normal vector is the average of the normal vectors computed for each pair of adjacent ring atoms and the ring centroid.

The radius is defined as the largest centroid-ring atom distance

Parameters:
Returns: numpy.array, numpy.array, float
The average normal vector to the plane of the ring translated so its base is at the origin, the average normal vector to the plane of the ring translated so its base is at the ring centroid, the radius of the ring.

getRotationMatrix(self)

 

Get a rotation matrix that rotates the ring to be aligned with the positive Z-axis when the ring centroid is at the origin.

Returns: numpy.array
A 4x4 numpy array containing the rotation matrix that aligns the ring normal vector to the positive Z-axis

findSpears(self, orig_struct, atoms=None, is_ring_struct=True, distorted=False, first_only=True, cell=None, dist=4.0)

 

Check for ring spears - bonds that pass through the face of the ring. It does not matter if the spearing bond is a single or multiple bond, or if it is part of another ring.

Parameters:
  • orig_struct (schrodinger.structure.Structure) - The structure to check if any bonds spear this ring in ring_struct.
  • atoms (list) - List of atom indexes to check to see if they spear this ring.
  • is_ring_struct (bool) - Whether orig_struct contains this ring. If True, the atoms with the same index as the indexes of this ring will not be considered for spearing calculations.
  • distorted (bool) - If False (default), the structure will be assumed to have reasonable bond lengths, and optimizations will be used to dramatically speed up spear-finding in large structures by eliminating atoms that cannot possibly spear this ring. If True, atom distances will not be used to optimize spear-finding - significantly increasing the time required.
  • first_only (bool) - Whether to return after finding the first ring spear, or whether all ring spears should be found.
  • cell (schrodinger.infra.structure.DistanceCell) - schrodinger.infra.structure.DistanceCell object created using pbc. cell is used for rough-cutting atoms too far away from the ring. If not provided, a cell will be created based on the value (or lack of value) of pbc. Pre-creating the cell for a structure and passing it to this method for all rings saves significant time. See also the pbc parameter.
  • dist (float) - The distance from the ring centroid at which atoms will be rough cut and eliminated from spearing consideration. This is only used if cell is not provided.
Returns: list
A list of found ring-spears, each item is a Spear object. An empty list is returned if no spears are found, and if first_only is True the list will be at most 1 item long.

_roughCutAtoms(self, orig_struct, cell=None, dist=4.0, ignore=None)

 

A quick method for eliminating atoms that are so far from this ring that they cannot possible spear it.

Parameters:
  • orig_struct (schrodinger.structure.Structure) - The structure to copy and cut atoms from.
  • cell (schrodinger.infra.structure.DistanceCell) - An infrastructure distance cell that has been created for use in rough-cutting atoms too far away from the ring. If not provided, a cell will be created. Pre-creating the cell for a structure and using it for all rings saves significant time. If the cell needs to be created, it will be created with the PBC currently stored in the pbc property.
  • dist (float) - The distance from the ring centroid at which atoms will be rough cut and eliminated from spearing consideration. This is only used if cell is not provided.
  • ignore (set) - A set of atom indexes to ignore even if they fall within the rough cut distance
Returns: schrodinger.structure.Structure or None
A copy of the input structure with all atoms eliminated that are beyond the rough cut distance or are in the ignore list.

centerAndRotate(self, struct)

 

Apply the same translation and rotation to the structure as would be required to place the ring centroid at the origin with the ring in the XY plane.

Parameters:
Returns: None
Returns nothing - the input structure is modified directly

quickWeedAtoms(self, struct)

 

Quickly weed out any atoms that are too far away from the ring centroid to spear the ring.

This method differs from the rough cut method, which uses a larger spherical cutoff based on the centroid. This uses a cubic cutoff, which allows the dimensions to be smaller since the sphere has to large enough to maintain sufficient distance near the edges of the ring.

This method also uses smaller distances for smaller atoms

Parameters:
Returns: None
Nothing is returned, the input structure is modified directly

markAtomsBeforeSpearCheck(struct)
Static Method

 

Add an atom property to all atoms with the atom's current index. This allows the original index to be retrieved even after atom indexes have been modified via atom extraction or deletion.

Note: This is a static method

_findSpearingPairs(self, struct, first_only)

 

Find atoms that spear this ring.

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to search for atoms that spear
  • first_only (bool) - Whether to find only the first set of spearing atoms or all sets of spearing atoms
Returns: list
Each item of the list is a Spear object for a set of atoms that spear this ring

getBondXYIntersection(self, atom1, atom2)

 

Find where the bond from atom1 to atom2 intersects the XY (z=0) plane.

The equation for a 3d line that passes through points p0=(x0, y0, z0) and p1=(x1, y1, z1) can be written:

   x-x0   y-y0   z-z0
   ---- = ---- = ----
    a       b     c

where (a, b, c) is the vector from p0 - p1.

if z = 0, then x = x0 - a(z0/c) and y = y0 - b(z0/c)

Parameters:
Returns: (float, float) or None
The (x,y) location where the bond intersects the ring plane, or None if there is no intersection (the bond is parallel or nearly parallel to the ring plane).