当前位置: 首页>>代码示例>>Python>>正文


Python DrawingOptions.wedgeDashedBonds方法代码示例

本文整理汇总了Python中rdkit.Chem.Draw.MolDrawing.DrawingOptions.wedgeDashedBonds方法的典型用法代码示例。如果您正苦于以下问题:Python DrawingOptions.wedgeDashedBonds方法的具体用法?Python DrawingOptions.wedgeDashedBonds怎么用?Python DrawingOptions.wedgeDashedBonds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdkit.Chem.Draw.MolDrawing.DrawingOptions的用法示例。


在下文中一共展示了DrawingOptions.wedgeDashedBonds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MolToQPixmap

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToQPixmap(mol, size=(300,300), kekulize=True,  wedgeBonds=True,
                 fitImage=False, options=None, **kwargs):
    """ Generates a drawing of a molecule on a Qt QPixmap
    """
    if not mol:
        raise ValueError('Null molecule provided')
    from rdkit.Chem.Draw.qtCanvas import Canvas
    canvas = Canvas(size)
    if options is None:
        options = DrawingOptions()
    options.bgColor = None
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds=wedgeBonds
    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)
    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)
    drawer.AddMol(mol, **kwargs)
    canvas.flush()
    return canvas.pixmap
开发者ID:dfhahn,项目名称:rdkit,代码行数:27,代码来源:__init__.py

示例2: MolToMPL

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToMPL(mol,size=(300,300),kekulize=True, wedgeBonds=True,
             imageType=None, fitImage=False, options=None, **kwargs):
  """ Generates a drawing of a molecule on a matplotlib canvas
  """
  if not mol:
    raise ValueError('Null molecule provided')
  from rdkit.Chem.Draw.mplCanvas import Canvas
  canvas = Canvas(size)
  if options is None:
    options = DrawingOptions()
    options.bgColor=None
  if fitImage:
      drawingOptions.dotsPerAngstrom = int(min(size) / 10)
  options.wedgeDashedBonds=wedgeBonds
  drawer = MolDrawing(canvas=canvas, drawingOptions=options)
  omol=mol
  if kekulize:
    from rdkit import Chem
    mol = Chem.Mol(mol.ToBinary())
    Chem.Kekulize(mol)
    
  if not mol.GetNumConformers():
    from rdkit.Chem import AllChem
    AllChem.Compute2DCoords(mol)
  
  drawer.AddMol(mol,**kwargs)
  omol._atomPs=drawer.atomPs[mol]
  for k,v in iteritems(omol._atomPs):
    omol._atomPs[k]=canvas.rescalePt(v)
  canvas._figure.set_size_inches(float(size[0])/100,float(size[1])/100)
  return canvas._figure
开发者ID:dfhahn,项目名称:rdkit,代码行数:33,代码来源:__init__.py

示例3: MolToJSON

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToJSON(mol, size=(300,300), kekulize=True, wedgeBonds=True,
               fitImage=False, options=None, **kwargs):
  if not mol:
    raise ValueError,'Null molecule provided'

  canvas = Canvas(size=size)

  if options is None:
    options = DrawingOptions()
  if fitImage:
      options.dotsPerAngstrom = int(min(size) / 10)
  options.wedgeDashedBonds = wedgeBonds
  try:
    drawer = MolDrawing(canvas=canvas,drawingOptions=options)
  except TypeError:
    drawer = MolDrawing(canvas=canvas)

  if kekulize:
    mol = Chem.Mol(mol.ToBinary())
    Chem.Kekulize(mol)

  if not mol.GetNumConformers():
    Compute2DCoords(mol)

  drawer.AddMol(mol,**kwargs)
  try:
    drawer.AddLegend(kwargs.get('legend', ''))
  except AttributeError:
    pass

  canvas.flush()
  return canvas.json

#------------------------------------------------------------------------------
开发者ID:jir322,项目名称:chembl_beaker,代码行数:36,代码来源:jsonCanvas.py

示例4: MolToImage

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToImage(mol, size=(300,300), kekulize=True, wedgeBonds=True,
               fitImage=False, options=None, canvas=None, **kwargs):
  """ returns a PIL image containing a drawing of the molecule

    Keyword arguments:
    kekulize -- run kekulization routine on input `mol` (default True)
    size -- final image size, in pixel (default (300,300))
    wedgeBonds -- draw wedge (stereo) bonds (default True)
    highlightAtoms -- list of atoms to highlight (default [])
    highlightMap -- dictionary of (atom, color) pairs (default None)
    highlightBonds -- list of bonds to highlight (default [])
  """
  if not mol:
    raise ValueError('Null molecule provided')
  if canvas is None:
    img,canvas=_createCanvas(size)
  else:
    img=None
    
  if options is None:
    options = DrawingOptions()
  if fitImage:
      options.dotsPerAngstrom = int(min(size) / 10)
  options.wedgeDashedBonds = wedgeBonds
  drawer = MolDrawing(canvas=canvas,drawingOptions=options)

  if kekulize:
    from rdkit import Chem
    mol = Chem.Mol(mol.ToBinary())
    Chem.Kekulize(mol)
    
  if not mol.GetNumConformers():
    from rdkit.Chem import AllChem
    AllChem.Compute2DCoords(mol)
  
  if 'legend' in kwargs:
    legend = kwargs['legend']
    del kwargs['legend']
  else:
    legend=''

  drawer.AddMol(mol,**kwargs)

  if legend:
    from rdkit.Chem.Draw.MolDrawing import Font
    bbox = drawer.boundingBoxes[mol]
    pos = size[0]/2,int(.94*size[1]),0 # the 0.94 is extremely empirical
    # canvas.addCanvasPolygon(((bbox[0],bbox[1]),(bbox[2],bbox[1]),(bbox[2],bbox[3]),(bbox[0],bbox[3])),
    #                         color=(1,0,0),fill=False,stroke=True)
    # canvas.addCanvasPolygon(((0,0),(0,size[1]),(size[0],size[1]),(size[0],0)   ),
    #                         color=(0,0,1),fill=False,stroke=True)
    font=Font(face='sans',size=12)
    canvas.addCanvasText(legend,pos,font)

  if kwargs.get('returnCanvas',False):
    return img,canvas,drawer
  else:
    canvas.flush()
    return img
开发者ID:baoilleach,项目名称:rdkit,代码行数:61,代码来源:__init__.py

示例5: MolToFile

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToFile(mol, fileName, size=(300, 300), kekulize=True, wedgeBonds=True,
              imageType=None, fitImage=False, options=None, **kwargs):
    """ Generates a drawing of a molecule and writes it to a file
    """
    # original contribution from Uwe Hoffmann
    if not fileName:
        raise ValueError('no fileName provided')
    if not mol:
        raise ValueError('Null molecule provided')

    if imageType is None:
        imageType = os.path.splitext(fileName)[1][1:]

    if options is None:
        options = DrawingOptions()
    useAGG, useCairo, Canvas = _getCanvas()
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds = wedgeBonds
    if useCairo or useAGG:
        canvas = Canvas(size=size, imageType=imageType,
                        fileName=fileName)
    else:
        # <- the sping canvas doesn't support unicode well
        options.radicalSymbol = '.'
        canvas = Canvas(size=size, name=fileName, imageType=imageType)
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)
    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)

    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)

    drawer.AddMol(mol, **kwargs)
    if useCairo or useAGG:
        canvas.flush()
    else:
        canvas.save()
开发者ID:mnowotka,项目名称:rdkit,代码行数:43,代码来源:__init__.py

示例6: MolToImage

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToImage(mol, size=(300,300), kekulize=True, wedgeBonds=True,
               fitImage=False, options=None, canvas=None, **kwargs):
  """Returns a PIL image containing a drawing of the molecule
    
      ARGUMENTS:

        - kekulize: run kekulization routine on input `mol` (default True)
        
        - size: final image size, in pixel (default (300,300))
        
        - wedgeBonds: draw wedge (stereo) bonds (default True)
        
        - highlightAtoms: list of atoms to highlight (default [])
        
        - highlightMap: dictionary of (atom, color) pairs (default None)
        
        - highlightBonds: list of bonds to highlight (default [])

        - highlightColor: RGB color as tuple (default [1, 0, 0])
          
      NOTE:
          
            use 'matplotlib.colors.to_rgb()' to convert string and 
            HTML color codes into the RGB tuple representation, eg.
            
              from matplotlib.colors import ColorConverter
              img = Draw.MolToImage(m, highlightAtoms=[1,2], highlightColor=ColorConverter().to_rgb('aqua'))
              img.save("molecule.png")
              
      RETURNS:
    
        a PIL Image object
  """
  
  if not mol:
    raise ValueError('Null molecule provided')
  if canvas is None:
    img,canvas=_createCanvas(size)
  else:
    img=None
    
  if options is None:
    options = DrawingOptions()
  if fitImage:
      options.dotsPerAngstrom = int(min(size) / 10)
  options.wedgeDashedBonds = wedgeBonds
  if 'highlightColor' in kwargs:
      color = kwargs.pop('highlightColor', (1, 0, 0))
      options.selectColor = color
      
  drawer = MolDrawing(canvas=canvas,drawingOptions=options)

  if kekulize:
    from rdkit import Chem
    mol = Chem.Mol(mol.ToBinary())
    Chem.Kekulize(mol)
    
  if not mol.GetNumConformers():
    from rdkit.Chem import AllChem
    AllChem.Compute2DCoords(mol)
  
  if 'legend' in kwargs:
    legend = kwargs['legend']
    del kwargs['legend']
  else:
    legend=''

  drawer.AddMol(mol,**kwargs)

  if legend:
    from rdkit.Chem.Draw.MolDrawing import Font
    bbox = drawer.boundingBoxes[mol]
    pos = size[0]/2,int(.94*size[1]),0 # the 0.94 is extremely empirical
    # canvas.addCanvasPolygon(((bbox[0],bbox[1]),(bbox[2],bbox[1]),(bbox[2],bbox[3]),(bbox[0],bbox[3])),
    #                         color=(1,0,0),fill=False,stroke=True)
    # canvas.addCanvasPolygon(((0,0),(0,size[1]),(size[0],size[1]),(size[0],0)   ),
    #                         color=(0,0,1),fill=False,stroke=True)
    font=Font(face='sans',size=12)
    canvas.addCanvasText(legend,pos,font)

  if kwargs.get('returnCanvas',False):
    return img,canvas,drawer
  else:
    canvas.flush()
    return img
开发者ID:dfhahn,项目名称:rdkit,代码行数:87,代码来源:__init__.py

示例7: MolToImage

# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import wedgeDashedBonds [as 别名]
def MolToImage(mol, size=(300, 300), kekulize=True, wedgeBonds=True,
               fitImage=False, options=None, canvas=None, background='white',
               values=None, index=None, canvas_creater=MycreateCanvas,
               mol_adder=MyAddMol, **kwargs):
    """ returns a PIL image containing a drawing of the molecule

    Keyword arguments:
    kekulize -- run kekulization routine on input `mol` (default True)
    size -- final image size, in pixel (default (300,300))
    wedgeBonds -- draw wedge (stereo) bonds (default True)
    highlightAtoms -- list of atoms to highlight (default [])
    highlightMap -- dictionary of (atom, color) pairs (default None)
    highlightBonds -- list of bonds to highlight (default [])
    background: can be given as a string (default = 'white') or as a color code: (250,0,0,0)
    """
    if not mol:
        raise ValueError('Null molecule provided')
    if canvas is None:
        img, canvas = canvas_creater(size, color='white')
    else:
        img = None

    if options is None:
        options = DrawingOptions()
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds = wedgeBonds
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)

    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)

    # noinspection PyArgumentList
    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)

    if 'legend' in kwargs:
        legend = kwargs['legend']
        del kwargs['legend']
    else:
        legend = ''

    if 'symbol' in kwargs:
        symbol = kwargs['symbol']
        del kwargs['symbol']
    else:
        symbol = ''

    # Add a colored border
    if not background == 'white':
        position = [(0, 0), (size[0], 0), (size[0], size[1]), (0, size[1])]
        canvas.addCanvasPolygon(position, fill=True, color=background)
        position = [(5, 5), (size[0] - 5, 5), (size[0] - 5, size[1] - 5), (5, size[1] - 5)]
        canvas.addCanvasPolygon(position, fill=True, color=(250, 250, 250))

    mol_adder(drawer, mol, **kwargs)

    if legend:
        # noinspection PyUnusedLocal
        bbox = drawer.boundingBoxes[mol]
        pos = size[0] / 2, int(.94 * size[1]), 0  # the 0.94 is extremely empirical
        # canvas.addCanvasPolygon(((bbox[0],bbox[1]),(bbox[2],bbox[1]),(bbox[2],bbox[3]),(bbox[0],bbox[3])),
        # color=(1,0,0),fill=False,stroke=True)
        # canvas.addCanvasPolygon(((0,0),(0,size[1]),(size[0],size[1]),(size[0],0) ),
        # color=(0,0,1),fill=False,stroke=True)
        font = Font(face='sans', size=12)
        canvas.addCanvasText(legend, pos, font)

    if symbol:
        # Let's put it (them) in the top left corner of the canas
        pos = size[0] / 10, size[1] / 10, 0
        font = Font(face='sans', size=12)
        canvas.addCanvasText(symbol, pos, font)

    if kwargs.get('returnCanvas', False):
        return img, canvas, drawer
    else:
        canvas.flush()
        return img
开发者ID:sdvillal,项目名称:ccl-malaria,代码行数:84,代码来源:drawing_ala_rdkit.py


注:本文中的rdkit.Chem.Draw.MolDrawing.DrawingOptions.wedgeDashedBonds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。