Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/MDAnalysis/mdanalysis in…
Browse files Browse the repository at this point in the history
…to shubham
  • Loading branch information
Shubx10 committed Jul 3, 2023
2 parents 2ecb38b + 1b7d322 commit 1797afb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ Chronological list of authors
- Egor Marin
- Shaivi Malik
- Daniel J. Evans
- Mohit Kumar

External code
-------------
Expand Down
2 changes: 1 addition & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 33 additions & 22 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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())
<AtomGroup with 3341 atoms>
>>> mobile.atoms.rotate(R)
<AtomGroup with 3341 atoms>
>>> mobile.atoms.translate(ref.select_atoms('name CA').center_of_mass())
<AtomGroup with 3341 atoms>
>>> mobile.atoms.write("mobile_on_ref.pdb")
Expand All @@ -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).
Expand All @@ -134,6 +138,7 @@
>>> trj = mda.Universe(PSF, DCD) # trajectory of change 1AKE->4AKE
>>> alignment = align.AlignTraj(trj, ref, filename='rmsfit.dcd')
>>> alignment.run()
<MDAnalysis.analysis.align.AlignTraj object at ...>
It is also possible to align two arbitrary structures by providing a
mapping between atoms based on a sequence alignment. This allows
Expand All @@ -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.)
Expand Down Expand Up @@ -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
-------
Expand All @@ -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)
<AtomGroup with 47681 atoms>
>>> A.atoms.write("rotated.pdb")
Notes
-----
Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ extra_formats = [
"netCDF4>=1.0",
"h5py>=2.10",
"chemfiles>=0.10",
"parmed",
"pyedr>=0.7.0",
"pytng>=0.2.3",
"gsd>3.0.0",
"rdkit>=2020.03.1",
]
analysis = [
"seaborn",
Expand Down
2 changes: 2 additions & 0 deletions package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ 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
'parmed', # ParmEd converter
],
'analysis': [
'seaborn', # for annotated heat map and nearest neighbor
Expand Down

0 comments on commit 1797afb

Please sign in to comment.