Skip to content

Commit

Permalink
clean up align to have something to die on
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyminium authored and orbeckst committed Jun 12, 2020
1 parent cb4d195 commit 105e47a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,10 @@
.. autofunction:: get_matching_atoms
"""
from __future__ import division, absolute_import

import os.path
import warnings
import logging

from six.moves import range, zip, zip_longest
from six import raise_from, string_types

import numpy as np

import Bio.SeqIO
Expand Down Expand Up @@ -508,20 +503,18 @@ def alignto(mobile, reference, select=None, weights=None,
if subselection is None:
# mobile_atoms is Universe
mobile_atoms = mobile.universe.atoms
elif isinstance(subselection, string_types):
elif isinstance(subselection, str):
# select mobile_atoms from string
mobile_atoms = mobile.select_atoms(subselection)
else:
try:
# treat subselection as AtomGroup
mobile_atoms = subselection.atoms
except AttributeError:
raise_from(
TypeError(
"subselection must be a selection string, an"
" AtomGroup or Universe or None"
),
None)
except AttributeError as exc:
err = ("subselection must be a selection string, an"
" AtomGroup or Universe or None")
raise TypeError(err) from exc


# _fit_to DOES subtract center of mass, will provide proper min_rmsd
mobile_atoms, new_rmsd = _fit_to(mobile_coordinates, ref_coordinates,
Expand Down Expand Up @@ -1348,12 +1341,12 @@ def get_atoms_byres(g, match_mask=np.logical_not(mismatch_mask)):
else:
try:
mass_mismatches = (np.absolute(ag1.masses - ag2.masses) > tol_mass)
except ValueError:
except ValueError as exc:
errmsg = ("Failed to find matching atoms: len(reference) = {}, len(mobile) = {} "
"Try to improve your selections for mobile and reference.").format(
ag1.n_atoms, ag2.n_atoms)
logger.error(errmsg)
raise_from(SelectionError(errmsg), None)
raise SelectionError(errmsg) from exc

if np.any(mass_mismatches):
# Test 2 failed.
Expand Down

0 comments on commit 105e47a

Please sign in to comment.