calculate_rmsd
esta.rmsd.calculate_rmsd
¶
str_atom(atom)
¶
Convert atom type from integer to string
Parameters:
-
atoms
(string
) –
Returns:
-
atoms
(integer
) –
int_atom(atom)
¶
Convert atom type from string to integer
Parameters:
-
atoms
(string
) –
Returns:
-
atoms
(integer
) –
rmsd(V, W)
¶
Calculate Root-mean-square deviation from two sets of vectors V and W.
Parameters:
-
V
(array
) –(N,D) matrix, where N is points and D is dimension.
-
W
(array
) –(N,D) matrix, where N is points and D is dimension.
Returns:
-
rmsd
(float
) –Root-mean-square deviation between the two vectors
kabsch_rmsd(P, Q, W=None, translate=False)
¶
Rotate matrix P unto Q using Kabsch algorithm and calculate the RMSD. An optional vector of weights W may be provided.
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
-
W
(array or None
, default:None
) –(N) vector, where N is points.
-
translate
(bool
, default:False
) –Use centroids to translate vector P and Q unto each other.
Returns:
-
rmsd
(float
) –root-mean squared deviation
kabsch_rotate(P, Q)
¶
Rotate matrix P unto matrix Q using Kabsch algorithm.
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
Returns:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension, rotated
kabsch_fit(P, Q, W=None)
¶
Rotate and translate matrix P unto matrix Q using Kabsch algorithm. An optional vector of weights W may be provided.
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
-
W
(array or None
, default:None
) –(N) vector, where N is points.
Returns:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension, rotated and translated.
kabsch(P, Q)
¶
Using the Kabsch algorithm with two sets of paired point P and Q, centered around the centroid. Each vector set is represented as an NxD matrix, where D is the the dimension of the space. The algorithm works in three steps: - a centroid translation of P and Q (assumed done before this function call) - the computation of a covariance matrix C - computation of the optimal rotation matrix U For more info see http://en.wikipedia.org/wiki/Kabsch_algorithm
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
Returns:
-
U
(matrix
) –Rotation matrix (D,D)
kabsch_weighted(P, Q, W=None)
¶
Using the Kabsch algorithm with two sets of paired point P and Q. Each vector set is represented as an NxD matrix, where D is the dimension of the space. An optional vector of weights W may be provided.
Note that this algorithm does not require that P and Q have already been overlayed by a centroid translation.
The function returns the rotation matrix U, translation vector V, and RMS deviation between Q and P', where P' is:
P' = P * U + V
For more info see http://en.wikipedia.org/wiki/Kabsch_algorithm
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
-
W
(array or None
, default:None
) –(N) vector, where N is points.
Returns:
-
U
(matrix
) –Rotation matrix (D,D)
-
V
(vector
) –Translation vector (D)
-
RMSD
(float
) –Root mean squared deviation between P and Q
kabsch_weighted_fit(P, Q, W=None, rmsd=False)
¶
Fit P to Q with optional weights W. Also returns the RMSD of the fit if rmsd=True.
Parameters:
-
P
–(N,D) matrix, where N is points and D is dimension.
-
Q
–(N,D) matrix, where N is points and D is dimension.
-
W
–(N) vector, where N is points
-
rmsd
(Bool
, default:False
) –If True, rmsd is returned as well as the fitted coordinates.
Returns:
-
P' : array
–(N,D) matrix, where N is points and D is dimension.
-
RMSD
(float
) –if the function is called with rmsd=True
kabsch_weighted_rmsd(P, Q, W=None)
¶
Calculate the RMSD between P and Q with optional weighhts W
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
-
W
(vector
, default:None
) –(N) vector, where N is points
Returns:
-
RMSD
(float
) –
quaternion_rmsd(P, Q)
¶
Rotate matrix P unto Q and calculate the RMSD based on doi:10.1016/1049-9660(91)90036-O
Parameters:
-
P
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Q
(array
) –(N,D) matrix, where N is points and D is dimension.
Returns:
-
rmsd
(float
) –
quaternion_transform(r)
¶
Get optimal rotation note: translation will be zero when the centroids of each molecule are the same
makeW(r1, r2, r3, r4=0)
¶
matrix involved in quaternion rotation
makeQ(r1, r2, r3, r4=0)
¶
matrix involved in quaternion rotation
quaternion_rotate(X, Y)
¶
Calculate the rotation
Parameters:
-
X
(array
) –(N,D) matrix, where N is points and D is dimension.
-
Y
–(N,D) matrix, where N is points and D is dimension.
Returns:
-
rot
(matrix
) –Rotation matrix (D,D)
centroid(X)
¶
Centroid is the mean position of all the points in all of the coordinate directions, from a vectorset X.
https://en.wikipedia.org/wiki/Centroid
C = sum(X)/len(X)
Parameters:
-
X
(array
) –(N,D) matrix, where N is points and D is dimension.
Returns:
-
C
(float
) –centroid
hungarian_vectors(p_vecs, q_vecs, sigma=1.0, use_kernel=True)
¶
Hungarian cost assignment of a similiarty molecule kernel.
Note: Assumes p and q are atoms of same type
Parameters:
-
p_vecs
(array
) –(N,L) matrix, where N is no. of atoms and L is representation length
-
q_vecs
(array
) –(N,L) matrix, where N is no. of atoms and L is representation length
Returns:
-
indices_b
(array
) –(N) view vector of reordered assignment
reorder_similarity(p_atoms, q_atoms, p_coord, q_coord, use_kernel=True)
¶
Re-orders the input atom list and xyz coordinates using QML similarity the Hungarian method for assignment.
Parameters:
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_coord
(array
) –(N,D) matrix, where N is points and D is dimension
-
q_coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
view_reorder
(array
) –(N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms
reorder_distance(p_atoms, q_atoms, p_coord, q_coord)
¶
Re-orders the input atom list and xyz coordinates by atom type and then by distance of each atom from the centroid.
Parameters:
-
atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
atoms_reordered
(array
) –(N,1) matrix, where N is points holding the ordered atoms' names
-
coords_reordered
(array
) –(N,D) matrix, where N is points and D is dimension (rows re-ordered)
hungarian(A, B)
¶
Hungarian reordering.
Assume A and B are coordinates for atoms of SAME type only
reorder_hungarian(p_atoms, q_atoms, p_coord, q_coord)
¶
Re-orders the input atom list and xyz coordinates using the Hungarian method (using optimized column results)
Parameters:
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_coord
(array
) –(N,D) matrix, where N is points and D is dimension
-
q_coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
view_reorder
(array
) –(N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms
reorder_inertia_hungarian(p_atoms, q_atoms, p_coord, q_coord)
¶
Align the principal intertia axis and then re-orders the input atom list and xyz coordinates using the Hungarian method (using optimized column results)
Parameters:
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_coord
(array
) –(N,D) matrix, where N is points and D is dimension
-
q_coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
view_reorder
(array
) –(N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms
generate_permutations(elements, n)
¶
Heap's algorithm for generating all n! permutations in a list https://en.wikipedia.org/wiki/Heap%27s_algorithm
brute_permutation(A, B)
¶
Re-orders the input atom list and xyz coordinates using the brute force method of permuting all rows of the input coordinates
Parameters:
-
A
(array
) –(N,D) matrix, where N is points and D is dimension
-
B
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
view
(array
) –(N,1) matrix, reordered view of B projected to A
reorder_brute(p_atoms, q_atoms, p_coord, q_coord)
¶
Re-orders the input atom list and xyz coordinates using all permutation of rows (using optimized column results)
Parameters:
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
q_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_coord
(array
) –(N,D) matrix, where N is points and D is dimension
-
q_coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
view_reorder
(array
) –(N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms
check_reflections(p_atoms, q_atoms, p_coord, q_coord, reorder_method=reorder_hungarian, rotation_method=kabsch_rmsd, keep_stereo=False)
¶
Minimize RMSD using reflection planes for molecule P and Q
Warning: This will affect stereo-chemistry
Parameters:
-
p_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
q_atoms
(array
) –(N,1) matrix, where N is points holding the atoms' names
-
p_coord
(array
) –(N,D) matrix, where N is points and D is dimension
-
q_coord
(array
) –(N,D) matrix, where N is points and D is dimension
Returns:
-
min_rmsd
– -
min_swap
– -
min_reflection
– -
min_review
–
rotation_matrix_vectors(v1, v2)
¶
Returns the rotation matrix that rotates v1 onto v2 using Rodrigues' rotation formula.
(see https://math.stackexchange.com/a/476311)
v1 : array Dim 3 float array v2 : array Dim 3 float array
Return
output : 3x3 matrix Rotation matrix
get_cm(atoms, V)
¶
Get the center of mass of V.
atoms : list List of atomic types V : array (N,3) matrix of atomic coordinates
Return
output : (3) array The CM vector
get_inertia_tensor(atoms, V)
¶
Get the tensor of intertia of V.
atoms : list List of atomic types V : array (N,3) matrix of atomic coordinates
Return
output : 3x3 float matrix The tensor of inertia
get_principal_axis(atoms, V)
¶
Get the molecule's principal axis.
atoms : list List of atomic types V : array (N,3) matrix of atomic coordinates
Return
output : array Array of dim 3 containing the principal axis
set_coordinates(atoms, V, title='', decimals=8)
¶
Print coordinates V with corresponding atoms to stdout in XYZ format.
Parameters:
-
atoms
(list
) –List of atomic types
-
V
(array
) –(N,3) matrix of atomic coordinates
-
title
(string(optional)
, default:''
) –Title of molecule
-
decimals
(int(optional)
, default:8
) –number of decimals for the coordinates
Return
output : str Molecule in XYZ format
print_coordinates(atoms, V, title='')
¶
Print coordinates V with corresponding atoms to stdout in XYZ format.
Parameters:
-
atoms
(list
) –List of element types
-
V
(array
) –(N,3) matrix of atomic coordinates
-
title
(string(optional)
, default:''
) –Title of molecule
get_coordinates(filename, fmt, is_gzip=False, return_atoms_as_int=False)
¶
Get coordinates from filename in format fmt. Supports XYZ and PDB.
Parameters:
-
filename
(string
) –Filename to read
-
fmt
(string
) –Format of filename. Either xyz or pdb.
Returns:
-
atoms
(list
) –List of atomic types
-
V
(array
) –(N,3) where N is number of atoms
get_coordinates_pdb(filename, is_gzip=False, return_atoms_as_int=False)
¶
Get coordinates from the first chain in a pdb file and return a vectorset with all the coordinates.
Parameters:
-
filename
(string
) –Filename to read
Returns:
-
atoms
(list
) –List of atomic types
-
V
(array
) –(N,3) where N is number of atoms
get_coordinates_xyz(filename, is_gzip=False, return_atoms_as_int=False)
¶
Get coordinates from filename and return a vectorset with all the coordinates, in XYZ format.
Parameters:
-
filename
(string
) –Filename to read
Returns:
-
atoms
(list
) –List of atomic types
-
V
(array
) –(N,3) where N is number of atoms