superimpose#

biotite.structure.superimpose(fixed: Coord[N] | MultiCoord[M, N], mobile: Coord[N] | MultiCoord[M, N], atom_mask: ndarray[tuple[N], dtype[bool]] | None = None) → RigidTransformation[Any][source]#

Find the transformation that superimposes structures onto each other, minimizing the RMSD between them. [1][2].

More precisely, the mobile structure is rotated and translated onto the fixed structure.

Parameters:
fixedAtomArray, shape(n,) or AtomArrayStack, shape(m,n) or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float

The fixed structure(s). Alternatively coordinates can be given.

mobileAtomArray, shape(n,) or AtomArrayStack, shape(m,n) or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float

The structure(s) which is/are superimposed on the fixed structure. Each atom at index i in mobile must correspond the atom at index i in fixed to obtain correct results. Furthermore, if both fixed and mobile are AtomArrayStack objects, they must have the same number of models. Alternatively coordinates can be given.

atom_maskndarray, dtype=bool, optional

If given, only the atoms covered by this boolean mask will be considered for superimposition. This means that the algorithm will minimize the RMSD based on the covered atoms instead of all atoms. The returned superimposed structure will contain all atoms of the input structure, regardless of this parameter.

Returns:
transformationRigidTransformation

The rigid transformation(s) that superimpose mobile onto fixed. Use RigidTransformation.apply() to obtain the superimposed mobile structure or to transform another structure in the same way.

See also

superimpose_without_outliers

Superimposition with outlier removal.

superimpose_homologs

Superimposition of homologous structures.

Notes

The transformation can come in handy, in case you want to superimpose two structures with different amount of atoms. Often the two structures need to be filtered in order to obtain the same size and annotation arrays.

References

Examples

At first two models of a structure are taken and one of them is randomly rotated/translated. Consequently the RMSD is quite large:

>>> array1 = atom_array_stack[0]
>>> array2 = atom_array_stack[1]
>>> array2 = translate(array2, [1,2,3])
>>> array2 = rotate(array2, [1,2,3])
>>> print("{:.3f}".format(rmsd(array1, array2)))
11.260

RMSD decreases after superimposition of only CA atoms:

>>> transformation = superimpose(
...     array1, array2, atom_mask=(array2.atom_name == "CA")
... )
>>> array2_fit = transformation.apply(array2)
>>> print("{:.3f}".format(rmsd(array1, array2_fit)))
1.961

RMSD is even lower when all atoms are considered in the superimposition:

>>> transformation = superimpose(array1, array2)
>>> array2_fit = transformation.apply(array2)
>>> print("{:.3f}".format(rmsd(array1, array2_fit)))
1.928