Example #1
0
 def test_work_in_atom(self):
     """
     Check if work in atom and work in residue keywords get the same cluster
     size distribution. Got to divide by number of atoms for this
     """
     SideClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
     SideClstr.cluster_analysis(
         cut_off=6.5,
         style="atom",
         measure="b2b",
         algorithm="static",
         work_in="Atom",
     )
     for main_sizes, side_sizes in zip(main_cluster_sizes,
                                       SideClstr.cluster_sizes):
         assert len(main_sizes) == approx(len(side_sizes))
         for main_cluster, side_cluster in zip(main_sizes, side_sizes):
             assert main_cluster == approx(side_cluster / 4)
Example #2
0
 def test_algorithm_static(self):
     """
     Check if static and dynamic keywords get the same cluster
     size distribution
     """
     SideClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
     SideClstr.cluster_analysis(
         cut_off=6.5,
         style="atom",
         measure="b2b",
         algorithm="static",
         work_in="Residue",
     )
     for main_sizes, side_sizes in zip(main_cluster_sizes,
                                       SideClstr.cluster_sizes):
         assert len(main_sizes) == approx(len(side_sizes))
         for main_cluster, side_cluster in zip(main_sizes, side_sizes):
             assert main_cluster == approx(side_cluster)
Example #3
0
 def test_measure_COM(self):
     """
     Check if measur distance by COM does result in the same cluster
     size distribution. Not really a good test as it physically
     does not need to result in the same cluster size distribution.
     Apparently it does for this trajectory tho.
     """
     SideClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
     SideClstr.cluster_analysis(
         cut_off=6.5,
         style="atom",
         measure="COM",
         algorithm="dynamic",
         work_in="Residue",
     )
     for main_sizes, side_sizes in zip(main_cluster_sizes,
                                       SideClstr.cluster_sizes):
         assert len(main_sizes) == approx(len(side_sizes))
         for main_cluster, side_cluster in zip(main_sizes, side_sizes):
             assert main_cluster == approx(side_cluster)
Example #4
0
 def test_style_molecule(self):
     """
     Check if style molecule gets the same result than style atom.
     Need to use different reference, which includes headgroups
     for style atom, as it actually makes a difference for the neighbour
     search.
     """
     SideClstr = ClusterEnsemble(tpr, traj, ["SDS"])
     SideClstr.cluster_analysis(
         cut_off=6.5,
         style="molecule",
         measure="b2b",
         algorithm="dynamic",
         work_in="Residue",
     )
     for main_sizes, side_sizes in zip(mol_cluster_sizes,
                                       SideClstr.cluster_sizes):
         assert len(main_sizes) == approx(len(side_sizes))
         for main_cluster, side_cluster in zip(main_sizes, side_sizes):
             assert main_cluster == approx(side_cluster)
Example #5
0
from re import L
import MDAnalysis as mda
from clustercode import ClusterEnsemble
from pytest import approx

# These files comprise the same trajectory but processed with different
# gmx trjconv -pbc options (cluster, atom and mol). The trajectory
# includes a large single micelles split across mutliple PBCs.
tcluster = "clustercode/tests/cluster/files/traj_pbc_problematic_cluster.xtc"
tatom = "clustercode/tests/cluster/files/traj_pbc_problematic_atom.xtc"
tpr = "clustercode/tests/cluster/files/topol_no_solv.tpr"

ClusterUniverse = ClusterEnsemble(tpr, tcluster, ["C1", "C2", "C3", "C4"])
AtomUniverse = ClusterEnsemble(tpr, tatom, ["C1", "C2", "C3", "C4"])

ClusterUniverse.cluster_analysis()
AtomUniverse.cluster_analysis()


class TestUnwrap:
    def test_unwrapping(self):
        """
        This test checks if gmx trjcvon -f ... -pbc cluster results in the
        same centre of geometry when applied to the example trajectory.
        Down to 0.005 Angstrom (pretty goood).
        """
        for c_clusters, a_clusters in zip(
            ClusterUniverse.cluster_list, AtomUniverse.cluster_list
        ):
            for c_cluster, a_cluster in zip(c_clusters, a_clusters):
                AtomUniverse.unwrap_cluster(a_cluster)
Example #6
0
from re import L
from click import style
from pytest import approx
from clustercode import ClusterEnsemble
import os

tpr = os.path.join("clustercode", "tests", "cluster", "files", "cg_agg.tpr")
traj = os.path.join("clustercode", "tests", "cluster", "files",
                    "traj_cg_agg.xtc")

MainClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
MainClstr.cluster_analysis(cut_off=6.5,
                           style="atom",
                           measure="b2b",
                           algorithm="dynamic",
                           work_in="Residue")

main_cluster_sizes = MainClstr.cluster_sizes

MolClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4", "SU"])
MolClstr.cluster_analysis(cut_off=6.5,
                          style="atom",
                          measure="b2b",
                          algorithm="dynamic",
                          work_in="Residue")

mol_cluster_sizes = MolClstr.cluster_sizes


class TestClustering:
    def test_generator(self):
Example #7
0
import MDAnalysis as mda
from clustercode import ClusterEnsemble
from pytest import approx
import pytest
import numpy as np

# The trajectory includes a large single micelles split across mutliple PBCs
# It was pretreated with gmx trjconv -pbc atom
tpr = "clustercode/tests/cluster/files/topol_no_solv.tpr"
traj = "clustercode/tests/cluster/files/traj_pbc_problematic_atom.xtc"
# traj = "clustercode/tests/cluster/files/traj_pbc_problematic_cluster.xtc"
clstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
AtomClstr = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])
clstr.cluster_analysis()
AtomClstr.cluster_analysis(work_in="Atom")

# gmx gyrate -f traj_pbc_problematic_cluster.xtc -s topol_no_solv.tpr -p yes
gmx_gyrate = [
    [3.28795, 1.86045, 2.97682, 3.04934],
    [3.22206, 1.86464, 2.9183, 2.96141],
    [3.20438, 1.89937, 2.8877, 2.93081],
    [3.17957, 1.90879, 2.83768, 2.91949],
    [3.17345, 1.86303, 2.87302, 2.90112],
    [3.19677, 1.83934, 2.91293, 2.92753],
]
gmx_principal = [
    [3.50891250, 8.983379375, 9.426435000],
    [3.52470625, 8.633655000, 8.890634375],
    [3.65722625, 8.453534375, 8.707842500],
    [3.69359125, 8.163197500, 8.640699375],
    [3.51862312, 8.367801875, 8.532266875],
Example #8
0
import pytest
import numpy as np
from clustercode import ClusterEnsemble

# The trajectory includes a large single micelles split across mutliple PBCs
# It was pretreated with gmx trjconv -pbc atom
traj = "clustercode/tests/cluster/files/traj_pbc_problematic_cluster.xtc"
tpr = "clustercode/tests/cluster/files/topol_no_solv.tpr"

uni = ClusterEnsemble(tpr, traj, ["C1", "C2", "C3", "C4"])

uni.cluster_analysis()


class TestDistributions:
    def test_distance_distribution(self):
        for clusters in uni.cluster_list:
            for cluster in clusters:
                distances = uni.distance_distribution(cluster,
                                                      "C1",
                                                      "C2",
                                                      unwrap=False)
                assert len(distances) == 382
                assert np.mean(distances) == pytest.approx(4.15, abs=0.025)

    def test_angle_distribution(self):
        for clusters in uni.cluster_list:
            for cluster in clusters:
                angles = uni.angle_distribution(cluster,
                                                "C1",
                                                "C2",