def test_TG_without_bondclass(self):
        ag = self.universe.atoms

        tg = TopologyGroup.from_indices([(0, 1), (1, 2), (2, 3)], ag)
        assert_(len(tg) == 3)
        assert_(type(tg[0]) == Bond)

        tg = TopologyGroup.from_indices([(0, 1, 2), (1, 2, 3), (2, 3, 4)], ag)
        assert_(len(tg) == 3)
        assert_(type(tg[0]) == Angle)

        tg = TopologyGroup.from_indices([(0, 1, 2, 3), (1, 2, 3, 4)], ag)
        assert_(len(tg) == 2)
        assert_(type(tg[0]) == Dihedral)
    def test_TG_without_bondclass(self):
        ag = self.universe.atoms

        tg = TopologyGroup.from_indices([(0, 1), (1, 2), (2, 3)], ag)
        assert_(len(tg) == 3)
        assert_(type(tg[0]) == Bond)

        tg = TopologyGroup.from_indices([(0, 1, 2), (1, 2, 3), (2, 3, 4)],
                                        ag)
        assert_(len(tg) == 3)
        assert_(type(tg[0]) == Angle)

        tg = TopologyGroup.from_indices([(0, 1, 2, 3), (1, 2, 3, 4)],
                                        ag)
        assert_(len(tg) == 2)
        assert_(type(tg[0]) == Dihedral)
    def test_from_indices_nonglobal_idx(self):
        idx = [(0, 1), (4, 5)]

        ag = self.universe.atoms[100:]

        tg = TopologyGroup.from_indices(idx, ag)

        b1 = self.universe.atoms[[100, 101]].bond
        b2 = self.universe.atoms[[104, 105]].bond

        assert_(b1 in tg)
        assert_(b2 in tg)
    def test_from_indices_nonglobal_idx(self):
        idx = [(0, 1), (4, 5)]

        ag = self.universe.atoms[100:]

        tg = TopologyGroup.from_indices(idx, ag)

        b1 = self.universe.atoms[[100, 101]].bond
        b2 = self.universe.atoms[[104, 105]].bond

        assert_(b1 in tg)
        assert_(b2 in tg)
    def test_TG_indices_creation(self):
        """Create a TG from indices"""
        bonds = [(0, 1), (1, 2)]

        tg = TopologyGroup.from_indices(bonds, self.universe.atoms,
                                        bondclass=Bond)

        assert_equal(len(tg), 2)
        b1 = self.universe.atoms[[0, 1]].bond
        b2 = self.universe.atoms[[1, 2]].bond
        assert_(b1 in tg)
        assert_(b2 in tg)
        assert_equal(bonds, tg.to_indices())
    def test_TG_from_indices_roundtrip(self):
        """Round trip check of dumping indices then recreating"""
        tg = self.universe.bonds[:10]
        idx = tg.to_indices()

        tg2 = TopologyGroup.from_indices(idx, self.universe.atoms,
                                         bondclass=Bond)

        # This doesn't work as it uses set operation and .from_indices
        # has created new Bond instances
        # assert_equal(tg, tg2)
        # instead...
        assert_equal(len(tg), len(tg2))
        assert_equal(tg.to_indices(), tg2.to_indices())
    def test_TG_indices_creation(self):
        """Create a TG from indices"""
        bonds = [(0, 1), (1, 2)]

        tg = TopologyGroup.from_indices(bonds,
                                        self.universe.atoms,
                                        bondclass=Bond)

        assert_equal(len(tg), 2)
        b1 = self.universe.atoms[[0, 1]].bond
        b2 = self.universe.atoms[[1, 2]].bond
        assert_(b1 in tg)
        assert_(b2 in tg)
        assert_equal(bonds, tg.to_indices())
    def test_TG_from_indices_roundtrip(self):
        """Round trip check of dumping indices then recreating"""
        tg = self.universe.bonds[:10]
        idx = tg.to_indices()

        tg2 = TopologyGroup.from_indices(idx,
                                         self.universe.atoms,
                                         bondclass=Bond)

        # This doesn't work as it uses set operation and .from_indices
        # has created new Bond instances
        # assert_equal(tg, tg2)
        # instead...
        assert_equal(len(tg), len(tg2))
        assert_equal(tg.to_indices(), tg2.to_indices())
 def test_force_bondclass(self):
     # Make a TG of improper dihedral
     tg = TopologyGroup.from_indices([(0, 1, 2, 3), (2, 3, 4, 6)],
                                     self.universe.atoms,
                                     bondclass=ImproperDihedral)
     assert_(type(tg[0]) == ImproperDihedral)
Exemple #10
0
 def _load_bonds(self):
     # Load some bonds into Universe, not required for all tests
     bondlist = [(0, 1), (1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (4, 7)]
     tg = TopologyGroup.from_indices(bondlist, self.u.atoms, bondclass=Bond)
     self.u.bonds = tg
Exemple #11
0
 def _load_bonds(self):
     # Load some bonds into Universe, not required for all tests
     bondlist = [(0, 1), (1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (4, 7)]
     tg = TopologyGroup.from_indices(bondlist, self.u.atoms, bondclass=Bond)
     self.u.bonds = tg
Exemple #12
0
 def test_force_bondclass(self):
     # Make a TG of improper dihedral
     tg = TopologyGroup.from_indices([(0, 1, 2, 3), (2, 3, 4, 6)],
                                     self.universe.atoms,
                                     bondclass=ImproperDihedral)
     assert_(type(tg[0]) == ImproperDihedral)