Hi Greg,

thanks that works great.

After trying it out I have another suggestion. With above current
implementation the empty cells in the grid will be transparent (alpha=0)
and hence depending on how the image is used or saved (png vs jpeg) will
not look very nice. Therefore I suggest to either set the default alpha
channel to 255 (white) and/or make it an argument for the user to set.

Best Regards,

Joos

2016-02-16 10:45 GMT+01:00 Greg Landrum <[email protected]>:

> Hi Joos,
>
>
> On Tue, Feb 16, 2016 at 7:34 AM, Joos Kiener <[email protected]>
> wrote:
>
>>
>> I'm trying to draw a grid using Draw.MolsToGridImage. However I have
>> different number of molecules per row. If I use "None" for columns where no
>> molecules should be an exception is thrown (c++ signature does not match,
>> mol vs NoneType).
>>
>> Is there any easy why to to this? Or do I need to roll my own function?
>>
>
> Nice idea, and pretty easy to do. It's a small change to
> $RDBASE/rdkit/Chem/Draw/__init__.py to ignore None :
>
> glandrum@Otter:/scratch/RDKit_git/rdkit/Chem/Draw$ git diff -w
> diff --git a/rdkit/Chem/Draw/__init__.py b/rdkit/Chem/Draw/__init__.py
> index 08df30a..f7742f3 100644
> --- a/rdkit/Chem/Draw/__init__.py
> +++ b/rdkit/Chem/Draw/__init__.py
> @@ -315,8 +315,10 @@ def
> MolsToGridImage(mols,molsPerRow=3,subImgSize=(200,200),legends=None,
>      highlights=None
>      if highlightAtomLists and highlightAtomLists[i]:
>        highlights=highlightAtomLists[i]
> -
>  
> res.paste(MolToImage(mol,subImgSize,legend=legends[i],highlightAtoms=highlights,
> -                         **kwargs),(col*subImgSize[0],row*subImgSize[1]))
> +    if mol is not None:
> +      img =
> MolToImage(mol,subImgSize,legend=legends[i],highlightAtoms=highlights,
> +                           **kwargs)
> +      res.paste(img,(col*subImgSize[0],row*subImgSize[1]))
>    return res
>
>  def ReactionToImage(rxn, subImgSize=(200,200),**kwargs):
>
> We'll get this checked in on github in the next day or so.
>
> -greg
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to