def GetFragmentScore(mol):

    score = 0.0
    score += 2.0 * oechem.OECount(mol, oechem.OEAtomIsInRing())
    score += 1.0 * oechem.OECount(mol, oechem.OENotAtom(oechem.OEAtomIsInRing()))

    return score
Пример #2
0
def OEAddLabel_Predicate(disp):
    ringhighlight = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, ringhighlight,
                               oechem.OEAtomIsInRing(), oechem.OEBondIsInRing())
    ringlabel = oedepict.OEHighlightLabel("ring", oechem.OELightGreen)
    oedepict.OEAddLabel(disp, ringlabel, oechem.OEAtomIsInRing())

    chainhighlight = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oedepict.OEAddHighlighting(disp, chainhighlight,
                               oechem.OEAtomIsInChain(), oechem.OEBondIsInChain())
    chainlabel = oedepict.OEHighlightLabel("chain", oechem.OEBlueTint)
    oedepict.OEAddLabel(disp, chainlabel, oechem.OEAtomIsInChain())
Пример #3
0
def RingSubSet(ifs, ofs, exo):
    for mol in ifs.GetOEGraphMols():
        submol = oechem.OEGraphMol()
        adjustHcount = True
        if exo:
            isinring = oechem.OEAtomIsInRing()
            isexo = oechem.OEIsNonRingAtomDoubleBondedToRing()
            includeexo = oechem.OEOrAtom(isinring, isexo)
            oechem.OESubsetMol(submol, mol, includeexo, adjustHcount)
        else:
            oechem.OESubsetMol(submol, mol, oechem.OEAtomIsInRing(),
                               adjustHcount)
        submol.SetTitle(mol.GetTitle() + "_rings")
        if submol.NumAtoms() != 0:
            oechem.OEWriteMolecule(ofs, submol)
Пример #4
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
Пример #5
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)
Пример #6
0
def OEAddLabel_OEAtomBondSet(disp):
    mol = disp.GetMolecule()

    ringset = oechem.OEAtomBondSet(mol.GetAtoms(oechem.OEAtomIsInRing()),
                                   mol.GetBonds(oechem.OEBondIsInRing()))
    ringhighlight = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, ringhighlight, ringset)
    ringlabel = oedepict.OEHighlightLabel("ring", oechem.OELightGreen)
    oedepict.OEAddLabel(disp, ringlabel, ringset)

    chainset = oechem.OEAtomBondSet(mol.GetAtoms(oechem.OEAtomIsInChain()),
                                    mol.GetBonds(oechem.OEBondIsInChain()))
    chainhighlight = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oedepict.OEAddHighlighting(disp, chainhighlight, chainset)
    chainlabel = oedepict.OEHighlightLabel("chain", oechem.OEBlueTint)
    oedepict.OEAddLabel(disp, chainlabel, chainset)
Пример #7
0
    def GetFuncGroups(mol):
        '''
        :param mol:
        :return:
        '''
        funcGrps = []
        for funcGrp in oemedchem.OEGetFuncGroupFragments(mol):
            if oechem.OECount(funcGrp, oechem.OEIsHeavy()) > 5:
                continue
            if oechem.OECount(funcGrp, oechem.OEIsHetero()) == 0:
                continue
            if oechem.OECount(funcGrp, oechem.OEAtomIsInRing()) > 0:
                continue

            funcGrps.append(oechem.OEAtomBondSet(funcGrp))

        return funcGrps
Пример #8
0
def main(argv=[__name__]):
    if len(argv) != 2:
        oechem.OEThrow.Usage("%s <infile>" % argv[0])

    ifs = oechem.oemolistream()
    if not ifs.open(argv[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1])

    print("Title MolWt NumAtoms NumHeavyAtoms NumRingAtoms NumRotors NumConfs")

    for mol in ifs.GetOEMols():
        title = mol.GetTitle()
        if not title:
            title = "Untitled"
        print("%s %.3f %d %d %d %d %d" %
              (title, oechem.OECalculateMolecularWeight(mol), mol.NumAtoms(),
               oechem.OECount(mol, oechem.OEIsHeavy()),
               oechem.OECount(mol, oechem.OEAtomIsInRing()),
               oechem.OECount(mol, oechem.OEIsRotor()), mol.NumConfs()))
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# 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(
Пример #10
0
# @ </SNIPPET-OE2DMOLDISPLAY-OPTIONS-ATOM-PROP-LABEL-FONT-SCALE>
DepictMolecules(opts, smiles,
                "OE2DMolDisplayOptions_SetAtomPropLabelFontScale")

# @ <SNIPPET-OE2DMOLDISPLAY-OPTIONS-ATOM-STEREO-STYLE>
width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomStereoStyle(oedepict.OEAtomStereoStyle_Display_All
                        | oedepict.OEAtomStereoStyle_HashWedgeStyle_Standard)
# @ </SNIPPET-OE2DMOLDISPLAY-OPTIONS-ATOM-STEREO-STYLE>
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomStereoStyle")

# @ <SNIPPET-OE2DMOLDISPLAY-OPTIONS-ATOM-VISIBILITY-FUNCTOR>
width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomVisibilityFunctor(oechem.OEAtomIsInRing())
# @ </SNIPPET-OE2DMOLDISPLAY-OPTIONS-ATOM-VISIBILITY-FUNCTOR>
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomVisibilityFunctor")

########################################################################
# BACKGROUND
########################################################################

# @ <SNIPPET-OE2DMOLDISPLAY-OPTIONS-BACKGROUND-COLOR>
width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBackgroundColor(oechem.OEYellowTint)
# @ </SNIPPET-OE2DMOLDISPLAY-OPTIONS-BACKGROUND-COLOR>
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBackgroundColor")

########################################################################
#!/usr/bin/env python
# (C) 2017 OpenEye Scientific Software Inc. All rights reserved.
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

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

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc[nH]c1CC2COCNC2")
submol = oechem.OEGraphMol()
oechem.OESubsetMol(submol, mol, oechem.OEAtomIsInRing(), True)
print(oechem.OEMolToSmiles(submol))
# @ </SNIPPET>
Пример #12
0
#!/usr/bin/env python
# (C) 2017 OpenEye Scientific Software Inc. All rights reserved.
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

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

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc[nH]c1CC2COCNC2")

print("Number of heavy atoms =", oechem.OECount(mol, oechem.OEIsHeavy()))
print("Number of ring atoms  =", oechem.OECount(mol, oechem.OEAtomIsInRing()))
# @ </SNIPPET>