Re: [Rdkit-discuss] Chem.PandasTools

2014-05-09 Thread Paul . Czodrowski
Dear Samo et al.,

thanks for the code, Samo!

"mmp" is correctly depicted as reaction.

However, the depiction in a pandas data frame does not properly work.

The figure in the data frame is still "depicted" as
 You can create new object that stores MMP and has default pandas and
> ipython representation as base64 encoded png. This usually works for
> me, but I'm not sure why in this case it works only for ipython 
> representation and not for pandas.. The code:
> 
> [...]
> Regards,
> Samo
> 


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.

--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-09 Thread Samo Turk
Hi,

You can create new object that stores MMP and has default pandas and
ipython representation as base64 encoded png. This usually works for me,
but I'm not sure why in this case it works only for ipython representation
and not for pandas.. The code:

# 

import pandas as pd
import rdkit.Chem as Chem
from rdkit.Chem import PandasTools
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole

# 

from base64 import b64encode
from StringIO import StringIO

class Reaction():
def __init__(self, reaction=None):
self.reaction = reaction

def _repr_html_(self):
sio = StringIO()
Draw.ReactionToImage(self.reaction).save(sio,format='PNG')
s = b64encode(sio.getvalue())
return '' %s
def __str__(self):
sio = StringIO()
Draw.ReactionToImage(self.reaction).save(sio,format='PNG')
s = b64encode(sio.getvalue())
return '' %s

# 

MMP_reaction = Chem.rdChemReactions.ReactionFromSmarts("[*:1][H]>>[*:1]C")

# 

mmp = Reaction(MMP_reaction)

# 

mmp

# 

newnew_df = pd.DataFrame(columns=['fig'],index=[1] )
newnew_df['fig'].ix[1] = mmp

# 

newnew_df

# 


Regards,
Samo


On Fri, May 9, 2014 at 8:19 AM,  wrote:

> Dear Grégori,
>
> when storing the image into a new data frame:
> "
> MMP_reaction = Chem.rdChemReactions.ReactionFromSmarts("[*:1][H]>>[*:1]C")
> newnew_df = pd.DataFrame(columns=['fig'],index=[1] )
> newnew_df['fig'].ix[1] = Draw.ReactionToImage(MMP_reaction)
> "
>
> apparently, the image can be stored in a data frame, but in the ipython
> notebook it is displayed as "
>
>
> Cheers & Thanks so far (in particular for the impressive speed in
> response!),
> Paul
>
> > Hi Paul,
> >
> > You first have to read the MMP into a reaction object
> > (Chem.ReactionFromSmarts).
> >
> > Greg
> >
> > On Friday, May 9, 2014,  wrote:
> > Dear Gregori & Samo,
> >
> > thanks for your hints.
> >
> > I just tried running
> >
> > Draw.ReactionToImage("[*:1][H]>>[*:1]C")
> >
> > =>
> >
> > AttributeError: 'str' object has no attribute 'GetNumReactantTemplates'
> >
> >
> >
> > BTW, how would I finally add a picture to a Pandas data frame?
> >
> >
> > Cheers,
> > Paul
>
>
> 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.
>
>
> --
> Is your legacy SCM system holding you back? Join Perforce May 7 to find
> out:
> • 3 signs your SCM is hindering your productivity
> • Requirements for releasing software faster
> • Expert tips and advice for migrating your SCM now
> http://p.sf.net/sfu/perforce
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Paul . Czodrowski
Dear Grégori, 

when storing the image into a new data frame:
"
MMP_reaction = Chem.rdChemReactions.ReactionFromSmarts("[*:1][H]>>[*:1]C")
newnew_df = pd.DataFrame(columns=['fig'],index=[1] )
newnew_df['fig'].ix[1] = Draw.ReactionToImage(MMP_reaction)
"

apparently, the image can be stored in a data frame, but in the ipython 
notebook it is displayed as " Hi Paul,
> 
> You first have to read the MMP into a reaction object 
> (Chem.ReactionFromSmarts).
> 
> Greg
> 
> On Friday, May 9, 2014,  wrote:
> Dear Gregori & Samo,
> 
> thanks for your hints.
> 
> I just tried running
> 
> Draw.ReactionToImage("[*:1][H]>>[*:1]C")
> 
> =>
> 
> AttributeError: 'str' object has no attribute 'GetNumReactantTemplates'
> 
> 
> 
> BTW, how would I finally add a picture to a Pandas data frame?
> 
> 
> Cheers,
> Paul


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.

--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Gerebtzoff, Gregori
Hi Paul,

You first have to read the MMP into a reaction object
(Chem.ReactionFromSmarts).

Greg

On Friday, May 9, 2014,  wrote:

> Dear Gregori & Samo,
>
> thanks for your hints.
>
> I just tried running
>
> Draw.ReactionToImage("[*:1][H]>>[*:1]C")
>
> =>
>
> AttributeError: 'str' object has no attribute 'GetNumReactantTemplates'
>
>
>
> BTW, how would I finally add a picture to a Pandas data frame?
>
>
> Cheers,
> Paul
>
>
> >
> > Hi Paul,
> >
> > The Draw modules also contains a "ReactionToImage" function;
> > Your MMP can be read as a reaction.
> > Hope this helps further!
> >
> > Grégori
>
>
> 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.
>
--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Paul . Czodrowski
Dear Gregori & Samo,

thanks for your hints.

I just tried running

Draw.ReactionToImage("[*:1][H]>>[*:1]C")

=>

AttributeError: 'str' object has no attribute 'GetNumReactantTemplates'



BTW, how would I finally add a picture to a Pandas data frame?


Cheers,
Paul


> 
> Hi Paul,
> 
> The Draw modules also contains a "ReactionToImage" function;
> Your MMP can be read as a reaction.
> Hope this helps further!
> 
> Grégori


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.

--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Gerebtzoff, Gregori
Hi Paul,

The Draw modules also contains a "ReactionToImage" function;
Your MMP can be read as a reaction.
Hope this helps further!

Grégori

Date: Thu, 8 May 2014 16:31:32 +0200
> From: paul.czodrow...@merckgroup.com
> Subject: [Rdkit-discuss] Chem.PandasTools
> To: rdkit-discuss@lists.sourceforge.net
> Message-ID:
> <
> ofc0c168e1.8dc7f4cf-onc1257cd2.004f2cec-c1257cd2.004fc...@merck.de>
> Content-Type: text/plain; charset="US-ASCII"
>
> Dear RDKitters,
>
> I started to play around with the great Chem.PandasTool contribution
> provided by Nicholas and Samo.
>
> Given such a data frame:
> "
> Transformation  npairs
> 1   [*:1][H]>>[*:1]C5
> "
>
> how do I depict the molecular transformation in the dataframe?
>
>
> I guess that I somehow have to integrate this function
> "
> def showLine_MMP(in_string):
> f = in_string.split("\t")
> LHS = Chem.MolFromSmiles(f[0].split(">>")[0])
> RHS = Chem.MolFromSmiles(f[0].split(">>")[1])
> mols.append(LHS)
> mols.append(RHS)
> return Draw.MolsToGridImage(mols,molsPerRow=2)
> "
>
> but I'm not sure how to accomplish this.
>
>
> Cheers & Thanks,
> Paul
>
>
> 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.
>
>
--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Samo Turk
Hi,

I'm not sure if it will work but you can try:
df['new'] = df['Transformation'].map(showLine_MMP)


Regards,
Samo


On Thu, May 8, 2014 at 4:31 PM,  wrote:

> Dear RDKitters,
>
> I started to play around with the great Chem.PandasTool contribution
> provided by Nicholas and Samo.
>
> Given such a data frame:
> "
> Transformation  npairs
> 1   [*:1][H]>>[*:1]C5
> "
>
> how do I depict the molecular transformation in the dataframe?
>
>
> I guess that I somehow have to integrate this function
> "
> def showLine_MMP(in_string):
> f = in_string.split("\t")
> LHS = Chem.MolFromSmiles(f[0].split(">>")[0])
> RHS = Chem.MolFromSmiles(f[0].split(">>")[1])
> mols.append(LHS)
> mols.append(RHS)
> return Draw.MolsToGridImage(mols,molsPerRow=2)
> "
>
> but I'm not sure how to accomplish this.
>
>
> Cheers & Thanks,
> Paul
>
>
> 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.
>
>
> --
> Is your legacy SCM system holding you back? Join Perforce May 7 to find
> out:
> • 3 signs your SCM is hindering your productivity
> • Requirements for releasing software faster
> • Expert tips and advice for migrating your SCM now
> http://p.sf.net/sfu/perforce
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Chem.PandasTools

2014-05-08 Thread Paul . Czodrowski
Dear RDKitters,

I started to play around with the great Chem.PandasTool contribution 
provided by Nicholas and Samo.

Given such a data frame:
"
Transformation  npairs
1   [*:1][H]>>[*:1]C5
"

how do I depict the molecular transformation in the dataframe?


I guess that I somehow have to integrate this function
"
def showLine_MMP(in_string):
f = in_string.split("\t")
LHS = Chem.MolFromSmiles(f[0].split(">>")[0])
RHS = Chem.MolFromSmiles(f[0].split(">>")[1])
mols.append(LHS)
mols.append(RHS)
return Draw.MolsToGridImage(mols,molsPerRow=2)
"

but I'm not sure how to accomplish this.


Cheers & Thanks,
Paul


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.

--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss