def GetTorsions(atoms, bond_graph):
    """Determine torsion angle atom quartets and parameters from bond graph.
  
  Search bond graph for torsion angle quartets, and parameter tables for mm
  parameters. Use to create a new Torsion object and append to Molecule. Count
  as torsion if ij and jk and kl are bonded in quartet ijkl.
  
  Args:
    atoms (mmlib.molecule.Atom*): Array of molecule's Atom objects.
    bond_graph (int:(int:float)): Dictionary of bond connectivity.

  Returns:
    torsions (mmlib.molecule.Torsion*): Array of molecule's Torsion objects.
  """
    torsions = []
    for j, at2 in enumerate(atoms):
        for i, k in itertools.permutations(bond_graph[j], 2):
            if j > k:
                continue
            at1, at3 = atoms[i], atoms[k]
            for l in bond_graph[k]:
                if l == i or l == j:
                    continue
                at4 = atoms[l]
                t_ijkl = geomcalc.GetTijkl(at1.coords, at2.coords, at3.coords,
                                           at4.coords)
                params = param.GetTorsionParam(at1.type_, at2.type_, at3.type_,
                                               at4.type_)
                for v_n, gamma, nfold, paths in params:
                    if v_n:
                        torsions.append(
                            molecule.Torsion(i, j, k, l, v_n, gamma, nfold,
                                             paths, t_ijkl))
    torsions.sort(key=lambda t: (t.at1, t.at2, t.at3, t.at4))
    return torsions
Beispiel #2
0
    def testBadInput(self):
        """Asserts raise of ValueError for missing string input."""
        with self.assertRaises(ValueError) as e:
            param.GetTorsionParam('AA', 'BB', 'CC', 'DD')

        self.assertEqual(
            str(e.exception),
            'No torsion parameters found for central atom pair: BB, CC')
Beispiel #3
0
    def testEmptyInput(self):
        """Asserts raise of ValueError for empty string input."""
        with self.assertRaises(ValueError) as e:
            param.GetTorsionParam('', '', '', '')

        self.assertEqual(
            str(e.exception),
            'No torsion parameters found for central atom pair: , ')
def GetTorsions(mol):
    """Determine torsion angle atom quartets and parameters from bond graph.
  
  Search bond graph for torsion angle quartets, and parameter tables for mm
  parameters. Use to create a new Torsion object and append to Molecule. Count
  as torsion if ij and jk and kl are bonded in quartet ijkl.
  
  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 k in mol.bond_graph[j].keys():
            if j >= k:
                continue
            at3 = mol.atoms[k]
            r_jk = mol.bond_graph[j][k]
            for i in mol.bond_graph[j].keys():
                if i == j or i == k:
                    continue
                at1 = mol.atoms[i]
                r_ij = mol.bond_graph[i][j]
                for l in mol.bond_graph[k].keys():
                    if i == l or j == l or k == l:
                        continue
                    at4 = mol.atoms[l]
                    r_kl = mol.bond_graph[k][l]
                    t_ijkl = geomcalc.GetTijkl(at1.coords, at2.coords,
                                               at3.coords, at4.coords, r_ij,
                                               r_jk, r_kl)
                    params = param.GetTorsionParam(at1.type_, at2.type_,
                                                   at3.type_, at4.type_)
                    for p in range(len(params)):
                        v_n, gamma, nfold, paths = params[p]
                        if v_n > 0.0:
                            mol.torsions.append(
                                molecule.Torsion(i, j, k, l, t_ijkl, v_n,
                                                 gamma, nfold, paths))
    mol.torsions = sorted(mol.torsions, key=lambda t: t.at4)
    mol.torsions = sorted(mol.torsions, key=lambda t: t.at3)
    mol.torsions = sorted(mol.torsions, key=lambda t: t.at2)
    mol.torsions = sorted(mol.torsions, key=lambda t: t.at1)
    mol.n_torsions = len(mol.torsions)
Beispiel #5
0
 def testFourAtomReversed(self):
     """Asserts correct parameters for given reversed atom quartet."""
     self.assertEqual(param.GetTorsionParam('C', 'N', 'CT', 'CT'),
                      _CT_CT_N_C_TORSION_PARAMS)
Beispiel #6
0
 def testCentralReversed(self):
     """Asserts correct parameters for given reversed central atom pair."""
     self.assertEqual(param.GetTorsionParam('X', 'CA', 'C', 'X'),
                      [(14.50, 180.0, 2, 4)])