Molecular similarity

Module that contains the class for evaluating similarity of atomic or molecular conformations. Alignment of atomistic systems requires consideration of translational, rotatational and permutational invariance, which makes it much more challenging than the Euclidean distance between configurations

class topsearch.similarity.molecular_similarity.MolecularSimilarity(distance_criterion: float, energy_criterion: float, weighted: bool = False, allow_inversion: bool = False)

Description

Class to perform alignment of molecular and atomic coordinate objects, and highlight repeated minima and transition states. Alignment minimises the Euclidean distance between a pair of conformations accounting for translational, rotational and permutational invariance.

distance_criterion

The distance under which two minima are considered the same

Type:

float

energy_criterion

The value that the difference in function values must be below to be considered the same

Type:

float

weighted

Flag that specifies whether we include the relative atomic weights in alignment

Type:

bool

allow_inversion

Flag that specifies if we consider conformations related by the inversion operation as the same

Type:

bool

align(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) tuple

Perform permutational and rotational alignment of coords2 relative to coords1 to find best alignment

centre(position: NDArray[Any, Any], weights: NDArray[Any, Any]) NDArray[Any, Any]

Returns coords after centre of mass has been moved to origin

closest_distance(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) float

Align two structures and return the optimised distance

generate_pairs(indices1: list, indices2: list) list

Generate a list of all possible pairs from two input lists

get_furthest_from_centre(position: NDArray[Any, Any]) list

Find the atom furthest from the origin in position, and any other within 0.05 of this

get_furthest_perpendicular(position: NDArray[Any, Any], ref_atom: int) list

Find the atoms furthest from the origin in position, perpendicular to the vector to position[ref_atom]

get_permutable_groups(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) list

Determine the subsets of atoms that are allowed to be permuted when minimising the distance between conformations. Must be of the same element and have the same bonds

invert(position: NDArray[Any, Any]) NDArray[Any, Any]

Invert a conformation

optimal_alignment(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) tuple

Try to find the optimal alignment between coords1 and coords2. Initially test if the structures are the same, and if not iterate alignment from different starting orientations

permutational_alignment(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) tuple

Hungarian algorithm adapted to solve the linear assignment problem for each atom of each distinct element. Finds the optimal permutation of all atoms respecting the atomic species

random_rotation(position: NDArray[Any, Any]) NDArray[Any, Any]

Apply a uniformly distributed random rotation matrix

rotational_alignment(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) tuple

Find the rotation that minimises the distance between two sets of vectors using the Kabsch algorithm and apply it

test_exact_same(coords1: MolecularCoordinates, coords2: NDArray[Any, Any]) tuple

Routine to test if two conformations are identical by aligning furthest atom from centre in each, along with furthest in direction perpendicular to that

test_same(coords1: MolecularCoordinates, coords2: NDArray[Any, Any], energy1: float, energy2: float) bool

Test if two structures are the same to within a distance and energy criterion after finding the closest alignment