Example #1
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())
def OEAddHighlighting_OEAtomBondSet(disp):
    mol = disp.GetMolecule()
    abset = oechem.OEAtomBondSet(mol.GetAtoms(Pred6MemAromAtom()),
                                 mol.GetBonds(Pred6MemAromBond()))

    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, abset)
Example #3
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)
Example #4
0
def OEAddLabel_OEMatch(disp):
    subs = oechem.OESubSearch("a1aaaaa1")
    unique = True
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    for match in subs.Match(disp.GetMolecule(), unique):
        oedepict.OEAddHighlighting(disp, highlightstyle, match)
        label = oedepict.OEHighlightLabel("aromatic", oechem.OELightGreen)
        oedepict.OEAddLabel(disp, label, match)
Example #5
0
def highlight_atoms_in_mol(mol2, dihedralAtomIndices, width=200, height=200):
    mol = mol2.CreateCopy()
    opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
    oedepict.OEPrepareDepiction(mol)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    img = oedepict.OEImage(width, height)

    hstyle = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    for atom_idx in dihedralAtomIndices:
        oedepict.OEAddHighlighting(disp, hstyle, oechem.OEHasAtomIdx(atom_idx))

    oedepict.OERenderMolecule(img, disp)
    return img
Example #6
0
def plot_dihedral(mol2, width=200, height=200):
    mol = mol2.CreateCopy()
    dihedralAtomIndices = [
        int(x) - 1 for x in get_sd_data(mol, "TORSION_ATOMS_FRAGMENT").split()
    ]
    dih, tor = get_dihedral(mol, dihedralAtomIndices)

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

    disp = oedepict.OE2DMolDisplay(mol, opts)
    img = oedepict.OEImage(width, height)

    hstyle = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oedepict.OEAddHighlighting(disp, hstyle, dih)
    hstyle = oedepict.OEHighlightByColor(oechem.OERed)
    oedepict.OEAddHighlighting(disp, hstyle, tor)

    oedepict.OERenderMolecule(img, disp)
    return img
Example #7
0
def draw_subsearch_highlights(mol, subsearch, width=400.0, height=400.0):
    """
    Draws the hits for the substructure in a given molecule.
    
    Copied from http://notebooks.eyesopen.com/substructure-search-pandas-oenotebook.html
    """
    opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)

    mol = oechem.OEGraphMol(mol)
    oedepict.OEPrepareDepiction(mol)
    img = oedepict.OEImage(width, height)
    hstyle = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    unique = True
    for match in subsearch.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, hstyle, match)

    oedepict.OERenderMolecule(img, disp)
    # return oenb.draw_oeimage_to_img_tag(img)
    return img
Example #8
0
def OEAddHighlighting_Predicate(adisp):
    highlight = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oegrapheme.OEAddLigandHighlighting(adisp, highlight, Pred6MemAromAtom())
    oegrapheme.OEAddLigandHighlighting(adisp, highlight, Pred6MemAromBond())
def OEAddHighlighting_OESubSearch(disp):
    subsearch = oechem.OESubSearch("a1aaaaa1")
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, subsearch)
def OEAddHighlighting_AtomAndBondPredicate(disp):
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom(),
                               Pred6MemAromBond())
Example #11
0
    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByBallAndStick(oechem.OEDarkBlue)
# @ <SNIPPET-OEHIGHLIGHTBYBALLANDSTICK-SETCOLOR>
highlight.SetColor(oechem.OEPinkTint)
# @ </SNIPPET-OEHIGHLIGHTBYBALLANDSTICK-SETCOLOR>
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightByBallAndStick_SetColor")

# @ <SNIPPET-OEHIGHLIGHTBYBALLANDSTICK-SETSTICKWIDTHSCALE>
highlight = oedepict.OEHighlightByBallAndStick(oechem.OEPinkTint)
highlight.SetStickWidthScale(5.0)
# @ </SNIPPET-OEHIGHLIGHTBYBALLANDSTICK-SETSTICKWIDTHSCALE>
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightByBallAndStick_SetStickWidthScale")

# @ <SNIPPET-OEHIGHLIGHTBYBALLANDSTICK-SETBALLRADIUSSCALE>
highlight = oedepict.OEHighlightByBallAndStick(oechem.OEPinkTint)