Пример #1
0
def has_protonated_double_bonded_ring_nitrogen(mol):
    for atom in mol.GetAtoms(
            oechem.OEAndAtom(
                oechem.OEAndAtom(oechem.OEIsNitrogen(),
                                 oechem.OEHasFormalCharge(1)),
                oechem.OEAtomIsInRing(),
            )):
        for bond in atom.GetBonds():
            if bond.GetOrder() == 2:
                return True

    return False
Пример #2
0
    def AddRelevantRingAtoms(mol, torsion, torsionSet):
        atom1or2 = oechem.OEOrAtom(oechem.OEHasMapIdx(1),
                                   oechem.OEHasMapIdx(2))
        ringNbrs = []
        for atom in mol.GetAtoms(
                oechem.OEAndAtom(oechem.OEAtomIsInRing(), atom1or2)):
            for nbr in atom.GetAtoms(
                    oechem.OEAndAtom(oechem.OENotAtom(atom1or2),
                                     oechem.OENotAtom(
                                         oechem.OEAtomIsInRing()))):
                if nbr.IsHydrogen():
                    ringNbrs.append(nbr)
                    continue

                if nbr.IsOxygen() and mol.GetBond(atom, nbr).GetOrder() == 2:
                    ringNbrs.append(nbr)
                    continue

                if TorsionGenerator.IsOrtho(nbr, torsion):
                    ringNbrs.append(nbr)
        for nbr in ringNbrs:
            if not torsionSet.HasAtom(nbr):
                nbr.SetMapIdx(2)
                torsionSet.AddAtom(nbr)
Пример #3
0
    def MarkBridgingAtoms(BRIDGE_ATOM_IDX, mol, torsionSet):
        NorOorS = oechem.OEOrAtom(
            oechem.OEOrAtom(oechem.OEIsNitrogen(), oechem.OEIsOxygen()),
            oechem.OEIsSulfur())
        for atom in mol.GetAtoms(
                oechem.OEAndAtom(oechem.OEHasMapIdx(2), NorOorS)):
            for nbr in atom.GetAtoms(oechem.OEIsHeavy()):
                if not torsionSet.HasAtom(nbr):
                    if nbr.GetMapIdx() == 0:
                        torsionSet.AddAtom(nbr)
                        if nbr.GetHvyDegree() == 1:
                            nbr.SetMapIdx(3)
                            continue

                        nbr.SetMapIdx(BRIDGE_ATOM_IDX)
Пример #4
0
def _OEFixConnectionNH(protein):
    """
    Temporary fix, thanks to Jesper!
    """
    for atom in protein.GetAtoms(
            oechem.OEAndAtom(oespruce.OEIsModeledAtom(),
                             oechem.OEIsNitrogen())):
        if oechem.OEGetPDBAtomIndex(atom) == oechem.OEPDBAtomName_N:
            expected_h_count = 1
            if oechem.OEGetResidueIndex(atom) == oechem.OEResidueIndex_PRO:
                expected_h_count = 0
            if atom.GetTotalHCount() != expected_h_count:
                oechem.OESuppressHydrogens(atom)
                atom.SetImplicitHCount(1)
                oechem.OEAddExplicitHydrogens(protein, atom)
                for nbr in atom.GetAtoms(oechem.OEIsHydrogen()):
                    oechem.OESet3DHydrogenGeom(protein, nbr)
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cnc(O)cc1CCCBr")

print("Number of chain atoms =", end=" ")
print(oechem.OECount(mol, oechem.OENotAtom(oechem.OEAtomIsInRing())))

print("Number of aromatic nitrogens =", end=" ")
print(
    oechem.OECount(
        mol, oechem.OEAndAtom(oechem.OEIsNitrogen(),
                              oechem.OEIsAromaticAtom())))

print("Number of non-carbons =", end=" ")
print(
    oechem.OECount(mol,
                   oechem.OENotAtom(oechem.OEHasAtomicNum(oechem.OEElemNo_C))))

print("Number of nitrogen and oxygen atoms =", end=" ")
print(
    oechem.OECount(
        mol,
        oechem.OEOrAtom(oechem.OEHasAtomicNum(oechem.OEElemNo_N),
                        oechem.OEHasAtomicNum(oechem.OEElemNo_O))))
# @ </SNIPPET>
Пример #6
0
mol = oechem.OEGraphMol()
oechem.OEReadMolecule(ifs, mol)

# @ <SNIPPET-OEAtomMatchResidue>
resAla = oechem.OEAtomMatchResidueID()
resAla.SetName("ALA")
predAla = oechem.OEAtomMatchResidue(resAla)
print("Number of atoms matching residue name ALA = ", oechem.OECount(mol, predAla))

resChainA = oechem.OEAtomMatchResidueID()
resChainA.SetChainID("A")
predChainA = oechem.OEAtomMatchResidue(resChainA)
print("Number of atoms matching chain A = ", oechem.OECount(mol, predChainA))

resHis = oechem.OEAtomMatchResidueID()
resHis.SetName("HIS")
resHis.SetChainID("A")
resHis.SetResidueNumber("88")
predHis = oechem.OEAtomMatchResidue(resHis)
print("Number of atoms matching residue (HIS A 88) = ", oechem.OECount(mol, predHis))

# alternative way to initialize as regex
predHis2 = oechem.OEAtomMatchResidue("HIS:88:.*:A:.*:.*")
print("Number of atoms matching residue (HIS A 88) = ", oechem.OECount(mol, predHis2))

backbonepred = oechem.OEIsBackboneAtom()
print("Backbone atoms of residue (HIS A 88): ")
for atom in mol.GetAtoms(oechem.OEAndAtom(predHis, backbonepred)):
    print(atom, oechem.OEAtomGetResidue(atom))
# @ </SNIPPET-OEAtomMatchResidue>
Пример #7
0
    def GetTorsions(mol):
        '''
        Goes through each rotatable bond in the molecule
        and extracts torsion atoms (a-b-c-d)
        Core torsion atoms are extended by one bond
        If core or extended atoms are part of a ring,
        then entire ring is kept
        Keep ortho substitution
        Keep functional groups that have at least one atom overlap
        with the core/extended torsion atoms
        Functional group inclusion criteria:
        - <= 5 heavy atoms
        - must contain at least one hetero atom
        - non-ring
        Add methyl cap if bond involving hetero atom is broken
        @param mol: OEGraphMol
        @type mol: OEGraphMol
        @return: list[OEGraphMol]
        '''
        # mol = OEGraphMol(input_mol)

        oechem.OEAssignHybridization(mol)
        funcGrps = TorsionGenerator.GetFuncGroups(mol)
        includedTorsions = oechem.OEAtomBondSet()
        torsionMols = []
        for atom in mol.GetAtoms():
            atom.SetData("idx", atom.GetIdx() + 1)

        torsions = get_canonical_torsions(mol)
        if torsions is None:
            torsions = oechem.OEGetTorsions(mol, oechem.OEIsRotor())

        for torsion in torsions:
            if torsion.a.IsHydrogen() or torsion.b.IsHydrogen() or \
                torsion.c.IsHydrogen() or torsion.d.IsHydrogen():
                continue

            torsion_bond = mol.GetBond(torsion.b, torsion.c)
            if includedTorsions.HasBond(torsion_bond):
                continue
            # if includedTorsions.HasAtom(torsion.b) and \
            #     includedTorsions.HasAtom(torsion.c):
            #     continue

            # revert map idx to zero in original mol
            for atom in mol.GetAtoms():
                atom.SetMapIdx(0)

            # includedTorsions.AddAtom(torsion.b)
            # includedTorsions.AddAtom(torsion.c)
            includedTorsions.AddBond(torsion_bond)

            torsionSet = oechem.OEAtomBondSet(mol.GetBonds())
            torsionSet.AddAtoms([torsion.a, torsion.b, torsion.c, torsion.d])
            for atom in torsionSet.GetAtoms():
                atom.SetMapIdx(1)

            # extend core torsion atoms by one bond
            nbrs = TorsionGenerator.GetNbrs(torsionSet)
            torsionSet.AddAtoms(nbrs)

            # include ring atoms
            ringAtoms = TorsionGenerator.GetSameRingAtoms(mol, torsionSet)
            torsionSet.AddAtoms(ringAtoms)

            for atom in torsionSet.GetAtoms():
                if not atom.GetMapIdx() == 1:
                    atom.SetMapIdx(2)

            # add functional groups that overlap with torsion set
            TorsionGenerator.AddFuncGroupAtoms(funcGrps, torsionSet)

            # add relevant ring atoms (ortho substituents and ring H)
            TorsionGenerator.AddRelevantRingAtoms(mol, torsion, torsionSet)

            # special treatment for C=O
            for atom in torsionSet.GetAtoms(
                    oechem.OEAndAtom(
                        oechem.OEIsOxygen(),
                        oechem.OEIsAtomHybridization(
                            oechem.OEHybridization_sp2))):
                for nbr in atom.GetAtoms():
                    if torsionSet.HasAtom(nbr):
                        for nbr2 in nbr.GetAtoms(oechem.OEIsHeavy()):
                            if not torsionSet.HasAtom(nbr2):
                                nbr2.SetMapIdx(2)
                                torsionSet.AddAtom(nbr2)

            # mark bridging atom and cap if needed
            BRIDGE_ATOM_IDX = 4
            TorsionGenerator.MarkBridgingAtoms(BRIDGE_ATOM_IDX, mol,
                                               torsionSet)

            A_IDX = 11
            B_IDX = 12
            C_IDX = 13
            D_IDX = 14
            torsion.a.SetMapIdx(A_IDX)
            torsion.b.SetMapIdx(B_IDX)
            torsion.c.SetMapIdx(C_IDX)
            torsion.d.SetMapIdx(D_IDX)

            torsionMol = oechem.OEGraphMol()
            oechem.OESubsetMol(torsionMol, mol, torsionSet, True)
            torsionMol.Sweep()
            torsionMols.append(torsionMol)

            # change bridge atom to Carbon
            for atom in torsionMol.GetAtoms(
                    oechem.OEHasMapIdx(BRIDGE_ATOM_IDX)):
                atom.SetAtomicNum(oechem.OEElemNo_C)
                explicit_valence = atom.GetExplicitValence()
                if explicit_valence < 4:
                    atom.SetImplicitHCount(4 - explicit_valence)

            TorsionGenerator.SetSDData(A_IDX, B_IDX, C_IDX, D_IDX, torsion,
                                       torsionMol)

            # set map idx to zero in torsion mol
            for atom in torsionMol.GetAtoms():
                atom.SetMapIdx(0)

        # revert map idx to zero in original mol
        for atom in mol.GetAtoms():
            atom.SetMapIdx(0)

        return torsionMols