module Chem::Spatial

Defined in:

chem/spatial.cr
chem/spatial/grid.cr
chem/spatial/kdtree.cr
chem/spatial/mat3.cr
chem/spatial/parallelepiped.cr
chem/spatial/positions3_proxy.cr
chem/spatial/qcp.cr
chem/spatial/quat.cr
chem/spatial/size3.cr
chem/spatial/transform.cr
chem/spatial/vec3.cr

Class Method Summary

Class Method Detail

def self.angle(cell : Parallelepiped, a : Vec3, b : Vec3, c : Vec3) : Float64 #

[View source]
def self.angle(cell : Parallelepiped, a : Atom, b : Atom, c : Atom) : Float64 #

[View source]
def self.angle(a : Vec3, b : Vec3, c : Vec3) : Float64 #

[View source]
def self.angle(a : Atom, b : Atom, c : Atom) : Float64 #

[View source]
def self.coords(pos : Indexable(Vec3)) : Indexable(Vec3) #

Returns a coordinate list for obj.

Accepts coordinate arrays and anything that exposes atoms or a pos proxy (AtomView, Structure, residue/chain views, and Positions3Proxy).


[View source]
def self.coords(atoms : AtomView) : Indexable(Vec3) #

Returns a coordinate list for obj.

Accepts coordinate arrays and anything that exposes atoms or a pos proxy (AtomView, Structure, residue/chain views, and Positions3Proxy).


[View source]
def self.coords(obj : Structure) : Indexable(Vec3) #

Returns a coordinate list for obj.

Accepts coordinate arrays and anything that exposes atoms or a pos proxy (AtomView, Structure, residue/chain views, and Positions3Proxy).


[View source]
def self.coords(obj : Residue | ResidueView | Chain | ChainView) : Indexable(Vec3) #

Returns a coordinate list for obj.

Accepts coordinate arrays and anything that exposes atoms or a pos proxy (AtomView, Structure, residue/chain views, and Positions3Proxy).


[View source]
def self.dihedral(cell : Parallelepiped, a : Vec3, b : Vec3, c : Vec3, d : Vec3) : Float64 #

[View source]
def self.dihedral(cell : Parallelepiped, a : Atom, b : Atom, c : Atom, d : Atom) : Float64 #

[View source]
def self.dihedral(a : Vec3, b : Vec3, c : Vec3, d : Vec3) : Float64 #

[View source]
def self.dihedral(a : Atom, b : Atom, c : Atom, d : Atom) : Float64 #

[View source]
def self.dihedral(a : Vec3, b : Vec3, c : Vec3) : Float64 #

[View source]
def self.distance(cell : Parallelepiped, a : Vec3, b : Vec3) : Float64 #

[View source]
def self.distance(cell : Parallelepiped, a : Atom, b : Atom) : Float64 #

[View source]
def self.distance(a : Vec3, b : Vec3) : Float64 #

[View source]
def self.distance(q1 : Quat, q2 : Quat) : Float64 #

Returns the distance between two quaternions.

It uses the formula acos(2 * p·q^2 - 1), which returns the angular distance (0 to π) between the orientations represented by the two quaternions. Taken from https://math.stackexchange.com/a/90098.


[View source]
def self.distance(a : Atom, b : Atom) : Float64 #

[View source]
def self.distance2(cell : Parallelepiped, a : Vec3, b : Vec3) : Float64 #

[View source]
def self.distance2(cell : Parallelepiped, a : Atom, b : Atom) : Float64 #

[View source]
def self.distance2(a : Vec3, b : Vec3) : Float64 #

[View source]
def self.distance2(a : Atom, b : Atom) : Float64 #

[View source]
def self.improper(cell : Parallelepiped, a : Vec3, b : Vec3, c : Vec3, d : Vec3) : Float64 #

[View source]
def self.improper(cell : Parallelepiped, a : Atom, b : Atom, c : Atom, d : Atom) : Float64 #

[View source]
def self.improper(a : Vec3, b : Vec3, c : Vec3, d : Vec3) : Float64 #

[View source]
def self.improper(a : Atom, b : Atom, c : Atom, d : Atom) : Float64 #

[View source]
def self.qcp(pos : Indexable(Vec3), ref_pos : Indexable(Vec3), weights : Indexable(Float64) | Nil = nil) : Tuple(Quat, Float64) #

Computes the optimal rotation and minimum root mean square deviation (RMSD) in Å between two sets of coordinates pos and ref_pos using the quaternion-based characteristic polynomial (QCP) method [Theobald2005].

The QCP method is among the fastest known methods to determine the optimal least-squares rotation matrix between the two coordinate sets. The algorithm defines the problem of superposition as finding the root of a quaternion-based characteristic polynomial of a "key" matrix. Such approach avoids the costly eigen decomposition and matrix inversion operations, which are commonly employed in other methods.

In the QCP method, the RMSD is first evaluated by solving for the most positive eigenvalue of the 4×4 key matrix using a Newton-Raphson algorithm that quickly finds the largest root (eigenvalue) from the characteristic polynomial. The minimum RMSD is then easily calculated from the largest eigenvalue. If not nil, the weights determine the relative weights of each coordinate when calculating the intermediate inner products. The optimal rotation is given by the corresponding eigenvector, which can be calculated from a column of the adjoint matrix [Liu2009].

Reference C implementation found at https://theobald.brandeis.edu/qcp.

WARNING Coordinate sets must be centered at the origin.

NOTE Prefer using Spatial.rmsd, AtomView#rmsd, or Positions3Proxy#rmsd, which take care of centering the coordinates and whether or not the coordinate sets should be superimposed first.

References

  • [Theobald2005] Theobald, D. L. Rapid calculation of RMSDs using a quaternion-based characteristic polynomial. Acta Cryst., 2005, A61, 478–480.
  • [Liu2009] Liu, P., Agrafiotis, D. K., & Theobald, D. L. Fast determination of the optimal rotational matrix for macromolecular superpositions. J. Comput. Chem., 2010, 31 (7), 1561–1563.

[View source]
def self.rmsd(pos : Indexable(Vec3), ref_pos : Indexable(Vec3), *, weights : Indexable(Float64) | Nil = nil, minimize : Bool = false) : Float64 #

Returns the root mean square deviation (RMSD) in Å between two coordinate sets.

The RMSD is the average Euclidean distance between corresponding coordinates in pos and ref_pos. If minimize is true, the coordinates are superimposed first using the QCP method (see .qcp). weights, if given, determine the relative contribution of each coordinate.

Raises ArgumentError if the two sets have different sizes or are empty.

NOTE Prefer AtomView#rmsd or Positions3Proxy#rmsd when coordinates belong to atoms, especially if symmetry-corrected RMSD is needed.


[View source]
def self.rmsd(pos, ref_pos, *, weights : Indexable(Float64) | Nil = nil, minimize : Bool = false) : Float64 #

Returns the root mean square deviation (RMSD) in Å between two coordinate sets.

The RMSD is the average Euclidean distance between corresponding coordinates in pos and ref_pos. If minimize is true, the coordinates are superimposed first using the QCP method (see .qcp). weights, if given, determine the relative contribution of each coordinate.

Raises ArgumentError if the two sets have different sizes or are empty.

NOTE Prefer AtomView#rmsd or Positions3Proxy#rmsd when coordinates belong to atoms, especially if symmetry-corrected RMSD is needed.


[View source]