From fbdb87aee72648db04816c2cd0679060918b9231 Mon Sep 17 00:00:00 2001 From: rlaplaza Date: Wed, 4 Dec 2024 17:16:37 +0100 Subject: [PATCH] Added some minor fixes for edge cases where isomorphisms cannot be found --- navicat_marc/helpers.py | 2 +- navicat_marc/rmsd.py | 14 +++++++++++--- pyproject.toml | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/navicat_marc/helpers.py b/navicat_marc/helpers.py index 084f62e..3371621 100755 --- a/navicat_marc/helpers.py +++ b/navicat_marc/helpers.py @@ -105,7 +105,7 @@ def molecules_from_file(filename, scale_factor=1.10, noh=True): def processargs(arguments): input_list = sys.argv input_str = " ".join(input_list) - version_str = "0.2.3" + version_str = "0.2.4" mbuilder = argparse.ArgumentParser( prog="navicat_marc", description="Analyse conformer ensembles to find the most representative structures.", diff --git a/navicat_marc/rmsd.py b/navicat_marc/rmsd.py index 7e011b5..ba4c498 100755 --- a/navicat_marc/rmsd.py +++ b/navicat_marc/rmsd.py @@ -50,9 +50,16 @@ def rmsd_matrix(mols, sort=False, truesort=False, normalize=True): save_rotated_coordinates = rotated_coordinates if np.isclose(0, min_res): break - pos_ibj.append(save_ibj) - assert all(mols[i].atoms == mols[j].atoms[save_ibj]) - mols[j].update(mols[j].atoms[save_ibj], save_rotated_coordinates) + if len(iviews) == 0: + min_res, save_rotated_coordinates = kabsch_rmsd( + mols[i].coordinates, mols[j].coordinates + ) + assert all(mols[i].atoms == mols[j].atoms) + mols[j].update(mols[j].atoms, save_rotated_coordinates) + else: + pos_ibj.append(save_ibj) + assert all(mols[i].atoms == mols[j].atoms[save_ibj]) + mols[j].update(mols[j].atoms[save_ibj], save_rotated_coordinates) M[i, j] = M[j, i] = min_res if not sort and len(pos_ibj) > 0: for k, ibj in enumerate(pos_ibj): @@ -78,6 +85,7 @@ def rmsd_matrix(mols, sort=False, truesort=False, normalize=True): if not truesort: sort = False maxval = np.max(M) + max_idxs = np.unravel_index(M.argmax(), M.shape) if normalize: M = np.abs(M) / maxval return M, maxval diff --git a/pyproject.toml b/pyproject.toml index 57a0626..0794440 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "navicat_marc" -version = "0.2.3" +version = "0.2.4" authors = [ { name="R. Laplaza", email="rlaplaza@duck.com" }, ] @@ -17,7 +17,7 @@ dependencies = [ 'networkx >= 3.0', 'numpy >= 1.24.4', 'scikit_learn >= 1.2.0', - 'scipy >= 1.10.1', + 'scipy == 1.10.1', 'setuptools >= 65.4.1', ] classifiers = [