|
|
7eacfb6 |
diff -up MDAnalysis-0.16.2/MDAnalysisTests-0.16.2/MDAnalysisTests/analysis/test_encore.py.skip-32bit MDAnalysis-0.16.2/MDAnalysisTests-0.16.2/MDAnalysisTests/analysis/test_encore.py
|
|
|
7eacfb6 |
--- MDAnalysis-0.16.2/MDAnalysisTests-0.16.2/MDAnalysisTests/analysis/test_encore.py.skip-32bit 2017-06-30 14:14:37.802409132 +0200
|
|
|
7eacfb6 |
+++ MDAnalysis-0.16.2/MDAnalysisTests-0.16.2/MDAnalysisTests/analysis/test_encore.py 2017-06-30 14:17:13.309229660 +0200
|
|
|
7eacfb6 |
@@ -283,21 +283,6 @@ inconsistent results")
|
|
|
a813845 |
assert_almost_equal(result_value, expected_value, decimal=-3,
|
|
|
a813845 |
err_msg="Unexpected value for Harmonic Ensemble Similarity: {0:f}. Expected {1:f}.".format(result_value, expected_value))
|
|
|
a813845 |
|
|
|
a813845 |
- def test_ces_to_self(self):
|
|
|
a813845 |
- results, details = \
|
|
|
a813845 |
- encore.ces([self.ens1, self.ens1],
|
|
|
a813845 |
- clustering_method=encore.AffinityPropagationNative(preference = -3.0))
|
|
|
a813845 |
- result_value = results[0,1]
|
|
|
a813845 |
- expected_value = 0.
|
|
|
a813845 |
- assert_almost_equal(result_value, expected_value,
|
|
|
a813845 |
- err_msg="ClusteringEnsemble Similarity to itself not zero: {0:f}".format(result_value))
|
|
|
7eacfb6 |
-
|
|
|
a813845 |
- def test_ces(self):
|
|
|
a813845 |
- results, details = encore.ces([self.ens1, self.ens2])
|
|
|
a813845 |
- result_value = results[0,1]
|
|
|
a813845 |
- expected_value = 0.51
|
|
|
a813845 |
- assert_almost_equal(result_value, expected_value, decimal=2,
|
|
|
a813845 |
- err_msg="Unexpected value for Cluster Ensemble Similarity: {0:f}. Expected {1:f}.".format(result_value, expected_value))
|
|
|
a813845 |
|
|
|
7eacfb6 |
def test_dres_to_self(self):
|
|
|
7eacfb6 |
results, details = encore.dres([self.ens1, self.ens1])
|
|
|
7eacfb6 |
@@ -324,13 +309,6 @@ inconsistent results")
|
|
|
a813845 |
assert_almost_equal(result_value, expected_value, decimal=1,
|
|
|
a813845 |
err_msg="Unexpected value for Dim. reduction Ensemble Similarity: {0:f}. Expected {1:f}.".format(result_value, expected_value))
|
|
|
a813845 |
|
|
|
a813845 |
- def test_ces_convergence(self):
|
|
|
a813845 |
- expected_values = [0.3443593, 0.1941854, 0.06857104, 0.]
|
|
|
a813845 |
- results = encore.ces_convergence(self.ens1, 5)
|
|
|
a813845 |
- print (results)
|
|
|
a813845 |
- for i,ev in enumerate(expected_values):
|
|
|
a813845 |
- assert_almost_equal(ev, results[i], decimal=2,
|
|
|
a813845 |
- err_msg="Unexpected value for Clustering Ensemble similarity in convergence estimation")
|
|
|
a813845 |
|
|
|
7eacfb6 |
def test_dres_convergence(self):
|
|
|
7eacfb6 |
expected_values = [ 0.3, 0.]
|
|
|
7eacfb6 |
@@ -351,44 +329,6 @@ inconsistent results")
|
|
|
a813845 |
assert_almost_equal(stdev, expected_stdev, decimal=-2,
|
|
|
a813845 |
err_msg="Unexpected standard daviation for bootstrapped samples in Harmonic Ensemble imilarity")
|
|
|
a813845 |
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_ces_error_estimation(self):
|
|
|
a813845 |
- expected_average = 0.03
|
|
|
a813845 |
- expected_stdev = 0.31
|
|
|
a813845 |
- averages, stdevs = encore.ces([self.ens1, self.ens1],
|
|
|
a813845 |
- estimate_error = True,
|
|
|
a813845 |
- bootstrapping_samples=10,
|
|
|
a813845 |
- clustering_method=encore.AffinityPropagationNative(preference=-2.0),
|
|
|
a813845 |
- selection="name CA and resnum 1-10")
|
|
|
a813845 |
- average = averages[0,1]
|
|
|
a813845 |
- stdev = stdevs[0,1]
|
|
|
7eacfb6 |
-
|
|
|
a813845 |
- assert_almost_equal(average, expected_average, decimal=1,
|
|
|
a813845 |
- err_msg="Unexpected average value for bootstrapped samples in Clustering Ensemble similarity")
|
|
|
a813845 |
- assert_almost_equal(stdev, expected_stdev, decimal=0,
|
|
|
a813845 |
- err_msg="Unexpected standard daviation for bootstrapped samples in Clustering Ensemble similarity")
|
|
|
7eacfb6 |
-
|
|
|
a813845 |
- @dec.skipif(module_not_found('sklearn'),
|
|
|
a813845 |
- "Test skipped because sklearn is not available.")
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_ces_error_estimation_ensemble_bootstrap(self):
|
|
|
a813845 |
- # Error estimation using a method that does not take a distance
|
|
|
a813845 |
- # matrix as input, and therefore relies on bootstrapping the ensembles
|
|
|
a813845 |
- # instead
|
|
|
a813845 |
- expected_average = 0.03
|
|
|
a813845 |
- expected_stdev = 0.02
|
|
|
a813845 |
- averages, stdevs = encore.ces([self.ens1, self.ens1],
|
|
|
a813845 |
- estimate_error = True,
|
|
|
a813845 |
- bootstrapping_samples=10,
|
|
|
a813845 |
- clustering_method=encore.KMeans(n_clusters=2),
|
|
|
a813845 |
- selection="name CA and resnum 1-10")
|
|
|
a813845 |
- average = averages[0,1]
|
|
|
a813845 |
- stdev = stdevs[0,1]
|
|
|
a813845 |
-
|
|
|
a813845 |
- assert_almost_equal(average, expected_average, decimal=1,
|
|
|
a813845 |
- err_msg="Unexpected average value for bootstrapped samples in Clustering Ensemble similarity")
|
|
|
a813845 |
- assert_almost_equal(stdev, expected_stdev, decimal=1,
|
|
|
a813845 |
- err_msg="Unexpected standard daviation for bootstrapped samples in Clustering Ensemble similarity")
|
|
|
a813845 |
|
|
|
a813845 |
@dec.slow
|
|
|
7eacfb6 |
def test_dres_error_estimation(self):
|
|
|
7eacfb6 |
@@ -454,38 +394,6 @@ class TestEncoreClustering(TestCase):
|
|
|
a813845 |
del cls.ens1_template
|
|
|
a813845 |
del cls.ens2_template
|
|
|
a813845 |
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_clustering_one_ensemble(self):
|
|
|
a813845 |
- cluster_collection = encore.cluster(self.ens1)
|
|
|
a813845 |
- expected_value = 7
|
|
|
a813845 |
- assert_equal(len(cluster_collection), expected_value,
|
|
|
a813845 |
- err_msg="Unexpected results: {0}".format(cluster_collection))
|
|
|
a813845 |
-
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_clustering_two_ensembles(self):
|
|
|
a813845 |
- cluster_collection = encore.cluster([self.ens1, self.ens2])
|
|
|
a813845 |
- expected_value = 14
|
|
|
a813845 |
- assert_equal(len(cluster_collection), expected_value,
|
|
|
a813845 |
- err_msg="Unexpected results: {0}".format(cluster_collection))
|
|
|
a813845 |
-
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_clustering_two_methods(self):
|
|
|
a813845 |
- cluster_collection = encore.cluster(
|
|
|
a813845 |
- [self.ens1],
|
|
|
a813845 |
- method=[encore.AffinityPropagationNative(),
|
|
|
a813845 |
- encore.AffinityPropagationNative()])
|
|
|
a813845 |
- assert_equal(len(cluster_collection[0]), len(cluster_collection[1]),
|
|
|
a813845 |
- err_msg="Unexpected result: {0}".format(cluster_collection))
|
|
|
a813845 |
-
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- def test_clustering_AffinityPropagationNative_direct(self):
|
|
|
a813845 |
- method = encore.AffinityPropagationNative()
|
|
|
a813845 |
- distance_matrix = encore.get_distance_matrix(self.ens1)
|
|
|
a813845 |
- cluster_assignment, details = method(distance_matrix)
|
|
|
a813845 |
- expected_value = 7
|
|
|
a813845 |
- assert_equal(len(set(cluster_assignment)), expected_value,
|
|
|
a813845 |
- err_msg="Unexpected result: {0}".format(
|
|
|
a813845 |
- cluster_assignment))
|
|
|
a813845 |
|
|
|
a813845 |
@dec.slow
|
|
|
a813845 |
@dec.skipif(module_not_found('sklearn'),
|
|
|
7eacfb6 |
@@ -549,29 +457,7 @@ class TestEncoreClustering(TestCase):
|
|
|
a813845 |
assert_equal(len(cluster_collection), 10,
|
|
|
a813845 |
err_msg="Unexpected result: {0}".format(cluster_collection))
|
|
|
a813845 |
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- @dec.skipif(module_not_found('sklearn'),
|
|
|
a813845 |
- "Test skipped because sklearn is not available.")
|
|
|
a813845 |
- def test_clustering_two_methods_one_w_no_distance_matrix(self):
|
|
|
a813845 |
- cluster_collection = encore.cluster(
|
|
|
a813845 |
- [self.ens1],
|
|
|
a813845 |
- method=[encore.KMeans(17),
|
|
|
a813845 |
- encore.AffinityPropagationNative()])
|
|
|
a813845 |
- print(cluster_collection)
|
|
|
a813845 |
- assert_equal(len(cluster_collection[0]), len(cluster_collection[0]),
|
|
|
a813845 |
- err_msg="Unexpected result: {0}".format(cluster_collection))
|
|
|
a813845 |
|
|
|
a813845 |
- @dec.slow
|
|
|
a813845 |
- @dec.skipif(module_not_found('sklearn'),
|
|
|
a813845 |
- "Test skipped because sklearn is not available.")
|
|
|
a813845 |
- def test_sklearn_affinity_propagation(self):
|
|
|
a813845 |
- cc1 = encore.cluster([self.ens1])
|
|
|
a813845 |
- cc2 = encore.cluster([self.ens1],
|
|
|
a813845 |
- method=encore.AffinityPropagation())
|
|
|
a813845 |
- assert_equal(len(cc1), len(cc2),
|
|
|
a813845 |
- err_msg="Native and sklearn implementations of affinity "
|
|
|
a813845 |
- "propagation don't agree: mismatch in number of "
|
|
|
a813845 |
- "clusters: {0} {1}".format(len(cc1), len(cc2)))
|
|
|
a813845 |
|
|
|
a813845 |
|
|
|
a813845 |
|
|
|
7eacfb6 |
@@ -662,15 +548,6 @@ class TestEncoreClusteringSklearn(TestCa
|
|
|
a813845 |
for j in range(i,dimension):
|
|
|
a813845 |
self.distance_matrix[i, j] = distances[i,j]
|
|
|
a813845 |
|
|
|
a813845 |
- def test_one(self):
|
|
|
a813845 |
- preference = -float(np.median(self.distance_matrix.as_array()) * 10.)
|
|
|
a813845 |
- clustering_method = encore.AffinityPropagationNative(preference=preference)
|
|
|
a813845 |
- ccs = encore.cluster(None,
|
|
|
a813845 |
- distance_matrix=self.distance_matrix,
|
|
|
a813845 |
- method=clustering_method)
|
|
|
a813845 |
- assert_equal(self.n_clusters, len(ccs),
|
|
|
a813845 |
- err_msg="Basic clustering test failed to give the right"
|
|
|
a813845 |
- "number of clusters: {0} vs {1}".format(self.n_clusters, len(ccs)))
|
|
|
a813845 |
|
|
|
a813845 |
|
|
|
a813845 |
class TestEncoreDimensionalityReduction(TestCase):
|