예제 #1
0
def GetAngles(mol):
    """Determine bond angle atom triplets from bond graph and get parameters.
  
  Search bond graph for bond angle triplets, and parameter tables for mm
  parameters. Use to create a new Angle object and append to Molecule.
  Count as angle if ij and jk are bonded in triplet ijk.
  
  Args:
      mol (mmlib.molecule.Molecule): Molecule object with bond graph of
          atom pairs within covalent radius cutoff threshold.
  """
    for j in range(mol.n_atoms):
        at2 = mol.atoms[j]
        for i in mol.bond_graph[j].keys():
            at1 = mol.atoms[i]
            r_ij = mol.bond_graph[i][j]
            for k in mol.bond_graph[j].keys():
                if i >= k:
                    continue
                at3 = mol.atoms[k]
                r_jk = mol.bond_graph[j][k]
                a_ijk = geomcalc.GetAijk(at1.coords, at2.coords, at3.coords,
                                         r_ij, r_jk)
                k_a, a_eq = param.GetAngleParam(at1.type_, at2.type_,
                                                at3.type_)
                if k_a > 0.0:
                    mol.angles.append(molecule.Angle(i, j, k, a_ijk, a_eq,
                                                     k_a))
    mol.angles = sorted(mol.angles, key=lambda a: a.at3)
    mol.angles = sorted(mol.angles, key=lambda a: a.at2)
    mol.angles = sorted(mol.angles, key=lambda a: a.at1)
    mol.n_angles = len(mol.angles)
예제 #2
0
def GetAngles(atoms, bond_graph):
    """Determine bond angle atom triplets from bond graph and get parameters.
  
  Search bond graph for bond angle triplets, and parameter tables for mm
  parameters. Use to create a new Angle object and append to Molecule.
  Count as angle if ij and jk are bonded in triplet ijk.
  
  Args:
    atoms (mmlib.molecule.Atom*): Array of molecule's Atom objects.
    bond_graph (int:(int:float)): Dictionary of bond connectivity.

  Returns:
    angles (mmlib.molecule.Angle*): Array of molecule's Angle objects.
  """
    angles = []
    for j, at2 in enumerate(atoms):
        for i, k in itertools.combinations(bond_graph[j], 2):
            if i > k:
                continue
            at1, at3 = atoms[i], atoms[k]
            a_ijk = geomcalc.GetAijk(at1.coords, at2.coords, at3.coords)
            k_a, a_eq = param.GetAngleParam(at1.type_, at2.type_, at3.type_)
            if k_a:
                angles.append(molecule.Angle(i, j, k, k_a, a_eq, a_ijk))
    angles.sort(key=lambda a: (a.at1, a.at2, a.at3))
    return angles
예제 #3
0
    def testBadInput(self):
        """Asserts raise of ValueError for missing string input."""
        with self.assertRaises(ValueError) as e:
            param.GetAngleParam('AA', 'BB', 'CC')

        self.assertEqual(
            str(e.exception),
            'No angle parameters found for atom type triplet: AA, BB, CC')
예제 #4
0
    def testEmptyInput(self):
        """Asserts raise of ValueError for empty string input."""
        with self.assertRaises(ValueError) as e:
            param.GetAngleParam('', '', '')

        self.assertEqual(
            str(e.exception),
            'No angle parameters found for atom type triplet: , , ')
예제 #5
0
 def testCCHBenzene(self):
     """Asserts correct mass for heaviest present atom."""
     self.assertEqual(param.GetAngleParam('HA', 'CA', 'CA'), (35.0, 120.0))
예제 #6
0
 def testHOHWater(self):
     """Asserts correct mass for hydrogen atom."""
     self.assertEqual(param.GetAngleParam('HW', 'OW', 'HW'),
                      (100.0, 104.52))
예제 #7
0
 def testDummyInput(self):
     """Asserts zero mass for dummy atom input."""
     self.assertEqual(param.GetAngleParam('X', 'X', 'X'), (0.0, 0.0))