예제 #1
0
    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: , ')
예제 #2
0
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
예제 #3
0
    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')
예제 #4
0
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)
예제 #5
0
 def testCarbonHydrogenReversedBond(self):
     """Asserts correct parameters for aromatic reversed carbon-hydrogen bond."""
     self.assertEqual(param.GetBondParam('HA', 'CA'), (367.0, 1.080))
예제 #6
0
 def testOxygenHydrogenBond(self):
     """Asserts correct parameters for water hydrogen-oxygen bond."""
     self.assertEqual(param.GetBondParam('OW', 'HW'), (553.0, 0.9572))
예제 #7
0
 def testDummyInput(self):
     """Asserts zero parameters for dummy atom types input."""
     self.assertEqual(param.GetBondParam('X', 'X'), (0.0, 0.0))