From 3407f4eff404710b04eab979fd8dff70d3da85b5 Mon Sep 17 00:00:00 2001 From: Irfan Alibay Date: Mon, 3 Jul 2023 08:55:58 +0100 Subject: [PATCH 1/5] Add rdkit to pyproject.toml --- package/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/package/pyproject.toml b/package/pyproject.toml index 1e3ed0171ed..4a3f19ec613 100644 --- a/package/pyproject.toml +++ b/package/pyproject.toml @@ -79,6 +79,7 @@ extra_formats = [ "pyedr>=0.7.0", "pytng>=0.2.3", "gsd>3.0.0", + "rdkit>=2020.03.1", ] analysis = [ "seaborn", From a3b90c7f2253e3a83b712824e034a89d6fa37823 Mon Sep 17 00:00:00 2001 From: Irfan Alibay Date: Mon, 3 Jul 2023 08:56:54 +0100 Subject: [PATCH 2/5] Update setup.py --- package/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/package/setup.py b/package/setup.py index 12da052e3e9..720050693a4 100755 --- a/package/setup.py +++ b/package/setup.py @@ -654,6 +654,7 @@ def long_description(readme): 'chemfiles>=0.10', # multiple formats supported by chemfiles 'pyedr>=0.7.0', # EDR files for the EDR AuxReader 'gsd>3.0.0', # GSD + 'rdkit>=2020.03.1', # RDKit converter ], 'analysis': [ 'seaborn', # for annotated heat map and nearest neighbor From 7935f71473ab0a0c1968afb18855bc387c5b020d Mon Sep 17 00:00:00 2001 From: Irfan Alibay Date: Mon, 3 Jul 2023 08:58:31 +0100 Subject: [PATCH 3/5] Update pyproject.toml --- package/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/package/pyproject.toml b/package/pyproject.toml index 4a3f19ec613..af034be83e1 100644 --- a/package/pyproject.toml +++ b/package/pyproject.toml @@ -76,6 +76,7 @@ extra_formats = [ "netCDF4>=1.0", "h5py>=2.10", "chemfiles>=0.10", + "parmed", "pyedr>=0.7.0", "pytng>=0.2.3", "gsd>3.0.0", From da2d04c899e5aeb65a6e8a3164b32b05ae6d22e2 Mon Sep 17 00:00:00 2001 From: Irfan Alibay Date: Mon, 3 Jul 2023 08:59:00 +0100 Subject: [PATCH 4/5] Update setup.py --- package/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/package/setup.py b/package/setup.py index 720050693a4..e72247b32c1 100755 --- a/package/setup.py +++ b/package/setup.py @@ -655,6 +655,7 @@ def long_description(readme): 'pyedr>=0.7.0', # EDR files for the EDR AuxReader 'gsd>3.0.0', # GSD 'rdkit>=2020.03.1', # RDKit converter + 'parmed', # ParmEd converter ], 'analysis': [ 'seaborn', # for annotated heat map and nearest neighbor From 69a00ad171a15aea22d83bada678598ae70507d2 Mon Sep 17 00:00:00 2001 From: Mohit Kumar <120097428+MohitKumar020291@users.noreply.github.com> Date: Mon, 3 Jul 2023 13:39:31 +0530 Subject: [PATCH 5/5] DOCS: Align.py changes made (#4182) * fix #3365 * fixed all doc tests in analysis.align * Update AUTHORS * Update CHANGELOG --- package/AUTHORS | 1 + package/CHANGELOG | 2 +- package/MDAnalysis/analysis/align.py | 55 +++++++++++++++++----------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/package/AUTHORS b/package/AUTHORS index 0279ba7dde5..ba4164e49bc 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -217,6 +217,7 @@ Chronological list of authors - Egor Marin - Shaivi Malik - Daniel J. Evans + - Mohit Kumar External code ------------- diff --git a/package/CHANGELOG b/package/CHANGELOG index 7b655028939..9fe5ab5228b 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -13,7 +13,7 @@ The rules for this file: * release numbers follow "Semantic Versioning" http://semver.org ------------------------------------------------------------------------------ -??/??/?? IAlibay, jaclark5 +??/??/?? IAlibay, jaclark5, MohitKumar020291 * 2.6.0 diff --git a/package/MDAnalysis/analysis/align.py b/package/MDAnalysis/analysis/align.py index 9bb9f4798e2..acb3943c576 100644 --- a/package/MDAnalysis/analysis/align.py +++ b/package/MDAnalysis/analysis/align.py @@ -74,7 +74,7 @@ two structures, using :func:`rmsd`:: >>> ref = mda.Universe(PDB_small) - >>> mobile = mda.Universe(PSF,DCD) + >>> mobile = mda.Universe(PSF, DCD) >>> rmsd(mobile.select_atoms('name CA').positions, ref.select_atoms('name CA').positions) 28.20178579474479 @@ -89,8 +89,8 @@ rotational superposition use the superposition keyword. This will calculate a minimized RMSD between the reference and mobile structure. - >>> rmsd(mobile.select_atoms('name CA').positions, ref.select_atoms('name CA').positions, - >>> superposition=True) + >>> rmsd(mobile.select_atoms('name CA').positions, ref.select_atoms('name CA').positions, + ... superposition=True) 6.809396586471815 The rotation matrix that superimposes *mobile* on *ref* while @@ -100,18 +100,21 @@ >>> mobile0 = mobile.select_atoms('name CA').positions - mobile.select_atoms('name CA').center_of_mass() >>> ref0 = ref.select_atoms('name CA').positions - ref.select_atoms('name CA').center_of_mass() >>> R, rmsd = align.rotation_matrix(mobile0, ref0) - >>> print rmsd + >>> rmsd 6.809396586471805 - >>> print R - [[ 0.14514539 -0.27259113 0.95111876] - [ 0.88652593 0.46267112 -0.00268642] - [-0.43932289 0.84358136 0.30881368]] + >>> R + array([[ 0.14514539, -0.27259113, 0.95111876], + ... [ 0.88652593, 0.46267112, -0.00268642], + ... [-0.43932289, 0.84358136, 0.30881368]]) Putting all this together one can superimpose all of *mobile* onto *ref*:: >>> mobile.atoms.translate(-mobile.select_atoms('name CA').center_of_mass()) + >>> mobile.atoms.rotate(R) + >>> mobile.atoms.translate(ref.select_atoms('name CA').center_of_mass()) + >>> mobile.atoms.write("mobile_on_ref.pdb") @@ -123,6 +126,7 @@ >>> ref = mda.Universe(PSF, PDB_small) >>> mobile = mda.Universe(PSF, DCD) # we use the first frame >>> align.alignto(mobile, ref, select="protein and name CA", weights="mass") + (21.892591663632704, 6.809396586471809) This will change *all* coordinates in *mobile* so that the protein C-alpha atoms are optimally superimposed (translation and rotation). @@ -134,6 +138,7 @@ >>> trj = mda.Universe(PSF, DCD) # trajectory of change 1AKE->4AKE >>> alignment = align.AlignTraj(trj, ref, filename='rmsfit.dcd') >>> alignment.run() + It is also possible to align two arbitrary structures by providing a mapping between atoms based on a sequence alignment. This allows @@ -143,9 +148,9 @@ the appropriate MDAnalysis selections with the :func:`fasta2select` function and then feed the resulting dictionary to :class:`AlignTraj`:: - >>> seldict = align.fasta2select('sequences.aln') - >>> alignment = align.AlignTraj(trj, ref, filename='rmsfit.dcd', select=seldict) - >>> alignment.run() + >>> seldict = align.fasta2select('sequences.aln') # doctest: +SKIP + >>> alignment = align.AlignTraj(trj, ref, filename='rmsfit.dcd', select=seldict) # doctest: +SKIP + >>> alignment.run() # doctest: +SKIP (See the documentation of the functions for this advanced usage.) @@ -222,15 +227,15 @@ def rotation_matrix(a, b, weights=None): Parameters ---------- a : array_like - coordinates that are to be rotated ("mobile set"); array of N atoms - of shape N*3 as generated by, e.g., - :attr:`MDAnalysis.core.groups.AtomGroup.positions`. + coordinates that are to be rotated ("mobile set"); array of N atoms + of shape N*3 as generated by, e.g., + :attr:`MDAnalysis.core.groups.AtomGroup.positions`. b : array_like - reference coordinates; array of N atoms of shape N*3 as generated by, - e.g., :attr:`MDAnalysis.core.groups.AtomGroup.positions`. + reference coordinates; array of N atoms of shape N*3 as generated by, + e.g., :attr:`MDAnalysis.core.groups.AtomGroup.positions`. weights : array_like (optional) - array of floats of size N for doing weighted RMSD fitting (e.g. the - masses of the atoms) + array of floats of size N for doing weighted RMSD fitting (e.g. the + masses of the atoms) Returns ------- @@ -246,10 +251,15 @@ def rotation_matrix(a, b, weights=None): :meth:`MDAnalysis.core.groups.AtomGroup.rotate` to generate a rotated selection, e.g. :: - >>> R = rotation_matrix(A.select_atoms('backbone').positions, - >>> B.select_atoms('backbone').positions)[0] - >>> A.atoms.rotate(R) - >>> A.atoms.write("rotated.pdb") + >>> from MDAnalysisTests.datafiles import TPR, TRR + >>> from MDAnalysis.analysis import align + >>> A = mda.Universe(TPR,TRR) + >>> B = A.copy() + >>> R = rotation_matrix(A.select_atoms('backbone').positions, + ... B.select_atoms('backbone').positions)[0] + >>> A.atoms.rotate(R) + + >>> A.atoms.write("rotated.pdb") Notes ----- @@ -263,6 +273,7 @@ def rotation_matrix(a, b, weights=None): AlignTraj: Fit a whole trajectory. """ + a = np.asarray(a, dtype=np.float64) b = np.asarray(b, dtype=np.float64)