Skip to content

Commit

Permalink
reduce computation in encore
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxuanzhuang committed May 2, 2024
1 parent 97cb5f7 commit 05fd7f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ jobs:
displayName: 'Check installed packages'
- powershell: |
cd testsuite
$env:OPENBLAS_NUM_THREADS=1
$env:GOTO_NUM_THREADS=1
$env:OMP_NUM_THREADS=1
pytest MDAnalysisTests --disable-pytest-warnings -n auto --timeout=200 -rsx --cov=MDAnalysis
displayName: 'Run MDAnalysis Test Suite'
- script: |
Expand Down
20 changes: 10 additions & 10 deletions testsuite/MDAnalysisTests/analysis/test_encore.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
def function(x):
return x**2


class TestEncore(object):
@pytest.fixture(scope='class')
def ens1_template(self):
Expand Down Expand Up @@ -124,10 +125,10 @@ def test_triangular_matrix(self):
reason="Not yet supported on Windows.")
def test_parallel_calculation(self):

arguments = [tuple([i]) for i in np.arange(0,100)]
arguments = [tuple([i]) for i in np.arange(0,10)]

parallel_calculation = encore.utils.ParallelCalculation(function=function,
n_jobs=4,
n_jobs=2,
args=arguments)
results = parallel_calculation.run()

Expand All @@ -141,12 +142,12 @@ def test_rmsd_matrix_with_superimposition(self, ens1):
conf_dist_matrix = encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights='mass',
n_jobs=1)

reference = rms.RMSD(ens1, select="name CA")
reference = rms.RMSD(ens1, select="name CA and resnum 1:3")
reference.run()
err_msg = (
"Calculated RMSD values differ from "
Expand All @@ -158,24 +159,25 @@ def test_rmsd_matrix_with_superimposition_custom_weights(self, ens1):
conf_dist_matrix = encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights='mass',
n_jobs=1)

conf_dist_matrix_custom = encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights=(ens1.select_atoms('name CA').masses, ens1.select_atoms('name CA').masses),
weights=(ens1.select_atoms("name CA and resnum 1:3").masses,
ens1.select_atoms("name CA and resnum 1:3").masses),
n_jobs=1)

for i in range(conf_dist_matrix_custom.size):
assert_allclose(conf_dist_matrix_custom[0, i], conf_dist_matrix[0, i], rtol=0, atol=1.5e-7)

def test_rmsd_matrix_without_superimposition(self, ens1):
selection_string = "name CA"
selection_string = "name CA and resnum 1:3"
selection = ens1.select_atoms(selection_string)
reference_rmsd = []
coordinates = ens1.trajectory.timeseries(selection, order='fac')
Expand Down Expand Up @@ -678,8 +680,6 @@ def test_cluster_repr(self):
repr_message = "<Cluster with 1 elements, centroid=1, id=1>"
assert_equal(repr(cluster), repr_message)



class TestEncoreClusteringSklearn(object):
"""The tests in this class were duplicated from the affinity propagation
tests in scikit-learn"""
Expand Down

0 comments on commit 05fd7f2

Please sign in to comment.