Skip to content

Commit

Permalink
Merge branch 'develop' into get_connections_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyminium authored Apr 7, 2021
2 parents 981c22a + 12bebfd commit 759e9ee
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .disabled-travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ env:
- SETUP_CMD="${PYTEST_FLAGS}"
- BUILD_CMD="pip install -e package/ && (cd testsuite/ && python setup.py build)"
- CONDA_MIN_DEPENDENCIES="mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov"
- CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} 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"
- CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} 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"
- CONDA_CHANNELS='biobuilds conda-forge'
- CONDA_CHANNEL_PRIORITY=True
- PIP_DEPENDENCIES="duecredit parmed"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defaults:

env:
MDA_CONDA_MIN_DEPS: "pip pytest==6.1.2 mmtf-python biopython networkx cython matplotlib-base 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_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"
MDA_PIP_MIN_DEPS: 'coveralls coverage<5 pytest-cov pytest-xdist'
MDA_PIP_EXTRA_DEPS: 'duecredit parmed'

Expand Down
8 changes: 5 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
Python38-64bit-full:
PYTHON_VERSION: '3.8'
PYTHON_ARCH: 'x64'
Python39-64bit-full:
PYTHON_VERSION: '3.9'
PYTHON_ARCH: 'x64'
steps:
- task: UsePythonVersion@0
inputs:
Expand All @@ -44,7 +47,7 @@ jobs:
- script: python -m pip install --upgrade pip setuptools wheel
displayName: 'Install tools'
- script: >-
python -m pip install
python -m pip install --only-binary=h5py
cython
hypothesis
matplotlib
Expand All @@ -54,11 +57,10 @@ jobs:
pytest-xdist
scikit-learn
scipy
h5py==2.10.0
h5py
tqdm
displayName: 'Install dependencies'
# TODO: recent rdkit is not on PyPI
# NOTE: h5py pinned because of gh-3019
- script: >-
python -m pip install
biopython
Expand Down
4 changes: 2 additions & 2 deletions maintainer/conda/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- cython
- griddataformats
- gsd
- h5py==2.10.0
- h5py
- hypothesis
- joblib>=0.12
- matplotlib==3.2.2
Expand All @@ -31,4 +31,4 @@ dependencies:
- duecredit
- parmed
- msmb_theme==1.2.0
- sphinx-sitemap==1.0.2
- sphinx-sitemap==1.0.2
4 changes: 4 additions & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ Chronological list of authors
- Leonardo Barneschi
- Henrik Jäger
- Jan Stevens
- Orion Cohen
- Dimitrios Papageorgiou
- Hannah Pollak
- Estefania Barreto-Ojeda

External code
-------------
Expand Down
9 changes: 8 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ The rules for this file:
lilyminium, daveminh, jbarnoud, yuxuanzhuang, VOD555, ianmkenney,
calcraven,xiki-tempula, mieczyslaw, manuel.nuno.melo, PicoCentauri,
hanatok, rmeli, aditya-kamath, tirkarthi, LeonardoBarneschi, hejamu,
biogen98
biogen98, orioncohen, z3y50n, hp115, ojeda-e

* 2.0.0

Fixes
* Helix_analysis coverage raised to 100% and `from __future__ import`
removed (Issue #3209)
* Fixed 'sphzone', 'sphlayer', 'cyzone', and 'cylayer' to return empty if the
zone/layer is empty, consistent with 'around' (Issue #2915)
* A Universe created from an ROMol with no atoms returns now a Universe
with 0 atoms (Issue #3142)
* ValueError raised when empty atomgroup is given to DensityAnalysis
Expand Down Expand Up @@ -90,6 +94,8 @@ Enhancements
* Added intra_bonds, intra_angles, intra_dihedrals etc. to return only
the connections involving atoms within the AtomGroup, instead of
including atoms outside the AtomGroup (Issue #1264, #2821, PR #3200)
* Add `set_dimensions` transformation class for setting constant
box dimensions for all timesteps in trajectory (Issue #2691)
* Added a ValueError raised when not given a gridcenter while
providing grid dimensions to DensityAnalysis, also added
check for NaN in the input (Issue #3148, PR #3154)
Expand Down Expand Up @@ -144,6 +150,7 @@ Enhancements


Changes
* Fixed inaccurate docstring inside the RMSD class (Issue #2796, PR #3134)
* TPRParser now loads TPR files with `tpr_resid_from_one=True` by default,
which starts TPR resid indexing from 1 (instead of 0 as in 1.x) (Issue #2364, PR #3152)
* Introduces encore specific C compiler arguments to allow for lowering of
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/helix_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
hel_xyz = hel.helix_analysis(u.atoms.positions, ref_axis=[0, 0, 1])
"""
from __future__ import division, absolute_import

import warnings
import numpy as np
Expand Down
5 changes: 4 additions & 1 deletion package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ def __init__(self, atomgroup, reference=None, select='all',
corresponding atom in `select`, and assumes ``None`` for `groupselections`.
weights_groupselections : False or list of {"mass", ``None`` or array_like} (optional)
1. ``False`` will apply imposed weights to `groupselections` from ``weights`` option.
1. ``False`` will apply imposed weights to `groupselections` from
``weights`` option if ``weights`` is either ``"mass"`` or ``None``.
Otherwise will assume a list of length equal to length of
`groupselections` filled with ``None`` values.
2. A list of {"mass", ``None`` or array_like} with the length of `groupselections`
will apply the weights to `groupselections` correspondingly.
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/H5MD.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def _read_frame(self, frame):
else:
raise NoDataError("Provide at least a position, velocity"
" or force group in the h5md file.")
except ValueError:
except (ValueError, IndexError):
raise IOError from None

self._frame = frame
Expand Down
8 changes: 7 additions & 1 deletion package/MDAnalysis/core/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def apply(self, group):
return func(self, group)
return apply


class _Selectionmeta(type):
def __init__(cls, name, bases, classdict):
type.__init__(type, name, bases, classdict)
Expand Down Expand Up @@ -352,6 +353,8 @@ def __init__(self, parser, tokens):
def apply(self, group):
indices = []
sel = self.sel.apply(group)
if len(sel) == 0:
return group[[]]
box = self.validate_dimensions(group.dimensions)
periodic = box is not None
ref = sel.center_of_geometry().reshape(1, 3).astype(np.float32)
Expand All @@ -378,6 +381,8 @@ def __init__(self, parser, tokens):
def apply(self, group):
indices = []
sel = self.sel.apply(group)
if len(sel) == 0:
return group[[]]
box = self.validate_dimensions(group.dimensions)
periodic = box is not None
ref = sel.center_of_geometry().reshape(1, 3).astype(np.float32)
Expand All @@ -394,7 +399,8 @@ class CylindricalSelection(Selection):
@return_empty_on_apply
def apply(self, group):
sel = self.sel.apply(group)

if len(sel) == 0:
return group[[]]
# Calculate vectors between point of interest and our group
vecs = group.positions - sel.center_of_geometry()

Expand Down
1 change: 1 addition & 0 deletions package/MDAnalysis/transformations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ def wrapped(ts):
from .positionaveraging import PositionAverager
from .fit import fit_translation, fit_rot_trans
from .wrap import wrap, unwrap
from .boxdimensions import set_dimensions
87 changes: 87 additions & 0 deletions package/MDAnalysis/transformations/boxdimensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
# (see the file AUTHORS for the full list of names)
#
# Released under the GNU Public Licence, v2 or any higher version
#
# Please cite your use of MDAnalysis in published work:
#
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
# doi: 10.25080/majora-629e541a-00e
#
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#

"""\
Set box dimensions --- :mod:`MDAnalysis.transformations.boxdimensions`
=======================================================================
Set dimensions of the simulation box to a constant vector across all timesteps.
.. autoclass:: set_dimensions
"""
import numpy as np


class set_dimensions:
"""
Set simulation box dimensions.
Timestep dimensions are modified in place.
Example
-------
e.g. set simulation box dimensions to a vector containing unit cell
dimensions [*a*, *b*, *c*, *alpha*, *beta*, *gamma*], lengths *a*,
*b*, *c* are in the MDAnalysis length unit (Å), and angles are in degrees.
.. code-block:: python
dim = [2, 2, 2, 90, 90, 90]
transform = mda.transformations.boxdimensions.set_dimensions(dim)
u.trajectory.add_transformations(transform)
Parameters
----------
dimensions: iterable of floats
vector that contains unit cell lengths and angles.
Expected shapes are (6, 0) or (1, 6)
Returns
-------
:class:`~MDAnalysis.coordinates.base.Timestep` object
"""

def __init__(self, dimensions):
self.dimensions = dimensions

try:
self.dimensions = np.asarray(self.dimensions, np.float32)
except ValueError:
errmsg = (f'{self.dimensions} cannot be converted into '
'np.float32 numpy.ndarray')
raise ValueError(errmsg)
try:
self.dimensions = self.dimensions.reshape(6, )
except ValueError:
errmsg = (f'{self.dimensions} array does not have valid box '
'dimension shape.\nSimulation box dimensions are '
'given by an float array of shape (6, ), '
' containing 3 lengths and 3 angles: '
'[a, b, c, alpha, beta, gamma]')
raise ValueError(errmsg)

def __call__(self, ts):
ts.dimensions = self.dimensions
return ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ Currently implemented transformations
./transformations/positionaveraging
./transformations/fit
./transformations/wrap
./transformations/boxdimensions

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. automodule:: MDAnalysis.transformations.boxdimensions
12 changes: 11 additions & 1 deletion testsuite/MDAnalysisTests/analysis/test_helix_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
from __future__ import absolute_import, division
import re

import numpy as np
Expand Down Expand Up @@ -397,6 +396,11 @@ def test_universe_from_origins(self, helanal):
assert len(u.atoms) == len(helanal.atomgroups[0])-2
assert len(u.trajectory) == 70

def test_universe_from_origins_except(self, psf_ca):
ha = hel.HELANAL(psf_ca, select='resnum 161-187')
with pytest.raises(ValueError, match=r'before universe_from_origins'):
u = ha.universe_from_origins()

def test_multiple_atoms_per_residues(self):
u = mda.Universe(XYZ)
with pytest.warns(UserWarning) as rec:
Expand Down Expand Up @@ -430,6 +434,12 @@ def test_residue_gaps_no_split(self, psf_ca):
assert 'has gaps in the residues' in warnmsg
assert 'Splitting into' not in warnmsg

def test_len_groups_short(self, psf_ca):
sel = 'resnum 161-168'
with pytest.warns(UserWarning, match='Fewer than 9 atoms found'):
ha = hel.HELANAL(psf_ca, select=sel)
assert len(ha.atomgroups) < 9

@pytest.mark.parametrize('ref_axis,screw_angles', [
# input vectors zigzag between [-1, 0, 0] and [1, 0, 0]
# global axis is z-axis
Expand Down
16 changes: 16 additions & 0 deletions testsuite/MDAnalysisTests/core/test_atomselections.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ def test_cylayer(self, universe, selstr):
sel = universe.select_atoms(selstr)
assert_equal(len(sel), 88)

def test_empty_cylayer(self, universe):
empty = universe.select_atoms('cylayer 4.0 6.0 10 -10 name NOT_A_NAME')
assert_equal(len(empty), 0)

@pytest.mark.parametrize('selstr', [
'cyzone 6.0 10 -10 bynum 1281',
'cyzone 6.0 10 -10 index 1280'
Expand All @@ -218,6 +222,10 @@ def test_cyzone(self, universe, selstr):
sel = universe.select_atoms(selstr)
assert_equal(len(sel), 166)

def test_empty_cyzone(self, universe):
empty = universe.select_atoms('cyzone 6.0 10 -10 name NOT_A_NAME')
assert_equal(len(empty), 0)

def test_point(self, universe):
ag = universe.select_atoms('point 5.0 5.0 5.0 3.5')

Expand Down Expand Up @@ -770,6 +778,10 @@ def test_sphlayer(self, u):

assert idx == set(ag.indices)

def test_empty_sphlayer(self, u):
empty = u.select_atoms('sphlayer 2.4 6.0 name NOT_A_NAME')
assert len(empty) == 0

def test_sphzone(self, u):
r1 = u.select_atoms('resid 1')
cog = r1.center_of_geometry().reshape(1, 3)
Expand All @@ -781,6 +793,10 @@ def test_sphzone(self, u):

assert idx == set(ag.indices)

def test_empty_sphzone(self, u):
empty = u.select_atoms('sphzone 5.0 name NOT_A_NAME')
assert len(empty) == 0

def test_point_1(self, u):
# The example selection
ag = u.select_atoms('point 5.0 5.0 5.0 3.5')
Expand Down
Loading

0 comments on commit 759e9ee

Please sign in to comment.