Dear Andrew,

thanks for the follow-up!

The situation is getting complicated, since your hack did not help.

This is the new code
"
if __name__=='__main__':
  import sys
  from rdkit import Chem
  from rdkit.Chem import AllChem
  from rdkit.Chem import Draw
  from rdkit.Chem.Draw import MolDrawing
  MolDrawing.MolDrawing.atomLabelFontFace = "sansserif"

  smi = open(sys.argv[1]).readlines()[0].rstrip()
  outF = sys.argv[2]
  mol = Chem.MolFromSmiles(smi)

  AllChem.Compute2DCoords(mol)
  Draw.MolToImageFile(mol, outF)
"



And this is the new error message:
"
  File "rdkit_smi2png.py", line 14, in <module>
    Draw.MolToImageFile(mol, outF)
  File
"/SW/python/x86_64_cs4/2.7/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.py",
 line 142, in MolToImageFile
    img = MolToImage
(mol,size=size,kekulize=kekulize,wedgeBonds=wedgeBonds,**kwargs)
  File
"/SW/python/x86_64_cs4/2.7/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.py",
 line 82, in MolToImage
    drawer.AddMol(mol,**kwargs)
  File
"/SW/python/x86_64_cs4/2.7/lib/python2.7/site-packages/rdkit/Chem/Draw/MolDrawing.py",
 line 463, in AddMol
    self._drawLabel(symbol, pos, font, color=color,orientation=orient)
  File
"/SW/python/x86_64_cs4/2.7/lib/python2.7/site-packages/rdkit/Chem/Draw/MolDrawing.py",
 line 279, in _drawLabel
    self.canvas.addCanvasText(label,(x1,y1),font,color,**kwargs)
  File
"/SW/python/x86_64_cs4/2.7/lib/python2.7/site-packages/rdkit/Chem/Draw/spingCanvas.py",
 line 67, in addCanvasText
    font = pid.Font(face=faceMap[font.face],size=font.size)
KeyError: 'sansserif'
"


Does this mean that there is no PIL sansserif font installed?


Cheers & Thanks,
Paul


> > What font are you using?
>
>
> Ahh, you showed the code. It uses the default, which is from
> rdkit/Chem/Draw/MolDrawing.py and is "sans"
>
> Could you try this?
>
> from rdkit.Chem.Draw import MolDrawing
> MolDrawing.MolDrawing.atomLabelFontFace = "sansserif"
>
> This forces the default to be "sansserif" instead of "sans"
>
> If this works, then the fix for RDKit is either to change
> the setting in MolDrawing to "sansserif" or to change
>
> rdkit/sping/PIL/pidPIL.py:
>
> def _pilFontPath(face,size,bold=0):
>   if face == 'monospaced': face = 'courier'
>   elif face == 'serif': face = 'times'
>   elif face == 'sansserif' or face == 'system': face = 'helvetica'
>
> so that "face == 'sans'" is another alias for helvetica.
>
> Cheers,
>
>             Andrew
>             [email protected]

This message and any attachment are confidential and may be privileged or
otherwise protected from disclosure. If you are not the intended recipient,
you must not copy this message or attachment or disclose the contents to
any other person. If you have received this transmission in error, please
notify the sender immediately and delete the message and any attachment
from your system. Merck KGaA, Darmstadt, Germany and any of its
subsidiaries do not accept liability for any omissions or errors in this
message which may arise as a result of E-Mail-transmission or for damages
resulting from any unauthorized changes of the content of this message and
any attachment thereto. Merck KGaA, Darmstadt, Germany and any of its
subsidiaries do not guarantee that this message is free of viruses and does
not accept liability for any damages caused by any virus transmitted
therewith.

Click http://www.merckgroup.com/disclaimer to access the German, French,
Spanish and Portuguese versions of this disclaimer.


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to