コード例 #1
0
    def get_ts_torsions(self):
        rdmol_copy = self.create_pseudo_geometry()
        torsion_list = []
        cistrans_list = []

        for bond1 in rdmol_copy.GetBonds():
            atom1 = bond1.GetBeginAtom()
            atom2 = bond1.GetEndAtom()
            if atom1.IsInRing() or atom2.IsInRing():
                # Making sure that bond1 we're looking at are in a ring
                continue

            bond_list1 = list(atom1.GetBonds())
            bond_list2 = list(atom2.GetBonds())

            if not len(bond_list1) > 1 and not len(bond_list2) > 1:
                # Making sure that there are more than one bond attached to
                # the atoms we're looking at
                continue

            # Getting the 0th and 3rd atom and insuring that atoms
            # attached to the 1st and 2nd atom are not terminal hydrogens
            # We also make sure that all of the atoms are properly bound together

            # If the above are satisfied, we append a tuple of the torsion our torsion_list
            got_atom0 = False
            got_atom3 = False

            for bond0 in bond_list1:
                atomX = bond0.GetOtherAtom(atom1)
                if atomX.GetIdx() != atom2.GetIdx():
                    got_atom0 = True
                    atom0 = atomX

            for bond2 in bond_list2:
                atomY = bond2.GetOtherAtom(atom2)
                if atomY.GetIdx() != atom1.GetIdx():
                    got_atom3 = True
                    atom3 = atomY

            if not (got_atom0 and got_atom3):
                # Making sure atom0 and atom3 were not found
                continue

            # Looking to make sure that all of the atoms are properly bonded to eached
            if ("SINGLE" in str(
                    rdmol_copy.GetBondBetweenAtoms(
                        atom1.GetIdx(), atom2.GetIdx()).GetBondType())
                    and rdmol_copy.GetBondBetweenAtoms(atom0.GetIdx(),
                                                       atom1.GetIdx())
                    and rdmol_copy.GetBondBetweenAtoms(atom1.GetIdx(),
                                                       atom2.GetIdx())
                    and rdmol_copy.GetBondBetweenAtoms(atom2.GetIdx(),
                                                       atom3.GetIdx())):
                torsion_tup = (atom0.GetIdx(), atom1.GetIdx(), atom2.GetIdx(),
                               atom3.GetIdx())

                already_in_list = False
                for torsion_entry in torsion_list:
                    a, b, c, d = torsion_entry
                    e, f, g, h = torsion_tup

                    if (b, c) == (f, g) or (b, c) == (g, f):
                        already_in_list = True

                if not already_in_list:
                    torsion_list.append(torsion_tup)

            if ("DOUBLE" in str(
                    rdmol_copy.GetBondBetweenAtoms(
                        atom1.GetIdx(), atom2.GetIdx()).GetBondType())
                    and rdmol_copy.GetBondBetweenAtoms(atom0.GetIdx(),
                                                       atom1.GetIdx())
                    and rdmol_copy.GetBondBetweenAtoms(atom1.GetIdx(),
                                                       atom2.GetIdx())
                    and rdmol_copy.GetBondBetweenAtoms(atom2.GetIdx(),
                                                       atom3.GetIdx())):

                torsion_tup = (atom0.GetIdx(), atom1.GetIdx(), atom2.GetIdx(),
                               atom3.GetIdx())

                already_in_list = False
                for torsion_entry in torsion_list:
                    a, b, c, d = torsion_entry
                    e, f, g, h = torsion_tup

                    if (b, c) == (f, g) or (b, c) == (g, f):
                        already_in_list = True

                if not already_in_list:
                    cistrans_list.append(torsion_tup)

        torsions = []
        cistrans = []
        for indices in torsion_list:
            i, j, k, l = indices

            dihedral = self.ase_ts.get_dihedral(i, j, k, l)
            tor = Torsion(indices=indices,
                          dihedral=dihedral,
                          left_mask=[],
                          right_mask=[])
            left_mask = self.get_ts_left_mask(tor)
            right_mask = self.get_ts_right_mask(tor)
            reaction_center = "No"

            if ((self.rmg_ts.atoms[i].label != ""
                 and self.rmg_ts.atoms[j].label != ""
                 and self.rmg_ts.atoms[k].label != "")
                    or (self.rmg_ts.atoms[j].label != ""
                        and self.rmg_ts.atoms[k].label != ""
                        and self.rmg_ts.atoms[l].label != "")):
                reaction_center = "Yes"

            torsions.append(
                Torsion(indices, dihedral, left_mask, right_mask,
                        reaction_center))

        for indices in cistrans_list:
            i, j, k, l = indices

            dihedral = self.ase_ts.get_dihedral(i, j, k, l)
            tor = CisTrans(indices=indices,
                           dihedral=dihedral,
                           left_mask=[],
                           right_mask=[])
            left_mask = self.get_ts_left_mask(tor)
            right_mask = self.get_ts_right_mask(tor)
            reaction_center = "No"

            cistrans.append(
                CisTrans(indices, dihedral, left_mask, right_mask,
                         reaction_center))

        self.torsions = torsions
        self.cistrans = cistrans
        return self.torsions
コード例 #2
0
ファイル: species.py プロジェクト: GalaxyFollower/AutoTST
    def get_torsions(self):
        """
        A method for identifying all of the torsions in a conformer
        """
        torsion_list = []
        for bond1 in self.rdkit_molecule.GetBonds():
            atom1 = bond1.GetBeginAtom()
            atom2 = bond1.GetEndAtom()
            if atom1.IsInRing() or atom2.IsInRing():
                # Making sure that bond1 we're looking at are not in a ring
                continue

            bond_list1 = list(atom1.GetBonds())
            bond_list2 = list(atom2.GetBonds())

            if not len(bond_list1) > 1 and not len(bond_list2) > 1:
                # Making sure that there are more than one bond attached to
                # the atoms we're looking at
                continue

            # Getting the 0th and 3rd atom and insuring that atoms
            # attached to the 1st and 2nd atom are not terminal hydrogens
            # We also make sure that all of the atoms are properly bound
            # together

            # If the above are satisfied, we append a tuple of the torsion our
            # torsion_list
            got_atom0 = False
            got_atom3 = False

            for bond0 in bond_list1:
                atomX = bond0.GetOtherAtom(atom1)
                # if atomX.GetAtomicNum() == 1 and len(atomX.GetBonds()) == 1:
                # This means that we have a terminal hydrogen, skip this
                # NOTE: for H_abstraction TSs, a non teminal H should exist
                #    continue
                if atomX.GetIdx() != atom2.GetIdx():
                    got_atom0 = True
                    atom0 = atomX

            for bond2 in bond_list2:
                atomY = bond2.GetOtherAtom(atom2)
                # if atomY.GetAtomicNum() == 1 and len(atomY.GetBonds()) == 1:
                # This means that we have a terminal hydrogen, skip this
                #    continue
                if atomY.GetIdx() != atom1.GetIdx():
                    got_atom3 = True
                    atom3 = atomY

            if not (got_atom0 and got_atom3):
                # Making sure atom0 and atom3 were not found
                continue

            # Looking to make sure that all of the atoms are properly bonded to
            # eached
            if (
                "SINGLE" in str(
                    self.rdkit_molecule.GetBondBetweenAtoms(
                        atom1.GetIdx(),
                        atom2.GetIdx()).GetBondType()) and self.rdkit_molecule.GetBondBetweenAtoms(
                    atom0.GetIdx(),
                    atom1.GetIdx()) and self.rdkit_molecule.GetBondBetweenAtoms(
                    atom1.GetIdx(),
                    atom2.GetIdx()) and self.rdkit_molecule.GetBondBetweenAtoms(
                        atom2.GetIdx(),
                    atom3.GetIdx())):

                torsion_tup = (atom0.GetIdx(), atom1.GetIdx(),
                               atom2.GetIdx(), atom3.GetIdx())

                already_in_list = False
                for torsion_entry in torsion_list:
                    a, b, c, d = torsion_entry
                    e, f, g, h = torsion_tup

                    if (b, c) == (f, g) or (b, c) == (g, f):
                        already_in_list = True

                if not already_in_list:
                    torsion_list.append(torsion_tup)

        torsions = []
        for index, indices in enumerate(torsion_list):
            i, j, k, l = indices

            dihedral = self.ase_molecule.get_dihedral(i, j, k, l)
            tor = Torsion(index=index,
                          atom_indices=indices,
                          dihedral=dihedral,
                          mask=[])
            mask = self.get_mask(tor)
            reaction_center = False

            torsions.append(Torsion(index=index,
                                    atom_indices=indices,
                                    dihedral=dihedral,
                                    mask=mask,
                                    reaction_center=reaction_center))

        self.torsions = torsions
        return self.torsions
コード例 #3
0
ファイル: geometryTest.py プロジェクト: nateharms/AutoTST
 def setUp(self):
     self.torsion = Torsion(index=1,
                            atom_indices=[1, 2, 3],
                            dihedral=60.0,
                            reaction_center=True,
                            mask=[True, True, True])