Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mda dependency #63

Merged
merged 6 commits into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
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='[email protected]',
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/MDAnalysis/mdanalysis/blob/release-0.14.0/package/MDAnalysis/core/AtomGroup.py#L1397

I think you can just switch to only the .resnums = resnums branch here, it was supported in 0.14

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we want to get rid of the storage of resnums here. The feature is hidden in MDS at the moment because we definitely won't be supporting it in the future, but it was really useful and important to work I was currently doing. With the new topology system in MDA and usage of persistent topologies we can completely eliminate this soon.

Thanks for this, @kain88-de. We keep it for now.

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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