Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/structure/benchmark_superimpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@ def benchmark_superimpose(method, atoms):
Compute superimposition of two structures with the same number of atoms.
"""
method(atoms[0], atoms[1])


@pytest.mark.benchmark
@pytest.mark.parametrize(
"method",
[
struc.superimpose,
struc.superimpose_without_outliers,
struc.superimpose_homologs,
],
)
def benchmark_superimpose_multi_model(method, atoms):
"""
Superimpose every model of an ensemble onto a single reference model.

``superimpose_structural_homologs`` is omitted, as it does not accept an
:class:`AtomArrayStack`.
"""
method(atoms[0], atoms)
2 changes: 1 addition & 1 deletion src/biotite/structure/superimpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def _get_rotation_matrices(
Both sets of coordinates must already be centered at origin.
"""
# Calculate cross-covariance matrices
cov = np.sum(fixed[:, :, :, np.newaxis] * mobile[:, :, np.newaxis, :], axis=1)
cov = np.matmul(np.swapaxes(fixed, -1, -2), mobile) # (M, XYZ, XYZ)
v, s, w = np.linalg.svd(cov)
# Remove possibility of reflected atom coordinates
reflected_mask = np.linalg.det(v) * np.linalg.det(w) < 0
Expand Down
Loading