本文整理汇总了Python中rdkit.Chem.Draw.MolDrawing.DrawingOptions.bgColor方法的典型用法代码示例。如果您正苦于以下问题:Python DrawingOptions.bgColor方法的具体用法?Python DrawingOptions.bgColor怎么用?Python DrawingOptions.bgColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem.Draw.MolDrawing.DrawingOptions
的用法示例。
在下文中一共展示了DrawingOptions.bgColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MolToQPixmap
# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import bgColor [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
示例2: MolToMPL
# 需要导入模块: from rdkit.Chem.Draw.MolDrawing import DrawingOptions [as 别名]
# 或者: from rdkit.Chem.Draw.MolDrawing.DrawingOptions import bgColor [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