Skip to content

Commit

Permalink
enable cross version compatibility for MDAnalysis
Browse files Browse the repository at this point in the history
  • Loading branch information
kain88-de committed Nov 8, 2016
1 parent e00120b commit 6f53c4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/mdsynthesis/limbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def _apply_resnums(self):
resnums = None

if resnums:
self._treant._universe.residues.resnums = 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 Down
13 changes: 10 additions & 3 deletions src/mdsynthesis/tests/test_treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ def test_set_resnums(self, treant):

protein = treant.universe.select_atoms('protein')
resids = protein.residues.resids
protein.residues.resnums = 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 @@ -144,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.resnums = 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

0 comments on commit 6f53c4f

Please sign in to comment.