Ejemplo n.º 1
0
    def psa(self, tmpdir):
        universe1 = mda.Universe(PSF, DCD)
        universe2 = mda.Universe(PSF, DCD2)
        universe_rev = mda.Universe(PSF, DCD)

        psa = PSA.PSAnalysis([universe1, universe2, universe_rev],
                             path_select='name CA',
                             targetdir=str(tmpdir))

        psa.generate_paths(align=True)
        psa.paths[-1] = psa.paths[-1][::-1, :, :]  # reverse third path
        return psa
Ejemplo n.º 2
0
    def test_save_nopaths(self, tmpdir):
        """Test case were save_paths is called without calcualted paths"""
        match_exp = "Paths have not been calculated yet"
        with pytest.raises(NoDataError, match=match_exp):
            universe1 = mda.Universe(PSF, DCD)
            universe2 = mda.Universe(PSF, DCD2)
            universe_rev = mda.Universe(PSF, DCD)

            psa = PSA.PSAnalysis([universe1, universe2, universe_rev],
                                 path_select='name CA',
                                 targetdir=str(tmpdir))
            psa.save_paths()
Ejemplo n.º 3
0
    def test_load(self, stored, tmpdir):
        """Test that the automatically saved files can be loaded"""
        # To allow for testing the store keyword, ignore fixture
        universe1 = mda.Universe(PSF, DCD)
        universe2 = mda.Universe(PSF, DCD2)
        universe_rev = mda.Universe(PSF, DCD)

        psa = PSA.PSAnalysis([universe1, universe2, universe_rev],
                              path_select='name CA',
                              targetdir=str(tmpdir))

        psa2 = PSA.PSAnalysis([universe1, universe2, universe_rev],
                              path_select='name CA',
                              targetdir=str(tmpdir))

        psa.generate_paths(align=True, store=stored)

        # Make copies to the existing data
        # Note: path names are set after save_paths has been called
        expected_paths = [p.copy() for p in psa.paths]

        if not stored:
            psa.save_paths()

        expected_path_names = psa.path_names[:]

        # Load data in the empty PSAnalysis object
        psa2.load()

        assert psa2.path_names == expected_path_names
        assert len(psa2.paths) == len(expected_paths)

        for ipath, (observed, expected) in enumerate(zip(psa2.paths,
                                                         expected_paths)):
            assert_almost_equal(observed, expected, decimal=6,
                                err_msg=("loaded path {} does not agree with "
                                         "input").format(ipath))
Ejemplo n.º 4
0
    def setUp(self):
        self.tmpdir = tempdir.TempDir()
        self.iu1 = np.triu_indices(3, k=1)
        self.universe1 = mda.Universe(PSF, DCD)
        self.universe2 = mda.Universe(PSF, DCD2)
        self.universe_rev = mda.Universe(PSF, DCD)
        self.universes = [self.universe1, self.universe2, self.universe_rev]
        self.psa = PSA.PSAnalysis(self.universes,
                                  path_select='name CA',
                                  targetdir=self.tmpdir.name)

        self.psa.generate_paths(align=True)
        self.psa.paths[-1] = self.psa.paths[-1][::-1,:,:] # reverse third path
        self._run()
        self._plot()
Ejemplo n.º 5
0
def pairwise_rmsds_traj(universes: List[mda.Universe], labels: List[str]):
    """Calculate pairwise RMSD for multiple trajectories using Hausdorff distance."""

    # Align trajectories because there seems to be a bug
    # in PSAnalysis.
    for k in universes[1:]:
        align.AlignTraj(k,
                        universes[0],
                        select=STANDARD_SELECTION,
                        in_memory=True)

    ps = psa.PSAnalysis(universes,
                        labels=labels,
                        reference=universes[0],
                        ref_frame=0,
                        select=STANDARD_SELECTION,
                        path_select=STANDARD_SELECTION)

    ps.generate_paths(align=False, save=False, weights='mass')
    ps.run(metric='hausdorff')
    return ps.D