def testEmptyInput(self): """Asserts raise of ValueError for empty string input.""" with self.assertRaises(ValueError) as e: param.GetBondParam('', '') self.assertEqual(str(e.exception), 'No bond parameters found for atom type pair: , ')
def GetBonds(atoms, bond_graph): """Determine covalently bonded atoms from bond graph and get parameters. Search bond graph for bonded atom pairs, and parameter tables for mm parameters. Use to create a new Bond object and append to Molecule. Args: atoms (mmlib.molecule.Atom*): Array of molecule's Atom objects. bond_graph (int:(int: float)): Dictionary of bond connectivity. Returns: bonds (mmlib.molecule.Bond*): Array of molecule's Bond objects. """ bonds = [] for i, at1 in enumerate(atoms): for j in bond_graph[i]: if i > j: continue at2 = atoms[j] r_ij = bond_graph[i][j] k_b, r_eq = param.GetBondParam(at1.type_, at2.type_) if k_b: bonds.append(molecule.Bond(i, j, k_b, r_eq, r_ij)) bonds.sort(key=lambda b: (b.at1, b.at2)) return bonds
def testBadInput(self): """Asserts raise of ValueError for missing atom types input.""" with self.assertRaises(ValueError) as e: param.GetBondParam('AA', 'BB') self.assertEqual( str(e.exception), 'No bond parameters found for atom type pair: AA, BB')
def GetBonds(mol): """Determine covalently bonded atoms from bond graph and get parameters. Search bond graph for bonded atom pairs, and parameter tables for mm parameters. Use to create a new Bond object and append to Molecule. Args: mol (mmlib.molecule.Molecule): Molecule object with bond graph of atom pairs within covalent radius cutoff threshold. """ for i in range(mol.n_atoms): at1 = mol.atoms[i] for j in mol.bond_graph[i].keys(): at2 = mol.atoms[j] if i >= j: r_ij = mol.bond_graph[i][j] k_b, r_eq = param.GetBondParam(at1.type_, at2.type_) if k_b > 0.0: mol.bonds.append(molecule.Bond(i, j, r_ij, r_eq, k_b)) mol.bonds = sorted(mol.bonds, key=lambda b: b.at2) mol.bonds = sorted(mol.bonds, key=lambda b: b.at1) mol.n_bonds = len(mol.bonds)
def testCarbonHydrogenReversedBond(self): """Asserts correct parameters for aromatic reversed carbon-hydrogen bond.""" self.assertEqual(param.GetBondParam('HA', 'CA'), (367.0, 1.080))
def testOxygenHydrogenBond(self): """Asserts correct parameters for water hydrogen-oxygen bond.""" self.assertEqual(param.GetBondParam('OW', 'HW'), (553.0, 0.9572))
def testDummyInput(self): """Asserts zero parameters for dummy atom types input.""" self.assertEqual(param.GetBondParam('X', 'X'), (0.0, 0.0))