def _toPNG(mol): if hasattr(mol, '__sssAtoms'): highlightAtoms = mol.__sssAtoms else: highlightAtoms = [] try: mol.GetAtomWithIdx(0).GetExplicitValence() except RuntimeError: mol.UpdatePropertyCache(False) if not hasattr(rdMolDraw2D, 'MolDraw2DCairo'): mc = copy.deepcopy(mol) try: img = Draw.MolToImage(mc, size=molSize, kekulize=kekulizeStructures, highlightAtoms=highlightAtoms) except ValueError: # <- can happen on a kekulization failure mc = copy.deepcopy(mol) img = Draw.MolToImage(mc, size=molSize, kekulize=False, highlightAtoms=highlightAtoms) bio = BytesIO() img.save(bio, format='PNG') return bio.getvalue() else: nmol = rdMolDraw2D.PrepareMolForDrawing(mol, kekulize=kekulizeStructures) d2d = rdMolDraw2D.MolDraw2DCairo(molSize[0], molSize[1]) d2d.DrawMolecule(nmol, highlightAtoms=highlightAtoms) d2d.FinishDrawing() return d2d.GetDrawingText()
def _toPNG(mol): if hasattr(mol, '__sssAtoms'): highlightAtoms = mol.__sssAtoms else: highlightAtoms = [] try: mol.GetAtomWithIdx(0).GetExplicitValence() except RuntimeError: mol.UpdatePropertyCache(False) mc = copy.deepcopy(mol) try: img = Draw.MolToImage(mc, size=molSize, kekulize=kekulizeStructures, highlightAtoms=highlightAtoms) except ValueError: # <- can happen on a kekulization failure mc = copy.deepcopy(mol) img = Draw.MolToImage(mc, size=molSize, kekulize=False, highlightAtoms=highlightAtoms) bio = BytesIO() img.save(bio, format='PNG') return bio.getvalue()
def _toReactionPNG(rxn): rc = copy.deepcopy(rxn) img = Draw.ReactionToImage(rc, subImgSize=(int(molSize[0] / 3), molSize[1])) bio = BytesIO() img.save(bio, format='PNG') return bio.getvalue()
def _toReactionPNG(rxn): rc = copy.deepcopy(rxn) img = Draw.ReactionToImage(rc, subImgSize=(int(molSize[0] / 3), molSize[1]), highlightByReactant=highlightByReactant) bio = BytesIO() img.save(bio, format='PNG') return bio.getvalue()
def _get_image(x): """displayhook function for PIL Images, rendered as PNG""" bio = BytesIO() x.save(bio, format='PNG') s = b64encode(bio.getvalue()).decode('ascii') pd.set_option('display.max_columns', len(s) + 1000) pd.set_option('display.max_rows', len(s) + 1000) if len(s) + 100 > pd.get_option("display.max_colwidth"): pd.set_option("display.max_colwidth", len(s) + 1000) return s
def _get_image(x): """displayhook function for PIL Images, rendered as PNG""" import pandas as pd bio = BytesIO() x.save(bio, format="PNG") s = b64encode(bio.getvalue()).decode("ascii") pd.set_option("display.max_columns", len(s) + 1000) pd.set_option("display.max_rows", len(s) + 1000) if len(s) + 100 > pd.get_option("display.max_colwidth"): pd.set_option("display.max_colwidth", len(s) + 1000) return s
def _toPNG(mol): if hasattr(mol,'__sssAtoms'): highlightAtoms=mol.__sssAtoms else: highlightAtoms=[] try: mol.GetAtomWithIdx(0).GetExplicitValence() except RuntimeError: mol.UpdatePropertyCache(False) mc = copy.deepcopy(mol) try: img = Draw.MolToImage(mc,size=molSize,kekulize=kekulizeStructures, highlightAtoms=highlightAtoms) except ValueError: # <- can happen on a kekulization failure mc = copy.deepcopy(mol) img = Draw.MolToImage(mc,size=molSize,kekulize=False, highlightAtoms=highlightAtoms) bio = BytesIO() img.save(bio,format='PNG') return bio.getvalue()
def display_pil_image(img): """displayhook function for PIL Images, rendered as PNG""" bio = BytesIO() img.save(bio, format='PNG') return bio.getvalue()
def display_pil_image(img): """displayhook function for PIL Images, rendered as PNG""" bio = BytesIO() img.save(bio,format='PNG') return bio.getvalue()