def test_angle_tg_creation_notype(self, PSFDCD): vals = np.array([[0, 5, 10], [5, 10, 15]]) tg = TopologyGroup(vals, PSFDCD) assert tg.btype == 'angle' assert_equal(tg[0].indices, (0, 5, 10)) assert_equal(tg[1].indices, (5, 10, 15))
def test_TG_getitem_fancy(self, PSFDCD): tg = PSFDCD.atoms.bonds[:10] tg2 = tg[[1, 4, 5]] manual = TopologyGroup(tg.indices[[1, 4, 5]], tg.universe, tg.btype) assert list(tg2) == list(manual)
def test_dihedral_tg_creation_notype(self, PSFDCD): vals = np.array([[0, 2, 4, 6], [5, 7, 9, 11]]) tg = TopologyGroup(vals, PSFDCD) assert tg.btype == 'dihedral' assert_equal(tg[0].indices, (0, 2, 4, 6)) assert_equal(tg[1].indices, (5, 7, 9, 11))
def test_TG_getitem_fancy(self): tg = self.universe.atoms.bonds[:10] tg2 = tg[[1, 4, 5]] manual = TopologyGroup(tg.indices[[1, 4, 5]], tg.universe, tg.btype) assert_equal(list(tg2), list(manual))
def test_TG_getitem_fancy(self): tg = self.universe.bonds[:10] tg2 = tg[[1, 4, 5]] manual = TopologyGroup([tg[i] for i in [1, 4, 5]]) assert_equal(list(tg2), list(manual))
def test_dihedral_tg_creation_notype(self): vals = np.array([[0, 2, 4, 6], [5, 7, 9, 11]]) tg = TopologyGroup(vals, self.universe) assert_(tg.btype == 'dihedral') assert_array_equal(tg[0].indices, (0, 2, 4, 6)) assert_array_equal(tg[1].indices, (5, 7, 9, 11))
def test_angle_tg_creation_notype(self): vals = np.array([[0, 5, 10], [5, 10, 15]]) tg = TopologyGroup(vals, self.universe) assert_(tg.btype == 'angle') assert_array_equal(tg[0].indices, (0, 5, 10)) assert_array_equal(tg[1].indices, (5, 10, 15))
def manual(topg, atomg): if len(atomg) == 1: # hack for Atom input atomg = [atomg] man = [] for b in topg.bondlist: if all(a in atomg for a in b.atoms): man.append(b) if len(man) > 0: return TopologyGroup(man) else: return None
def test_create_empty_TG(self): tg = TopologyGroup([]) def check(a): if a: return True else: return False assert_equal(check(tg), False) assert_equal(len(tg), 0) assert_equal(tg.toptype, None)
def test_verticalTG(self): b1 = self.universe.atoms[0].dihedrals[0] b2 = self.universe.atoms[20].dihedrals[0] TG = TopologyGroup([b1, b2]) forwards = [AtomGroup([b1[i], b2[i]]) for i in range(4)] backwards = [AtomGroup([b2[i], b1[i]]) for i in range(4)] verts = [TG.atom1, TG.atom2, TG.atom3, TG.atom4] # the lists might be in one of two formats, but always in a strict order # ie any(1234 or 4321) but not (1324) assert_equal( any([ all(list(x) == list(y) for x, y in zip(forwards, verts)), all(list(x) == list(y) for x, y in zip(backwards, verts)) ]), True)
def test_nobonds_warns(self): self.u.bonds = TopologyGroup([]) assert_warns(UserWarning, self.u.select_atoms, 'type 2 and bonded name N')
def test_create_guessed_tg_2(self, PSFDCD): vals = np.array([[0, 10], [5, 15]]) tg = TopologyGroup(vals, PSFDCD, guessed=False) assert_equal(tg._guessed, np.array([[False], [False]]))
def test_tg_creation_bad_btype(self, PSFDCD): vals = np.array([[0, 10], [5, 15]]) with pytest.raises(ValueError): TopologyGroup(vals, PSFDCD, btype='apple')
def test_bad_creation_TG(self): """Test making a TopologyGroup out of nonsense""" inputlist = ['a', 'b', 'c'] with pytest.raises(TypeError): TopologyGroup(inputlist)
def manual(topg, atomg): man = [] for b in topg.bondlist: if any(a in atomg for a in b.atoms): man.append(b) return TopologyGroup(man)
def test_create_guessed_tg_2(self): vals = np.array([[0, 10], [5, 15]]) tg = TopologyGroup(vals, self.universe, guessed=False) assert_array_equal(tg._guessed, np.array([[False], [False]]))