def test_Exceptions(self, universe):

        match = "midplane_sel is 'None' and midplane_cutoff "
        with pytest.raises(ValueError, match=match):
            AssignLeaflets(
                universe=universe,
                lipid_sel="name L",
                midplane_sel=None,
                midplane_cutoff=5,
            )

        match = "midplane_sel is 'name C' and midplane_cutoff "
        with pytest.raises(ValueError, match=match):
            AssignLeaflets(
                universe=universe,
                lipid_sel="name L C",
                midplane_sel="name C",
                midplane_cutoff=None,
            )

        match = "To assign molecules to the midplane, midplane_cutoff must"
        with pytest.raises(ValueError, match=match):
            AssignLeaflets(
                universe=universe,
                lipid_sel="name L C",
                midplane_sel="name C",
                midplane_cutoff=-10,
            )

        match = "midplane_sel contains atoms that are not present in molecules selected "
        with pytest.raises(ValueError, match=match):
            AssignLeaflets(universe=universe,
                           lipid_sel="name L",
                           midplane_sel="name C",
                           midplane_cutoff=10)
    def test_nbins4(self, universe):

        leaflets = AssignLeaflets(universe, n_bins=4, **self.kwargs)
        leaflets.run()

        reference = {
            'leaflets_present':
            [-1, 1],  # now (correctly) no midplane residues should be found
            'midplane_resnames':
            [],  # list or residues incorrectly identified as midplane
        }

        assert_array_equal(np.unique(leaflets.leaflets),
                           reference['leaflets_present'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resnames,
            reference['midplane_resnames'])  # noqa: E225
    def test_nbins1(self, universe):

        leaflets = AssignLeaflets(universe, n_bins=1, **self.kwargs)
        leaflets.run()

        reference = {
            'leaflets_present': [-1, 0, 1],
            'midplane_resnames': ["CHOL"] *
            6,  # list or residues incorrectly identified as midplane
        }

        assert_array_equal(np.unique(leaflets.leaflets),
                           reference['leaflets_present'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resnames,
            reference['midplane_resnames'])  # noqa: E225
        assert 'LIPID' not in universe.residues[leaflets.leaflets[:, 0] ==
                                                0].resnames  # noqa: E225
    def test_nbins4_midplane(self, universe):

        leaflets = AssignLeaflets(universe, **self.kwargs)
        leaflets.run()

        reference = {
            'leaflets_present': [-1, 1],
            'midplane_resnames':
            [],  # only one of two atoms in CHOL78 is in the midplane, so the molecule is not assigned to the midplane
            'midplane_resids': []
        }

        assert_array_equal(np.unique(leaflets.leaflets),
                           reference['leaflets_present'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resnames,
            reference['midplane_resnames'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resids,
            reference['midplane_resids'])
    def test_nbins4_midplane(self, universe):

        leaflets = AssignLeaflets(universe, **self.kwargs)
        leaflets.run()

        reference = {
            'leaflets_present': [-1, 0, 1],
            'midplane_resnames':
            ["CHOL"
             ],  # list of residues resnames (correctly) identified as midplane
            'midplane_resids': [78]  # resid of midplane molecules
        }

        assert_array_equal(np.unique(leaflets.leaflets),
                           reference['leaflets_present'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resnames,
            reference['midplane_resnames'])
        assert_array_equal(
            universe.residues[leaflets.leaflets[:, 0] == 0].resids,
            reference['midplane_resids'])
 def leaflets(self, universe):
     leaflets = AssignLeaflets(universe, **self.kwargs)
     leaflets.run()
     return leaflets
Exemplo n.º 7
0
 def leaflets(self, universe):
     leaflets = AssignLeaflets(universe, lipid_sel="name L C")
     leaflets.run()
     return leaflets