Example #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'])
Example #2
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()
Example #3
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()
Example #4
0
 def neighbours(self, universe):
     neighbours = Neighbours(universe, **self.kwargs)
     neighbours.run()
     return neighbours