Skip to content

Commit

Permalink
Merge develop (#2)
Browse files Browse the repository at this point in the history
* Add arbitrary TopologyAttr selection (MDAnalysis#2927)

Fixes MDAnalysis#2925 
Fixes MDAnalysis#2875
Fixes MDAnalysis#3054 

Changes made in this Pull Request:
 - added a class factory to subclass `core.selection.Selection` for each TopologyAttr
 - added tokens to `core.selection.SameSelection`
 - added `FloatRangeSelection` and `BoolSelection`
 - added negatives, scientific notation and "to" delimiter for ranges

* Add ReadTheDocs configuration for PR builds (MDAnalysis#3060)

 - Adds RTD configuration
 - Add `environment.yml` for package installation

* Remove appveyor

* Install MDAnalysis on ReadTheDocs via pip (MDAnalysis#3071)

Install via `pip install package/` to build current docs on ReadTheDocs

* try stringio

* rm metals file

* pin pytest

* pin pytest on gh actions

* Fixes RMSF docstring (Issue MDAnalysis#2806) (MDAnalysis#3033)

Fixes the RMSF docstring's align command and adds transformation to make the results accurate

* MAINT: simplify guessers regex (MDAnalysis#3085)

* the `SYMBOLS` regex in `guessers.py` does not require
any escape sequences because the metacharacters are inactive
in the character class (this includes the range metacharacter
when placed at the start or end of the character class)

* MAINT: char class regex improve

* avoid the overhead of a regex character class
when that character class has only a single character
(i.e., serves no purpose)

* there is only one instance of this in MDA codebase
discovered by my [scraping
code](https://github.com/tylerjereddy/regex-improve)

* for a longer explanation see my similar changes in
NumPy codebase:
numpy/numpy#18083

* Fix syntax warning over comparison of literals using is.

* Quick fix for atommethods to return empty residue group (MDAnalysis#3089)

Returns empty residue group for _get_prev_residues_by_resid and _get_next_residues_by_resid

* Add to authors list.

Co-authored-by: Lily Wang <[email protected]>
Co-authored-by: IAlibay <[email protected]>
Co-authored-by: Tyler Reddy <[email protected]>
Co-authored-by: Lily Wang <[email protected]>
Co-authored-by: Irfan Alibay <[email protected]>
Co-authored-by: Oliver Beckstein <[email protected]>
Co-authored-by: Karthikeyan Singaravelan <[email protected]>
Co-authored-by: Aditya Kamath <[email protected]>
  • Loading branch information
9 people authored Jan 12, 2021
1 parent 5acfc4e commit 09a05be
Show file tree
Hide file tree
Showing 23 changed files with 692 additions and 248 deletions.
73 changes: 0 additions & 73 deletions .appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defaults:
shell: bash -l {0}

env:
MDA_CONDA_MIN_DEPS: "pip pytest mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov"
MDA_CONDA_MIN_DEPS: "pip pytest==6.1.2 mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov"
MDA_CONDA_EXTRA_DEPS: "seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py==2.10.0"
MDA_PIP_MIN_DEPS: 'coveralls coverage<5 pytest-cov pytest-xdist'
MDA_PIP_EXTRA_DEPS: 'duecredit parmed'
Expand Down
24 changes: 24 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in with Sphinx
sphinx:
configuration: package/doc/sphinx/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml


# Optionally set the version of Python and requirements required to build your docs
python:
install:
- method: pip
path: package

conda:
environment: maintainer/conda/environment.yml
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
hypothesis
matplotlib
numpy
pytest
pytest==6.1.2
pytest-cov
pytest-xdist
scikit-learn
Expand Down
34 changes: 34 additions & 0 deletions maintainer/conda/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: mda-dev
channels:
- defaults
- conda-forge
dependencies:
- chemfiles
- codecov
- cython
- griddataformats
- gsd
- h5py==2.10.0
- hypothesis
- joblib>=0.12
- matplotlib==3.2.2
- mmtf-python
- mock
- networkx
- numpy>=1.17.3
- psutil
- pytest
- python==3.7
- scikit-learn
- scipy
- pip
- sphinx==1.8.5
- tidynamics>=1.0.0
- tqdm>=4.43.0
- sphinxcontrib-bibtex
- sphinx_rtd_theme
- pip:
- duecredit
- parmed
- msmb_theme==1.2.0
- sphinx-sitemap==1.0.2
5 changes: 4 additions & 1 deletion package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ Chronological list of authors
- Nicholas Craven
- Mieczyslaw Torchala
- Haochuan Chen

- Karthikeyan Singaravelan
2021
- Aditya Kamath

External code
-------------

Expand Down
12 changes: 10 additions & 2 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ The rules for this file:
??/??/?? tylerjereddy, richardjgowers, IAlibay, hmacdope, orbeckst, cbouy,
lilyminium, daveminh, jbarnoud, yuxuanzhuang, VOD555, ianmkenney,
calcraven,xiki-tempula, mieczyslaw, manuel.nuno.melo, PicoCentauri,
hanatok, rmeli
hanatok, rmeli, aditya-kamath, tirkarthi

* 2.0.0

Fixes
* atommethods (_get_prev/next_residues_by_resid) returns empty residue group
when given empty residue group (Issue #3089)
* MOL2 files without bonds can now be read and written (Issue #3057)
* Write `CONECT` record only once in multi-model PDB files (Issue #3018)
* Add '.nc' as a recognised extension for the NCDFWriter (Issue #3030)
Expand Down Expand Up @@ -75,8 +77,14 @@ Fixes
(Issue #2934)
* Fix tests for analysis.bat that could fail when run in parallel and that
would create a test artifact (Issue #2979, PR #2981)
* Fix syntax warning over comparison of literals using is (Issue #3066)

Enhancements
* Added automatic selection class generation for TopologyAttrs,
FloatRangeSelection, and BoolSelection (Issues #2925, #2875; PR #2927)
* Added 'to' operator, negatives, scientific notation, and arbitrary
whitespace for ranges (Issue #3054, PR #2927)
* Added `atol` and `rtol` keywords for float comparison (PR #2927)
* Improved performance of the ParmEd converter (Issue #3028, PR #3029)
* Improved analysis class docstrings, and added missing classes to the
`__all__` list (PR #2998)
Expand Down Expand Up @@ -112,7 +120,7 @@ Enhancements
'protein' selection (#2751 PR #2755)
* Added an RDKit converter that works for any input with all hydrogens
explicit in the topology (Issue #2468, PR #2775)

Changes
* Continuous integration uses mamba rather than conda to install the
dependencies (PR #2983)
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/legacy/x3dna.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def plot(self, **kwargs):
ax.set_xlabel(r"Nucleic Acid Number")
param = self.profiles.values()[0].dtype.names[k]
if param in ["Shear", "Stretch", "Stagger", "Rise", "Shift", "Slide"]:
ax.set_ylabel("{0!s} ($\AA$)".format((param)))
ax.set_ylabel(r"{!s} ($\AA$)".format(param))
else:
ax.set_ylabel("{0!s} (deg)".format((param)))
ax.figure.savefig("{0!s}.png".format((param)))
Expand Down
30 changes: 20 additions & 10 deletions package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,27 +745,37 @@ def __init__(self, atomgroup, **kwargs):
u = mda.Universe(TPR, XTC, in_memory=True)
protein = u.select_atoms("protein")
# 1) need a step to center and make whole: this trajectory
# contains the protein being split across periodic boundaries
#
# TODO
# 1) the current trajectory contains a protein split across
# periodic boundaries, so we first make the protein whole and
# center it in the box using on-the-fly transformations
import MDAnalysis.transformations as trans
not_protein = u.select_atoms('not protein')
transforms = [trans.unwrap(protein),
trans.center_in_box(protein, wrap=True),
trans.wrap(not_protein)]
u.trajectory.add_transformations(*transforms)
# 2) fit to the initial frame to get a better average structure
# (the trajectory is changed in memory)
prealigner = align.AlignTraj(u, select="protein and name CA", in_memory=True).run()
prealigner = align.AlignTraj(u, u, select="protein and name CA",
in_memory=True).run()
# 3) reference = average structure
reference_coordinates = u.trajectory.timeseries(asel=protein).mean(axis=1)
# make a reference structure (need to reshape into a 1-frame "trajectory")
reference = mda.Merge(protein).load_new(
reference_coordinates[:, None, :], order="afc")
ref_coordinates = u.trajectory.timeseries(asel=protein).mean(axis=1)
# make a reference structure (need to reshape into a 1-frame
# "trajectory")
reference = mda.Merge(protein).load_new(ref_coordinates[:, None, :],
order="afc")
We created a new universe ``reference`` that contains a single frame
with the averaged coordinates of the protein. Now we need to fit the
whole trajectory to the reference by minimizing the RMSD. We use
:class:`MDAnalysis.analysis.align.AlignTraj`::
aligner = align.AlignTraj(u, reference, select="protein and name CA", in_memory=True).run()
aligner = align.AlignTraj(u, reference,
select="protein and name CA",
in_memory=True).run()
The trajectory is now fitted to the reference (the RMSD is stored as
`aligner.rmsd` for further inspection). Now we can calculate the RMSF::
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/GMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _read_next_timestep(self, ts=None):
line) is not None):
flag = 2
continue
if (flag == 2) and (re.match(r'^\s*[-]+\s*', line) is not None):
if (flag == 2) and (re.match(r'^\s*-+\s*', line) is not None):
flag = 3
continue
if flag == 3 and counter < self.n_atoms:
Expand Down
20 changes: 14 additions & 6 deletions package/MDAnalysis/core/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,9 @@ def ts(self):

# As with universe.select_atoms, needing to fish out specific kwargs
# (namely, 'updating') doesn't allow a very clean signature.
def select_atoms(self, sel, *othersel, **selgroups):

def select_atoms(self, sel, *othersel, periodic=True, rtol=1e-05,
atol=1e-08, updating=False, **selgroups):
"""Select atoms from within this Group using a selection string.
Returns an :class:`AtomGroup` sorted according to their index in the
Expand All @@ -2623,6 +2625,12 @@ def select_atoms(self, sel, *othersel, **selgroups):
periodic : bool (optional)
for geometric selections, whether to account for atoms in different
periodic images when searching
atol : float, optional
The absolute tolerance parameter for float comparisons.
Passed to :func:``numpy.isclose``.
rtol : float, optional
The relative tolerance parameter for float comparisons.
Passed to :func:``numpy.isclose``.
updating : bool (optional)
force the selection to be re evaluated each time the Timestep of the
trajectory is changed. See section on **Dynamic selections** below.
Expand Down Expand Up @@ -2893,17 +2901,15 @@ def select_atoms(self, sel, *othersel, **selgroups):
Removed flags affecting default behaviour for periodic selections;
periodic are now on by default (as with default flags)
.. versionchanged:: 2.0.0
Added the *smarts* selection.
Added the *smarts* selection. Added `atol` and `rtol` keywords
to select float values.
"""

if not sel:
warnings.warn("Empty string to select atoms, empty group returned.",
UserWarning)
return self[[]]

periodic = selgroups.pop('periodic', True)

updating = selgroups.pop('updating', False)
sel_strs = (sel,) + othersel

for group, thing in selgroups.items():
Expand All @@ -2912,7 +2918,9 @@ def select_atoms(self, sel, *othersel, **selgroups):
"You provided {} for group '{}'".format(
thing.__class__.__name__, group))

selections = tuple((selection.Parser.parse(s, selgroups, periodic=periodic)
selections = tuple((selection.Parser.parse(s, selgroups,
periodic=periodic,
atol=atol, rtol=rtol)
for s in sel_strs))
if updating:
atomgrp = UpdatingAtomGroup(self, selections, sel_strs)
Expand Down
Loading

0 comments on commit 09a05be

Please sign in to comment.