Package schrodinger :: Package structutils :: Module transform
[hide private]
[frames] | no frames]

Module transform


A module for manipulating atom coordinates with matrix operations.

Provides array methods to translate and rotate atoms in a
structure.Structure.  The coin of the realm is a four by four numpy array.
The first 3x3 is a rotation matrix, the last 3x1 is translation matrix,
and the 4th row is a spectator row.

All angles are in radians.

[[ 1.  0.  0.  0.]  
 [ 0.  1.  0.  0.]  
 [ 0.  0.  1.  0.] 
 [ 0.  0.  0.  1.]] # spectator row

The elements in the last row are spectators and don't contribute to
atomic coordinate changes.

Copyright Schrodinger, LLC. All rights reserved.

Functions [hide private]
 
get_vector_magnitude(a)
Returns magnitute of a specified vector (numpy array)
 
get_normalized_vector(vector)
Returns normalized version of the specified vector (numpy array)
 
get_angle_between_vectors(a, b)
Return angle between 2 vectors
 
translate_structure(st, x=0.0, y=0.0, z=0.0, atom_index_list=None)
Translates the atom coordinates along Cartesian x, y, and z axes.
 
rotate_structure(st, x_angle=0, y_angle=0, z_angle=0, rot_center=None)
Rotates the structure about x axis, then y axis, then z axis.
 
transform_atom_coordinates(coords, matrix)
Transforms the specified atom coordinates using a 4x4 transformation matrix.
 
transform_structure(st, matrix, atom_index_list=None)
Transforms atom coordinates of the structure using a 4x4 transformation matrix.
 
get_centroid(st, atom_list=None)
Returns the structure's centroid as a 4-element numpy array: [x y z 0.0].
 
translate_center_to_origin(st, origin=None)
Translates the structure's center to the origin.
 
translate_centroid_to_origin(st, atom_list=None)
Translates the structure's centroid to the origin.
 
translate_to_origin(st, atom_list=None)
Translates the structure's centroid to the origin.
 
get_translation_matrix(trans)
Returns a 4x4 numpy array representing a translation matrix from a 3-element list.
 
get_rotation_matrix(axis, angle)
Returns a 4x4 numpy array representing a right-handed rotation matrix about the specified Cartesian axis by some angle
 
get_rotation_matrix_from_eulers(phi, theta, psi)
Returns a 4x4 numpy array representing a rotation matrix generated from a list of Euler angles.
 
get_coords_array_from_list(coords_list)
Returns coordinates as a 4-element numpy array: (x,y,z,0.0).
 
get_alignment_matrix(a_vector, b_vector)
Returns a Numpy 4x4 rotation matrix that will align a_vector onto b_vector.
Variables [hide private]
  _version = '$Revision: 1.16 $'
  X_AXIS = [1.0, 0.0, 0.0]
  Y_AXIS = [0.0, 1.0, 0.0]
  Z_AXIS = [0.0, 0.0, 1.0]
  logger = log.get_output_logger(__file__)
  __package__ = 'schrodinger.structutils'
Function Details [hide private]

translate_structure(st, x=0.0, y=0.0, z=0.0, atom_index_list=None)

 

Translates the atom coordinates along Cartesian x, y, and z axes.

st (structure.Structure)

x (float)
    Distance, in angstroms, along positive x to translate.

y (float)
    Distance, in angstroms, along positive y to translate.

z (float)
    Distance, in angstroms, along positive z to translate.

atom_index_list (list)
    Integer indexes for the atoms to transform.  If the list is not
    specified then all atoms in the structure are transformed. If the
    list is empty, none of the atoms are transformed.

rotate_structure(st, x_angle=0, y_angle=0, z_angle=0, rot_center=None)

 

Rotates the structure about x axis, then y axis, then z axis.

st (structure.Structure)

x_angle (float)
    Angle, in radians, about x to right-hand rotate.

y_angle (float)
    Angle, in radians, about y to right-hand rotate.

z_angle (float)
    Angle, in radians, about z to right-hand rotate.

rot_center (list)
    Cartesian coordinates (x, y, z) for the center of rotation.
    By default, rotation happens about the origin (0, 0, 0)

transform_atom_coordinates(coords, matrix)

 

Transforms the specified atom coordinates using a 4x4 transformation matrix.
NOTE: This will alter the actual array passed to this function.

coords (array)
    numpy array of atom coordniates (x, y, z)

matrix (numpy.array)
    4x4 numpy array representation of transformation matrix. 

transform_structure(st, matrix, atom_index_list=None)

 

Transforms atom coordinates of the structure using a 4x4
transformation matrix.  An optional list of atom numbers defining
a subset of atoms for transformation may be specified.

st (structure.Structure)

matrix (numpy.array)
    4x4 numpy array representation of transformation matrix. 

atom_index_list (list)
    Integer indexes for the atoms to transform.  If the list is not
    specified then all atoms in the structure are transformed. If the
    list is empty, none of the atoms are transformed.

get_centroid(st, atom_list=None)

 

Returns the structure's centroid as a 4-element numpy array:
[x y z 0.0].

st (structure.Structure)

@type atom_list: list
@param atom_list
    A list of 1-based atom indices. If provided, the centroid of the atoms in this
    list will be calculated instead of the centroid of all atoms.

translate_center_to_origin(st, origin=None)

 

Translates the structure's center to the origin. The difference between this function and translate_centroid_to_origin is that the centroid is the average of all atoms, whereas the center is the middle of the atoms. The centroid can be very far from the center for structures with a high percent of the atoms located in one region of space and a few atoms very far away.

Parameters:
  • st (structure.Structure) - Structure that will modified
  • orgin - Coordinates of the new origin
  • origin (list(3 floats))

translate_centroid_to_origin(st, atom_list=None)

 

Translates the structure's centroid to the origin.

st (structure.Structure)

@type atom_list: list
@param atom_list
    A list of 1-based atom indices. If provided, the centroid of the atoms
    in this list will be translated to the origin.

translate_to_origin(st, atom_list=None)

 

Translates the structure's centroid to the origin.

st (structure.Structure)

@type atom_list: list
@param atom_list
    A list of 1-based atom indices. If provided, the centroid of the atoms
    in this list will be translated to the origin.

get_translation_matrix(trans)

 

Returns a 4x4 numpy array representing a translation matrix from
a 3-element list.

trans (list)
    3-element list (x,y,z).  

get_rotation_matrix(axis, angle)

 

Returns a 4x4 numpy array representing a right-handed rotation
matrix about the specified Cartesian axis by some angle

axis (vector)
    Normalized (unit) vector for the axis around which to rotate.
    Can be one of predefined axis: X_AXIS, Y_AXIS, Z_AXIS.

angle (float)
    Angle, in radians, about which to rotate the structure about
    the axis.

get_rotation_matrix_from_eulers(phi, theta, psi)

 

Returns a 4x4 numpy array representing a rotation matrix generated
from a list of Euler angles.  The angles of rotation (phi, theta
and psi) are applied in order, and are defined as:

phi 
    Angle to rotate by about Z axis [0 to 2pi in radians]

theta
    Angle to rotate by about X' axis [0 to 2pi in radians]

psi
    Angle to rotate by about Z' axis [0 to 2pi in radians]

get_coords_array_from_list(coords_list)

 

Returns coordinates as a 4-element numpy array: (x,y,z,0.0).

coords_list (list or array)
    3 elements: x, y, z.

get_alignment_matrix(a_vector, b_vector)

 

Returns a Numpy 4x4 rotation matrix that will align a_vector onto b_vector.

a_vector (array) numpy array of vector coordinates (x, y, z)

b_vector (array) numpy array of vector coordinates (x, y, z)