diff --git a/setup.py b/setup.py index 780874b..71e8d6f 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup(name='mdsynthesis', version='0.6.2-dev', description='a persistence engine for molecular dynamics data', - author='David Dotson', + author='David Dotson', author_email='dotsdl@gmail.com', url='http://mdsynthesis.readthedocs.org/', classifiers=[ @@ -32,6 +32,7 @@ install_requires=[ 'datreant.core>=0.6.0', 'datreant.data>=0.6.0', + # TODO: update dependency to 0.16.0 once it's released 'MDAnalysis>=0.14.0', ], - ) + ) diff --git a/src/mdsynthesis/filesystem.py b/src/mdsynthesis/filesystem.py index 896976d..0cef49c 100644 --- a/src/mdsynthesis/filesystem.py +++ b/src/mdsynthesis/filesystem.py @@ -3,9 +3,6 @@ """ import os -import glob - -from datreant.core import Treant, Group class Universehound(object): diff --git a/src/mdsynthesis/limbs.py b/src/mdsynthesis/limbs.py index a9b3912..551fc4b 100644 --- a/src/mdsynthesis/limbs.py +++ b/src/mdsynthesis/limbs.py @@ -17,7 +17,6 @@ from datreant.core import Leaf from datreant.core.limbs import Limb from MDAnalysis import Universe -from MDAnalysis.core.AtomGroup import AtomGroup from .filesystem import Universehound @@ -216,7 +215,11 @@ def _apply_resnums(self): resnums = None if resnums: - self._treant._universe.residues.set_resnums(np.array(resnums)) + # Compatibility for MDAnalysis pre 0.16.0 + try: + self._treant._universe.residues.resnums = resnums + except AttributeError: + self._treant._universe.residues.set_resnum(resnums) @deprecate(message="resnum storage is deprecated") def _set_resnums(self, resnums): @@ -240,7 +243,7 @@ def _set_resnums(self, resnums): if resnums is None: simdict['resnums'] = None else: - simdict['resnums'] = list(resnums) + simdict['resnums'] = np.asarray(resnums).tolist() if self._treant._universe: self._apply_resnums() @@ -407,7 +410,7 @@ def add(self, handle, *selection): if isinstance(sel, np.ndarray): outsel = sel.tolist() elif isinstance(sel, string_types): - outsel = sel + outsel = sel else: outsel = list() for sel in selection: diff --git a/src/mdsynthesis/tests/test_treants.py b/src/mdsynthesis/tests/test_treants.py index ad34dd0..12b0c57 100644 --- a/src/mdsynthesis/tests/test_treants.py +++ b/src/mdsynthesis/tests/test_treants.py @@ -3,11 +3,7 @@ """ import mdsynthesis as mds -import pandas as pd -import numpy as np import pytest -import os -import shutil import py from pkg_resources import parse_version @@ -101,12 +97,6 @@ def test_set_universe_with_kwargs(self, treant): with pytest.raises(ValueError): treant.universe = u2 - # check that we get a warning if a Universe didn't store its kwargs - u3 = mda.Universe(PDB, XTC, something_fake=True) - del u3._kwargs - with pytest.warns(UserWarning): - treant.universe = u3 - def test_add_univese_typeerror(self, treant): """Test checking of what is passed to setter""" with pytest.raises(TypeError): @@ -145,7 +135,11 @@ def test_set_resnums(self, treant): protein = treant.universe.select_atoms('protein') resids = protein.residues.resids - protein.residues.set_resnum(resids + 3) + # Compatibility for MDAnalysis pre 0.16.0 + try: + protein.residues.resnums = resids + 3 + except AttributeError: + protein.residues.set_resnum(resids + 3) treant.universedef._set_resnums(treant.universe.residues.resnums) @@ -154,8 +148,11 @@ def test_set_resnums(self, treant): protein = treant.universe.select_atoms('protein') assert (resids + 3 == protein.residues.resnums).all() - # test resetting of resnums - protein.residues.set_resnum(resids + 6) + # Compatibility for MDAnalysis pre 0.16.0 + try: + protein.residues.resnums = resids + 6 + except AttributeError: + protein.residues.set_resnum(resids + 6) assert (protein.residues.resnums == resids + 6).all() treant.universedef._set_resnums(treant.universe.residues.resnums) @@ -322,10 +319,10 @@ def sim(self, tmpdir, request): c.universedef.topology = GRO_t.strpath c.universedef.trajectory = XTC_t.strpath - py.path.local(c.abspath).chmod(0550, rec=True) + py.path.local(c.abspath).chmod(0o0550, rec=True) def fin(): - py.path.local(c.abspath).chmod(0770, rec=True) + py.path.local(c.abspath).chmod(0o0770, rec=True) request.addfinalizer(fin) @@ -340,13 +337,13 @@ def test_sim_moved_universe_access(self, sim, tmpdir): """Test that Sim can access Universe when read-only, especially when universe files have moved with it (stale paths). """ - py.path.local(sim.abspath).chmod(0770, rec=True) + py.path.local(sim.abspath).chmod(0o0770, rec=True) sim.location = tmpdir.mkdir('test').strpath - py.path.local(sim.abspath).chmod(0550, rec=True) + py.path.local(sim.abspath).chmod(0o0550, rec=True) assert isinstance(sim.universe, mda.Universe) - py.path.local(sim.abspath).chmod(0770, rec=True) + py.path.local(sim.abspath).chmod(0o0770, rec=True) def test_fresh_sim_readonly(self, sim): """Test that a read-only Sim can be initialized without issue. @@ -360,4 +357,4 @@ def test_fresh_sim_readonly(self, sim): # would be nice if it DIDN'T behave this way, but lazy loading keeps # Sim init cheaper with pytest.raises(KeyError): - len(s.atomselections) == 0 + s.atomselections diff --git a/src/mdsynthesis/treants.py b/src/mdsynthesis/treants.py index 7edfaca..2299a73 100644 --- a/src/mdsynthesis/treants.py +++ b/src/mdsynthesis/treants.py @@ -3,12 +3,10 @@ """ import warnings -import os -from six import string_types from MDAnalysis import Universe -from datreant.core import Treant, Leaf +from datreant.core import Treant from . import limbs from .backends import statefiles @@ -103,14 +101,7 @@ def universe(self, universe): traj = [] self.universedef._set_trajectory(traj) - - # try and store keyword arguments - try: - self.universedef.kwargs = universe.kwargs - except AttributeError: - warnings.warn("Universe did not keep keyword arguments; " - "cannot store keyword arguments for Universe.") - + self.universedef.kwargs = universe.kwargs # finally, just use this instance self._universe = universe