Esempio n. 1
0
    def test_subset_lipids(self, universe):

        neighbours = Neighbours(universe, lipid_sel="name C", cutoff=10)
        neighbours.run()

        # it's a hexagonal lattice, but each hexagon is irregular (two sides longer than the other 4)
        # with cutoff=10, every lipid should have 2 neighbours
        reference = {
            'n_frames':
            1,
            'n_residues':
            50,
            'n_neighbours':
            np.array([
                0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0,
                0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0,
                1, 0, 1, 0, 0, 1, 0, 1
            ])
        }

        assert neighbours.neighbours.shape[0] == (reference['n_frames'])
        assert neighbours.neighbours[0].shape == (reference['n_residues'],
                                                  reference['n_residues'])
        assert_array_equal(np.sum(neighbours.neighbours[0].toarray(), axis=0),
                           reference['n_neighbours'])
Esempio n. 2
0
    def test_run_method_not_called(self, universe):

        neighbours = Neighbours(universe=universe,
                                lipid_sel='name L C',
                                cutoff=12.0)

        match = ".neighbours attribute is None: use .run\(\) before calling .largest_cluster\(\)"  # noqa:W605
        with pytest.raises(NoDataError, match=match):
            neighbours.largest_cluster()
Esempio n. 3
0
    def test_neighbours_cutoff10(self, universe):

        neighbours = Neighbours(universe, **self.kwargs, cutoff=10)
        neighbours.run()

        # it's a hexagonal lattice, but each hexagon is irregular (two sides longer than the other 4)
        # with cutoff=10, every lipid should have 2 neighbours
        reference = {
            'n_residues': 100,  # there are 200 atoms but 100 lipids in total
            'n_neighbours': 2,
        }

        assert neighbours.neighbours.shape == (reference['n_residues'],
                                               reference['n_residues'])
        assert (np.sum(neighbours.neighbours.toarray(),
                       axis=0) == reference['n_neighbours']).all()
Esempio n. 4
0
    def test_neighbours_cutoff12(self, universe):

        neighbours = Neighbours(universe, **self.kwargs, cutoff=12)
        neighbours.run()

        # it's a hexagonal lattice
        # with cutoff=12, every lipid should have 6 neighbours
        reference = {
            'n_residues': 100,  # there are 200 atoms but 100 lipids in total
            'n_neighbours': 6,
        }

        assert neighbours.neighbours.shape == (reference['n_residues'],
                                               reference['n_residues'])
        assert (np.sum(neighbours.neighbours.toarray(),
                       axis=0) == reference['n_neighbours']).all()
Esempio n. 5
0
    def test_Exceptions(self, universe):

        match = "'cutoff' must be greater than 0"
        with pytest.raises(ValueError, match=match):
            Neighbours(universe=universe, lipid_sel="name L C", cutoff=-1)
Esempio n. 6
0
 def neighbours(self, universe):
     neighbours = Neighbours(universe, **self.kwargs)
     neighbours.run()
     return neighbours