本文整理匯總了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