Beispiel #1
0
    def test_select_average(self, universe: md.Trajectory) -> None:
        """Test get_average_structure function using atom selection.

        GIVEN topology and trajectory filenames and an atom selection
        WHEN the get_average_structure function is called
        THEN the average coordinates are computed

        Parameters
        ----------
        universe : Trajectory
            Molecular dynamics trajectory
        """
        mask = "protein and name CA"
        atoms = universe.topology.select(mask)
        n_atoms = atoms.size

        average = utils.get_average_structure(
            TOPWW,
            [
                TRJWW,
            ],
            mask=mask,
        )
        assert average.xyz.shape == (1, n_atoms, 3)
        universe_average = universe.atom_slice(atoms).xyz.mean(axis=0)
        testing.assert_allclose(average.xyz[0], universe_average)
Beispiel #2
0
    def test_select_positions(self, universe: md.Trajectory,
                              n_frames: int) -> None:
        """Test get_positions function using atom selection.

        GIVEN topology and trajectory filenames and an atom selection
        WHEN the get_positions function is called
        THEN return a array of positions with shape (n_frames, n_atoms, 3)

        Parameters
        ----------
        universe : Trajectory
            Molecular dynamics trajectory
        n_frames : int
            Number of frames
        """
        mask = "protein and name CA"
        atoms = universe.topology.select(mask)
        n_atoms = atoms.size

        array = utils.get_positions(
            TOPWW,
            [
                TRJWW,
            ],
            mask=mask,
        )
        assert array.shape == (n_frames, n_atoms, 3)
        testing.assert_allclose(array[0],
                                universe.atom_slice(atoms).xyz[0] * 10)
        assert isinstance(array, np.ndarray)