Skip to content

Commit

Permalink
[coor/feat/util] _describe_atom returns chain index if two or more ch…
Browse files Browse the repository at this point in the history
…ains are present (markovmodel#823)
  • Loading branch information
gph82 authored and marscher committed Jun 7, 2016
1 parent ecd07bc commit a39eb67
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
5 changes: 4 additions & 1 deletion pyemma/coordinates/data/featurization/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def _describe_atom(topology, index):
:return:
"""
at = topology.atom(index)
return "%s %i %s %i" % (at.residue.name, at.residue.resSeq, at.name, at.index)
if topology.n_chains > 1:
return "%s %i %s %i %i" % (at.residue.name, at.residue.resSeq, at.name, at.index, at.residue.chain.index )
else:
return "%s %i %s %i" % (at.residue.name, at.residue.resSeq, at.name, at.index)


def _catch_unhashable(x):
Expand Down
42 changes: 37 additions & 5 deletions pyemma/coordinates/tests/test_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# from pyemma.coordinates.data import featurizer as ft
from pyemma.coordinates.data.featurization.featurizer import MDFeaturizer, CustomFeature
from pyemma.coordinates.data.featurization.util import _parse_pairwise_input
from pyemma.coordinates.data.featurization.util import _parse_pairwise_input, _describe_atom
from six.moves import range
import pkg_resources

Expand Down Expand Up @@ -63,10 +63,10 @@
ATOM 001 CA ASN A 01 1.0000 0.000 0.0000 1.00 0.000 C
ATOM 002 MW ACE A 02 2.0000 0.000 0.0000 1.00 0.000 X
ATOM 003 CA ASN A 03 3.0000 0.000 0.0000 1.00 0.000 C
ATOM 004 MW ACE A 04 4.0000 0.000 0.0000 1.00 0.000 X
ATOM 005 CA ASN A 05 5.0000 0.000 0.0000 1.00 0.000 C
ATOM 006 MW ACE A 06 6.0000 0.000 0.0000 1.00 0.000 X
ATOM 007 CA ASN A 07 7.0000 0.000 0.0000 1.00 0.000 C
ATOM 004 MW ACE B 04 4.0000 0.000 0.0000 1.00 0.000 X
ATOM 005 CA ASN B 05 5.0000 0.000 0.0000 1.00 0.000 C
ATOM 006 MW ACE B 06 6.0000 0.000 0.0000 1.00 0.000 X
ATOM 007 CA ASN B 07 7.0000 0.000 0.0000 1.00 0.000 C
"""

def verbose_assertion_minrmsd(ref_Y, test_Y, test_obj):
Expand Down Expand Up @@ -744,6 +744,38 @@ def test_two_redundants_overlap(self):
)))
assert np.allclose(dist_list, _parse_pairwise_input(group1, group2, self.feat._logger))

class TestUtils(unittest.TestCase):
@classmethod
def setUpClass(cls):
import tempfile
cls.bogus_geom_pdbfile = tempfile.mkstemp(suffix=".pdb")[1]
print(cls.bogus_geom_pdbfile)
with open(cls.bogus_geom_pdbfile, 'w') as fh:
fh.write(bogus_geom_pdbfile)
super(TestUtils, cls).setUpClass()


@classmethod
def tearDownClass(cls):
try:
os.unlink(cls.bogus_geom_pdbfile)
except EnvironmentError:
pass

super(TestUtils, cls).tearDownClass()

@classmethod
def setUp(self):
self.traj = mdtraj.load(self.bogus_geom_pdbfile)

def test_describe_atom(self):
str1 = _describe_atom(self.traj.topology, 0)
str2 = _describe_atom(self.traj.topology,self.traj.n_atoms-1)
assert len(str1.split()) >=4
assert len(str2.split()) >=4
assert str1.split()[-1] == '0'
assert str2.split()[-1] == '1'

class TestStaticMethods(unittest.TestCase):

def setUp(self):
Expand Down

0 comments on commit a39eb67

Please sign in to comment.