def _test_container(self, obj_type, obj_id, length, atom_ids, out_ids): molid_1 = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) molid_2 = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) mol_2 = Molecule(molid_2) VMD.molecule.set_top(molid_1) obj = obj_type(obj_id) # Check __len__ self.assertEqual(len(obj), length) # Check __iter__ self.assertEqual(list(obj), [Atom(i) for i in atom_ids]) # Check __contains__ for atom_id in atom_ids: self.assertIn(Atom(atom_id), obj) for atom_id in atom_ids: # Frame differs self.assertNotIn(Atom(atom_id, frame=0), obj) for atom_id in atom_ids: # Molecule differs self.assertNotIn(Atom(atom_id, mol_2), obj) for atom_id in out_ids: self.assertNotIn(Atom(atom_id), obj)
def test_contacts(self): # Test `contacts` method VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) sel1 = Selection('resid 1 to 3 and noh') sel2 = Selection('hydrogen') self.assertEqual(list(sel1.contacts(sel2, 1.0)), []) self.assertEqual(list(sel1.contacts(sel2, 2.0)), [(Atom(6), Atom(11))]) self.assertEqual(list(sel2.contacts(sel1, 2.0)), [(Atom(11), Atom(6))])
def test_values(self): VMD.label.add(BOND, (self.mol.molid, self.mol.molid), (0, 1)) bond_label = BondLabel(Atom(0), Atom(1)) distances = [ 1.0100465, 0.9646406, 0.9611206, 0.9662452, 0.9626279, 0.9649956, 0.9611024, 0.9658498, 0.9603688, 0.9671795, 0.961661, 0.9632944, 0.9573071 ] self.assertAlmostEqualSeqs(bond_label.distances, distances) VMD.label.add(ANGLE, (self.mol.molid, self.mol.molid, self.mol.molid), (0, 1, 2)) angle_label = AngleLabel(Atom(0), Atom(1), Atom(2)) angles = [ 38.9131393, 38.1194229, 38.2041321, 38.341835, 38.3854752, 38.1108742, 37.7457161, 37.9469795, 38.6991272, 38.7136955, 38.4580612, 38.6055489, 39.1369514 ] self.assertAlmostEqualSeqs(angle_label.angles, angles) VMD.label.add( DIHEDRAL, (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), (0, 1, 2, 3)) dihedral_label = DihedralLabel(Atom(0), Atom(1), Atom(2), Atom(3)) dihedrals = [ 54.5871239, 57.054245, 61.5406532, 68.0926056, 75.0311661, 81.3050842, 86.0759125, 89.2662735, 93.1087952, 99.3121338, 110.2715073, 125.2944031, 142.6539612 ] self.assertAlmostEqualSeqs(dihedral_label.dihedrals, dihedrals)
def test_dihedrals(self): # Test `dihedral` function a = Atom(0) b = Atom(4) c = Atom(7) d = Atom(10) self.assertAlmostEqual(dihedral(a, b, c, d), -80.113001) self.assertAlmostEqual(dihedral(d, c, b, a), -80.113001) self.assertAlmostEqual(dihedral(a, c, b, d), 80.113001) self.assertAlmostEqual(dihedral(d, b, c, a), 80.113001)
def test_angle(self): # Test `angle` function a = Atom(0) b = Atom(4) c = Atom(7) self.assertAlmostEqual(angle(a, b, c), 54.0939249) self.assertAlmostEqual(angle(c, b, a), 54.0939249) self.assertAlmostEqual(angle(b, c, a), 63.0930652) self.assertAlmostEqual(angle(a, c, b), 63.0930652) self.assertAlmostEqual(angle(c, a, b), 62.8130099) self.assertAlmostEqual(angle(b, a, c), 62.8130099)
def test_distance(self): # Test `distance` function a = Atom(0) b = Atom(4) c = Atom(7) self.assertAlmostEqual(distance(a, b), 4.4765141) self.assertAlmostEqual(distance(b, a), 4.4765141) self.assertAlmostEqual(distance(a, c), 4.0660655) self.assertAlmostEqual(distance(c, a), 4.0660655) self.assertAlmostEqual(distance(b, c), 4.4653567) self.assertAlmostEqual(distance(c, b), 4.4653567)
def test_delete(self): VMD.label.add(ATOM, (self.mol.molid, ), (0, )) atom_label = AtomLabel(Atom(0)) atom_label.delete() self.assertEqual(VMD.label.listall(ATOM), []) # Label can't be deleted twice with self.assertRaises(ValueError): atom_label.delete() VMD.label.add(BOND, (self.mol.molid, self.mol.molid), (0, 4)) bond_label = BondLabel(Atom(0), Atom(4)) bond_label.delete() self.assertEqual(VMD.label.listall(BOND), []) # Label can't be deleted twice with self.assertRaises(ValueError): bond_label.delete() # Check label values with self.assertRaises(ValueError): bond_label.distances VMD.label.add(ANGLE, (self.mol.molid, self.mol.molid, self.mol.molid), (0, 4, 7)) angle_label = AngleLabel(Atom(0), Atom(4), Atom(7)) angle_label.delete() self.assertEqual(VMD.label.listall(ANGLE), []) # Label can't be deleted twice with self.assertRaises(ValueError): angle_label.delete() # Check label values with self.assertRaises(ValueError): angle_label.angles VMD.label.add( DIHEDRAL, (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), (0, 4, 7, 10)) dihedral_label = DihedralLabel(Atom(0), Atom(4), Atom(7), Atom(10)) dihedral_label.delete() self.assertEqual(VMD.label.listall(DIHEDRAL), []) # Label can't be deleted twice with self.assertRaises(ValueError): dihedral_label.delete() # Check label values with self.assertRaises(ValueError): dihedral_label.dihedrals
def test_create(self): atom_label = AtomLabel.create(Atom(0)) self.assertEqual(VMD.label.listall(ATOM), [{ 'atomid': (0, ), 'molid': (self.mol.molid, ), 'on': 1, 'value': 0.0 }]) self.assertTrue(atom_label.visible) bond_label = BondLabel.create(Atom(0), Atom(4)) data_1 = { 'atomid': (0, 4), 'molid': (self.mol.molid, self.mol.molid), 'on': 1, 'value': 4.476513862609863 } self.assertEqual(VMD.label.listall(BOND), [data_1]) self.assertTrue(bond_label.visible) angle_label = AngleLabel.create(Atom(0), Atom(4), Atom(7)) data_2 = { 'atomid': (0, 4, 7), 'molid': (self.mol.molid, self.mol.molid, self.mol.molid), 'on': 1, 'value': 54.093936920166016 } self.assertEqual(VMD.label.listall(ANGLE), [data_2]) self.assertTrue(angle_label.visible) dihedral_label = DihedralLabel.create(Atom(0), Atom(4), Atom(7), Atom(10)) data_3 = { 'atomid': (0, 4, 7, 10), 'molid': (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), 'on': 1, 'value': -80.11302947998047 } self.assertEqual(VMD.label.listall(DIHEDRAL), [data_3]) self.assertTrue(dihedral_label.visible)
def test_unequal_types(self): VMD.label.add(ATOM, (self.mol.molid, ), (0, )) atom_label = AtomLabel(Atom(0)) VMD.label.add(BOND, (self.mol.molid, self.mol.molid), (0, 4)) bond_label = BondLabel(Atom(0), Atom(4)) VMD.label.add(ANGLE, (self.mol.molid, self.mol.molid, self.mol.molid), (0, 4, 7)) angle_label = AngleLabel(Atom(0), Atom(4), Atom(7)) VMD.label.add( DIHEDRAL, (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), (0, 4, 7, 10)) dihedral_label = DihedralLabel(Atom(0), Atom(4), Atom(7), Atom(10)) self.assertNotEqual(atom_label, bond_label) self.assertNotEqual(atom_label, angle_label) self.assertNotEqual(atom_label, dihedral_label) self.assertNotEqual(bond_label, angle_label) self.assertNotEqual(bond_label, dihedral_label) self.assertNotEqual(angle_label, dihedral_label)
def test_visibility(self): # Test `visible` property VMD.label.add(ATOM, (self.mol.molid, ), (0, )) label = AtomLabel(Atom(0)) self.assertEqual(VMD.label.listall(ATOM), [{ 'atomid': (0, ), 'molid': (self.mol.molid, ), 'on': 1, 'value': 0.0 }]) self.assertTrue(label.visible) # Show visible label doesn't change anything label.visible = True self.assertEqual(VMD.label.listall(ATOM), [{ 'atomid': (0, ), 'molid': (self.mol.molid, ), 'on': 1, 'value': 0.0 }]) self.assertTrue(label.visible) # Hide label label.visible = False self.assertEqual(VMD.label.listall(ATOM), [{ 'atomid': (0, ), 'molid': (self.mol.molid, ), 'on': 0, 'value': 0.0 }]) self.assertFalse(label.visible) # Hide again doesn't change anything label.visible = False self.assertEqual(VMD.label.listall(ATOM), [{ 'atomid': (0, ), 'molid': (self.mol.molid, ), 'on': 0, 'value': 0.0 }]) self.assertFalse(label.visible) # Check direct changes to visibility are followed VMD.label.show(ATOM, {'atomid': (0, ), 'molid': (self.mol.molid, )}) self.assertTrue(label.visible) VMD.label.hide(ATOM, {'atomid': (0, ), 'molid': (self.mol.molid, )}) self.assertFalse(label.visible) label.delete() # Deleted label raises errors with self.assertRaises(ValueError): label.visible with self.assertRaises(ValueError): label.visible = True
def test_constructors(self): # Test various ways of Atom instance creation molid1 = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) VMD.molecule.read(molid1, 'dcd', data('water.1.dcd'), waitfor=-1) mol1 = Molecule(molid1) molid2 = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) mol2 = Molecule(molid2) VMD.molecule.set_top(molid2) # Top molecule and NOW atom = Atom(0) self.assertEqual(atom.molecule, mol2) self.assertEqual(atom.frame, NOW) self.assertAlmostEqual(atom.x, -1.493) # Molecule and frame atom = Atom(0, molecule=mol1, frame=5) self.assertEqual(atom.molecule, mol1) self.assertEqual(atom.frame, 5) self.assertAlmostEqual(atom.x, -1.4746015) # Get atom using selection string atom = Atom.pick('resid 2 and name OH2') self.assertEqual(atom.molecule, mol2) self.assertEqual(atom.frame, NOW) self.assertAlmostEqual(atom.x, 0.337) # Get atom using selection string, molecule and frame atom = Atom.pick('resid 2 and name OH2', molecule=mol1, frame=8) self.assertEqual(atom.molecule, mol1) self.assertEqual(atom.frame, 8) self.assertAlmostEqual(atom.x, 0.3521036) # Atom which does not exist with self.assertRaises(ValueError): Atom(8947) # Selection which returns none or too many atoms with self.assertRaises(ValueError): Atom.pick('all') with self.assertRaises(ValueError): Atom.pick('none')
def test_center(self): # Test `center` function. sel = Selection('all') # Center of selection self.assertAlmostEqualSeqs(list(center(sel)), [-0.0001906, 0.0004762, -0.0001429]) res = Residue(0) # Center of residue self.assertAlmostEqualSeqs(list(center(res)), [-1.3403333, 2.1406667, 0.967]) atom = Atom(0) # Center of atom - atom coordinates self.assertAlmostEqualSeqs(list(center(atom)), [-1.493, 1.9, 1.28]) # Center of atom iterables # The manuall computation seems to differ a bit from the `atomsel.center` self.assertAlmostEqualSeqs(list(center(iter(sel))), [-0.0001905, 0.0004762, -0.0001429]) self.assertAlmostEqualSeqs(list(center((Atom(i) for i in xrange(10)))), [-0.146, 0.3756, 0.3972])
def test_bond_label(self): # Test bond labels a = Atom(0) b = Atom(4) c = Atom(7) VMD.label.add(BOND, (self.mol.molid, self.mol.molid), (0, 4)) VMD.label.add(BOND, (self.mol.molid, self.mol.molid), (4, 7)) VMD.label.add(BOND, (self.other.molid, self.other.molid), (0, 4)) # Check label label_1 = BondLabel(a, b) self.assertEqual(label_1.category, BOND) self.assertEqual(label_1.atoms, (a, b)) self.assertEqual(label_1, label_1) # Create other instance of the same label label_2 = BondLabel(a, b) self.assertEqual(label_2, label_1) # Check other label label_3 = BondLabel(b, c) self.assertEqual(label_3.category, BOND) self.assertEqual(label_3.atoms, (b, c)) self.assertNotEqual(label_3, label_1) # Check label with opposite order of atoms label_4 = BondLabel(b, a) self.assertEqual(label_4.atoms, (b, a)) self.assertEqual(label_4, label_1) # Create label for atom in another frame - it's the same label, because labels are independent on frames label_5 = BondLabel(Atom(0, frame=4), Atom(4, frame=8)) self.assertEqual(label_5, label_1) # Check label to atom from other molecule is different label_6 = BondLabel(Atom(0, self.other), Atom(4, self.other)) self.assertNotEqual(label_6, label_1) # Check ValueError if label doesn't exist with self.assertRaises(ValueError): BondLabel(Atom(5), Atom(6))
def test_atom_label(self): # Test atom labels a = Atom(0) b = Atom(4) VMD.label.add(ATOM, (self.mol.molid, ), (0, )) VMD.label.add(ATOM, (self.mol.molid, ), (4, )) VMD.label.add(ATOM, (self.other.molid, ), (0, )) # Check label label_1 = AtomLabel(a) self.assertEqual(label_1.category, ATOM) self.assertEqual(label_1.atoms, (a, )) self.assertEqual(label_1.atom, a) self.assertEqual(label_1, label_1) # Create other instance of the same label label_2 = AtomLabel(a) self.assertEqual(label_2, label_1) # Check other label label_3 = AtomLabel(b) self.assertEqual(label_3.category, ATOM) self.assertEqual(label_3.atoms, (b, )) self.assertEqual(label_3.atom, b) self.assertNotEqual(label_3, label_1) # Check label for other instance of the same atom label_4 = AtomLabel(Atom(0)) self.assertEqual(label_4, label_1) # Check label for atom in another frame - it's the same label, because labels are independent on frames label_5 = AtomLabel(Atom(0, frame=4)) self.assertEqual(label_5, label_1) # Check label to atom from other molecule is different label_6 = AtomLabel(Atom(0, self.other)) self.assertNotEqual(label_6, label_1) # Check ValueError if label doesn't exist with self.assertRaises(ValueError): AtomLabel(Atom(5))
def test_dihedral_label(self): # Test dihedral labels a = Atom(0) b = Atom(4) c = Atom(7) d = Atom(10) VMD.label.add( DIHEDRAL, (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), (0, 4, 7, 10)) VMD.label.add( DIHEDRAL, (self.mol.molid, self.mol.molid, self.mol.molid, self.mol.molid), (4, 7, 10, 0)) VMD.label.add(DIHEDRAL, (self.other.molid, self.other.molid, self.other.molid, self.other.molid), (0, 4, 7, 10)) # Check label label_1 = DihedralLabel(a, b, c, d) self.assertEqual(label_1.category, DIHEDRAL) self.assertEqual(label_1.atoms, (a, b, c, d)) self.assertEqual(label_1, label_1) # Create other instance of the same label label_2 = DihedralLabel(a, b, c, d) self.assertEqual(label_2, label_1) # Check other label label_3 = DihedralLabel(b, c, d, a) self.assertEqual(label_3.category, DIHEDRAL) self.assertEqual(label_3.atoms, (b, c, d, a)) self.assertNotEqual(label_3, label_1) # Check label with opposite order of atoms label_4 = DihedralLabel(d, c, b, a) self.assertEqual(label_4.atoms, (d, c, b, a)) self.assertEqual(label_4, label_1) # Create label for atom in another frame - it's the same label, because labels are independent on frames label_5 = DihedralLabel(Atom(0, frame=4), Atom(4, frame=8), Atom(7, frame=2), Atom(10, frame=3)) self.assertEqual(label_5, label_1) # Check label to atom from other molecule is different label_6 = DihedralLabel(Atom(0, self.other), Atom(4, self.other), Atom(7, self.other), Atom(10, self.other)) self.assertNotEqual(label_6, label_1) # Check ValueError if label doesn't exist with self.assertRaises(ValueError): DihedralLabel(Atom(5), Atom(6), Atom(7), Atom(8))
def test_selection_updates(self): # Test selection updates if frame is changed molid = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) VMD.molecule.read(molid, 'dcd', data('water.1.dcd'), waitfor=-1) mol = Molecule(molid) # Create selection linked to the molecule frame sel = Selection('x < -1.4') self.assertEqual(list(sel), [Atom(9), Atom(18), Atom(19), Atom(20)]) # Change the molecule frame, the selection should follow mol.frame = 0 self.assertEqual(list(sel), [ Atom(0), Atom(1), Atom(9), Atom(10), Atom(18), Atom(19), Atom(20) ]) mol.frame = 4 self.assertEqual( list(sel), [Atom(0), Atom(1), Atom(9), Atom(18), Atom(19), Atom(20)]) # Define the selection's frame result = [ Atom(0, frame=9), Atom(1, frame=9), Atom(9, frame=9), Atom(18, frame=9), Atom(19, frame=9), Atom(20, frame=9) ] sel.frame = 9 self.assertEqual(list(sel), result) # Change the molecule frame, the selection keeps its frame mol.frame = 11 self.assertEqual(list(sel), result) # Set the selection's frame back to the molecule's frame sel.frame = NOW self.assertEqual(list(sel), [Atom(9), Atom(18), Atom(19), Atom(20)])
def test_properties(self): # Test getters and setters molid = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) atom = Atom(0) # Test getters self.assertEqual(atom.index, 0) self.assertAlmostEqual(atom.x, -1.493) self.assertAlmostEqual(atom.y, 1.900) self.assertAlmostEqual(atom.z, 1.280) self.assertIsInstance(atom.coords, ndarray) self.assertAlmostEqualSeqs(list(atom.coords), [-1.493, 1.9, 1.28]) self.assertEqual(atom.name, 'OH2') self.assertEqual(atom.type, 'OT') self.assertEqual(atom.element, 'O') self.assertAlmostEqual(atom.beta, 0.0) self.assertAlmostEqual(atom.occupancy, 1.0) self.assertAlmostEqual(atom.mass, 15.9994, places=6) self.assertAlmostEqual(atom.charge, -0.834) self.assertAlmostEqual(atom.radius, 1.52) self.assertEqual(list(atom.bonded), [Atom(1), Atom(2)]) self.assertEqual(atom.residue, Residue(0)) self.assertEqual(atom.chain, Chain('W')) self.assertEqual(atom.segment, Segment('W1')) # Test setters with self.assertRaises(AttributeError): atom.index = 42 with self.assertRaises(AttributeError): atom.residue = Residue(4) sel = VMD.atomsel.atomsel('index 0', molid=molid) # Test setters for coordinates atom.x = 23.9 atom.y = -200.45 atom.z = 0 # XXX: There are some troubles with rounding in set self.assertAlmostEqualSeqs(sel.get('x'), [23.9], places=6) self.assertAlmostEqualSeqs(sel.get('y'), [-200.45], places=5) self.assertAlmostEqualSeqs(sel.get('z'), [0]) self.assertAlmostEqual(atom.x, 23.9, places=6) self.assertAlmostEqual(atom.y, -200.45, places=5) self.assertAlmostEqual(atom.z, 0) self.assertAlmostEqualSeqs(list(atom.coords), [23.9, -200.45, 0], places=5) # Set complete coordinates atom.coords = (-90.56, 42, 17.85) # XXX: There are some troubles with rounding in set self.assertAlmostEqualSeqs(sel.get('x'), [-90.56], places=5) self.assertAlmostEqualSeqs(sel.get('y'), [42]) self.assertAlmostEqualSeqs(sel.get('z'), [17.85], places=6) self.assertAlmostEqual(atom.x, -90.56, places=5) self.assertAlmostEqual(atom.y, 42) self.assertAlmostEqual(atom.z, 17.85, places=6) self.assertAlmostEqualSeqs(list(atom.coords), [-90.56, 42, 17.85], places=5) # Test setters for other attributes atom.name = 'NEW' self.assertEqual(atom.name, 'NEW') self.assertEqual(sel.get('name'), ['NEW']) atom.type = 'N18' self.assertEqual(atom.type, 'N18') self.assertEqual(sel.get('type'), ['N18']) atom.element = 'Y' self.assertEqual(atom.element, 'Y') self.assertEqual(sel.get('element'), ['Y']) atom.beta = 2.5 self.assertEqual(atom.beta, 2.5) self.assertEqual(sel.get('beta'), [2.5]) atom.occupancy = -3.8 self.assertAlmostEqual(atom.occupancy, -3.8) self.assertAlmostEqualSeqs(sel.get('occupancy'), [-3.8]) atom.mass = 42.89 self.assertAlmostEqual(atom.mass, 42.89, places=5) self.assertAlmostEqualSeqs(sel.get('mass'), [42.89], places=5) atom.charge = -7.05 self.assertAlmostEqual(atom.charge, -7.05, places=6) self.assertAlmostEqualSeqs(sel.get('charge'), [-7.05], places=6) atom.radius = 4.9 self.assertAlmostEqual(atom.radius, 4.9, places=6) self.assertAlmostEqualSeqs(sel.get('radius'), [4.9], places=6) atom.chain = Chain('A') # Ensure only this atom was moved to the new chain self.assertEqual(VMD.atomsel.atomsel('chain A').get('index'), [0]) self.assertEqual(atom.chain, Chain('A')) atom.segment = Segment('S') # Ensure only this atom was moved to the new segment self.assertEqual(VMD.atomsel.atomsel('segname S').get('index'), [0]) self.assertEqual(atom.segment, Segment('S'))
def test_different_objects(self): VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) self.assertNotEqual(Atom(0), Residue(0)) self.assertNotEqual(Chain('X'), Segment('X'))
def test_hydrogen_bonds(self): # Test `hydrogen_bonds` function sel = Selection('noh') result = [ HydrogenBond(Atom(18), Atom(19), Atom(9)), HydrogenBond(Atom(9), Atom(11), Atom(6)), HydrogenBond(Atom(6), Atom(7), Atom(15)) ] self.assertEqual(list(hydrogen_bonds(sel)), result) self.assertEqual(list(hydrogen_bonds(sel, sel)), result) result = [ HydrogenBond(Atom(18), Atom(19), Atom(9)), HydrogenBond(Atom(9), Atom(11), Atom(6)), HydrogenBond(Atom(6), Atom(7), Atom(9)), HydrogenBond(Atom(6), Atom(7), Atom(15)) ] self.assertEqual(list(hydrogen_bonds(sel, angle=75)), result) self.assertEqual(list(hydrogen_bonds(sel, angle=180)), []) self.assertEqual(list(hydrogen_bonds(sel, distance=2)), []) # If the selections do not share same atoms, check the hydrogen bonds are returned only in correct direction sel1 = Selection('index 6') sel2 = Selection('index 9') self.assertEqual(list(hydrogen_bonds(sel1, sel2, angle=75)), [HydrogenBond(Atom(6), Atom(7), Atom(9))])
def test_managers(self): molid = VMD.molecule.load('psf', data('water.psf'), 'pdb', data('water.pdb')) # There are no labels self.assertEqual(len(ATOM_LABELS), 0) self.assertEqual(len(BOND_LABELS), 0) self.assertEqual(len(ANGLE_LABELS), 0) self.assertEqual(len(DIHEDRAL_LABELS), 0) # Create a few labels directly in VMD VMD.label.add(ATOM, (molid, ), (0, )) VMD.label.add(ATOM, (molid, ), (1, )) VMD.label.add(ATOM, (molid, ), (2, )) VMD.label.add(ATOM, (molid, ), (3, )) VMD.label.add(BOND, (molid, molid), (2, 3)) VMD.label.add(BOND, (molid, molid), (3, 4)) VMD.label.add(BOND, (molid, molid), (4, 5)) VMD.label.add(ANGLE, (molid, molid, molid), (2, 4, 6)) VMD.label.add(ANGLE, (molid, molid, molid), (3, 5, 7)) VMD.label.add(DIHEDRAL, (molid, molid, molid, molid), (8, 5, 3, 2)) # Check manager's properties self.assertEqual(len(ATOM_LABELS), 4) self.assertEqual(len(BOND_LABELS), 3) self.assertEqual(len(ANGLE_LABELS), 2) self.assertEqual(len(DIHEDRAL_LABELS), 1) label_1 = AtomLabel(Atom(0)) self.assertIn(label_1, ATOM_LABELS) self.assertNotIn(label_1, BOND_LABELS) self.assertNotIn(label_1, ANGLE_LABELS) self.assertNotIn(label_1, DIHEDRAL_LABELS) self.assertEqual(list(ATOM_LABELS), [ label_1, AtomLabel(Atom(1)), AtomLabel(Atom(2)), AtomLabel(Atom(3)) ]) self.assertEqual(list(BOND_LABELS), [ BondLabel(Atom(2), Atom(3)), BondLabel(Atom(3), Atom(4)), BondLabel(Atom(4), Atom(5)) ]) self.assertEqual(list(ANGLE_LABELS), [ AngleLabel(Atom(2), Atom(4), Atom(6)), AngleLabel(Atom(3), Atom(5), Atom(7)) ]) self.assertEqual(list(DIHEDRAL_LABELS), [DihedralLabel(Atom(8), Atom(5), Atom(3), Atom(2))])