示例#1
0
def Draw2DSurfaces(image, mol):

    oedepict.OEPrepareDepiction(mol)

    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts, 1.50))

    disp = oedepict.OE2DMolDisplay(mol, opts)

    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_C), 1.00,
                  oechem.OEBlack)
    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_N), 1.25,
                  oechem.OEDarkBlue)
    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_O), 1.50,
                  oechem.OEDarkRed)

    oedepict.OERenderMolecule(image, disp)
示例#2
0
def has_undesirable_elements(mol):
    '''
    returns True if molecule contains any element other than
    H, C, N, O, F, S, Cl, or P
    @param mol:
    @type mol: OEGraphMol
    @return: bool
    '''
    atomsHC = oechem.OEOrAtom(oechem.OEIsHydrogen(), oechem.OEIsCarbon())
    atomsNO = oechem.OEOrAtom(oechem.OEIsNitrogen(), oechem.OEIsOxygen())
    atomsFS = oechem.OEOrAtom(oechem.OEHasAtomicNum(9), oechem.OEIsSulfur())
    atomsHCNO = oechem.OEOrAtom(atomsHC, atomsNO)
    atomsHCNOFS = oechem.OEOrAtom(atomsHCNO, atomsFS)
    atomsHCNOFSCl = oechem.OEOrAtom(atomsHCNOFS, oechem.OEHasAtomicNum(17))
    atomsHCNOFSClP = oechem.OEOrAtom(atomsHCNOFSCl, oechem.OEIsPhosphorus())

    undesirable_atom = mol.GetAtom(oechem.OENotAtom(atomsHCNOFSClP))
    if undesirable_atom is not None:
        return True

    return False
# 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>
示例#4
0
# 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.

from openeye import oechem
from openeye import oedepict

# @ <SNIPPET-ATOM-DISPLAY-LABEL>
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height,
                                      oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)

for adisp in disp.GetAtomDisplays(oechem.OEHasAtomicNum(oechem.OEElemNo_C)):
    if adisp.IsVisible():
        adisp.SetLabel("C")

oedepict.OERenderMolecule("AtomDisplayLabel.png", disp)
# @ </SNIPPET-ATOM-DISPLAY-LABEL>
oedepict.OERenderMolecule("AtomDisplayLabel.pdf", disp)
示例#5
0
# 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 openeye import oechem

# @ <SNIPPET-OEADDMOLS>
dstmol = oechem.OEGraphMol()
oechem.OESmilesToMol(dstmol, 'c1ccccc1 benzene')
srcmol = oechem.OEGraphMol()
oechem.OESmilesToMol(srcmol, 'c1cnccc1 pyridine')

amap, bmap = oechem.OEAddMols(dstmol, srcmol, "+")
print("%s %s" % (oechem.OEMolToSmiles(dstmol), dstmol.GetTitle()))
print(" ".join(str(a) for a in amap))
print(" ".join(str(b) for b in bmap))
# @ </SNIPPET-OEADDMOLS>

# @ <SNIPPET-OEADDMOL-ATOMMAP>
srcatom = srcmol.GetAtom(oechem.OEHasAtomicNum(oechem.OEElemNo_N))
dstatom = amap[srcatom.GetIdx()]
# @ </SNIPPET-OEADDMOL-ATOMMAP>

# @ <SNIPPET-OEADDMOL-BONDMAP>
srcbond = srcmol.GetBond(oechem.OEHasBondIdx(0))
dstbond = bmap[srcbond.GetIdx()]
# @ </SNIPPET-OEADDMOL-BONDMAP>
# @ </SNIPPET>
示例#6
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, "c1c(Br)occ1CCC")

print("Carbon atoms:", end=" ")
for atom in mol.GetAtoms(oechem.OEHasAtomicNum(oechem.OEElemNo_C)):
    print(atom.GetIdx(), end=" ")
print()
# @ </SNIPPET>
#!/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")
# @ <SNIPPET-PRED-ATOMIC>
print("Number of oxygen atoms =",
      oechem.OECount(mol, oechem.OEHasAtomicNum(oechem.OEElemNo_O)))
print("Number of oxygen atoms =", oechem.OECount(mol, oechem.OEIsOxygen()))
# @ </SNIPPET-PRED-ATOMIC>
# @ </SNIPPET>