/usr/lib/python2.7/dist-packages/csb/test/cases/statistics/mixtures.py is in python-csb 1.2.3+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | from numpy import array, linspace
from csb import test
from csb.bio.io.wwpdb import LegacyStructureParser
from csb.statistics import mixtures
@test.functional
class TestMixtures(test.Case):
w_ref_segments = array([
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2])
w_ref_conformers = array([2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1])
def _ake_ensemble_coords(self):
pdbfile = self.config.getTestFile('ake-xray-ensemble-ca.pdb')
ensemble = LegacyStructureParser(pdbfile).parse_models()
X = array([model.get_coordinates(['CA'], True) for model in ensemble])
self.assertEqual(X.shape, (16, 211, 3))
self._ake_ensemble_coords = lambda: X
return X
def testSegmentMixture(self):
self._testMixture(mixtures.SegmentMixture, self.w_ref_segments)
def testConformerMixture(self):
self._testMixture(mixtures.ConformerMixture, self.w_ref_conformers, 14./16.)
def _testMixture(self, cls, w_ref, min_overlap=0.9, repeats=5):
X = self._ake_ensemble_coords()
K = len(set(w_ref))
# non-randomized heuristic with BIC
m = cls.new(X)
overlap = m.overlap(w_ref)
self.assertTrue(overlap >= min_overlap, 'mixture not reproduced with heuristic')
# annealing (randomized initialization)
m = cls(X, K, False)
for _ in range(repeats):
m.randomize_scales()
m.anneal(linspace(2.0, 0.1, 10))
overlap = m.overlap(w_ref)
if overlap >= min_overlap:
break
else:
self.assertTrue(False, 'mixture not reproduced with annealing')
if __name__ == '__main__':
test.Console()
# vi:expandtab:smarttab
|