Skip to content

Commit

Permalink
Merge pull request #63 from datreant/update-mda-dependency
Browse files Browse the repository at this point in the history
Update mda dependency
  • Loading branch information
dotsdl committed Nov 30, 2016
2 parents 98f3db0 + d8b413c commit 452a420
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 39 deletions.
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -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=[
Expand All @@ -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',
],
)
)
3 changes: 0 additions & 3 deletions src/mdsynthesis/filesystem.py
Expand Up @@ -3,9 +3,6 @@
"""
import os
import glob

from datreant.core import Treant, Group


class Universehound(object):
Expand Down
11 changes: 7 additions & 4 deletions src/mdsynthesis/limbs.py
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
35 changes: 16 additions & 19 deletions src/mdsynthesis/tests/test_treants.py
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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.
Expand All @@ -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
13 changes: 2 additions & 11 deletions src/mdsynthesis/treants.py
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 452a420

Please sign in to comment.