Ahh, yes - that would explain it. Apologies for reporting a user error as a bug - however, on the positive side for me, this python lesson is going to stick!
Cheers Jameed -----Original Message----- From: Greg Landrum [mailto:greg.land...@gmail.com] Sent: 10 April 2013 20:37 To: Jameed Hussain Cc: rdkit-discuss@lists.sourceforge.net Subject: Re: [Rdkit-discuss] minor reaction bug Hi Jameed, On Wed, Apr 10, 2013 at 9:07 AM, Jameed Hussain <jameed.x.huss...@gsk.com> wrote: > > Just noticed this bug in the reaction functionality. I want to apply > the following transform: > > [*:1]c1ccc([*:2])o1>>[*:1]c1ccc([*:2])cc1 > > To the following reactant: > > Cc1ccc(CC)o1 > > Code: > > In [1]: from rdkit import Chem > In [2]: from rdkit.Chem import AllChem ]> In [3]: rxn = > AllChem.ReactionFromSmarts('[*:1]c1ccc([*:2])o1>>[*:1]c1ccc([*:2])cc1' > ) > > In [4]: ps = rxn.RunReactants( (Chem.MolFromSmiles('Cc1ccc(CC)o1')) ) > > ---------------------------------------------------------------------- > ----- > > ArgumentError Traceback (most recent call last) > > <ipython-input-4-6b04a2899e4e> in <module>() > > ----> 1 ps = rxn.RunReactants( (Chem.MolFromSmiles('Cc1ccc(CC)o1')) ) > > > > ArgumentError: Python argument types in > > ChemicalReaction.RunReactants(ChemicalReaction, Mol) > > did not match C++ signature: > > RunReactants(RDKit::ChemicalReaction*, boost::python::list) > > RunReactants(RDKit::ChemicalReaction*, boost::python::tuple) > > > > It appears that the RunReactants function expects two reactants and > does not work with just one reactant - this is only the case when you > specify a tuple as the input. If you use a list/array instead, it works fine: You're actually not providing a tuple in the above call. In python you have to use a comma to create a single-element tuple: In [5]: (1) Out[5]: 1 In [6]: (1,) Out[6]: (1,) To look at your example: In [7]: rxn = AllChem.ReactionFromSmarts('[*:1]c1ccc([*:2])o1>>[*:1]c1ccc([*:2])cc1') In [8]: ps = rxn.RunReactants( (Chem.MolFromSmiles('Cc1ccc(CC)o1'),) ) In [9]: Chem.MolToSmiles(ps[0][0]) Out[9]: 'CCc1ccc(C)cc1' -greg ________________________________ This e-mail was sent by GlaxoSmithKline Services Unlimited (registered in England and Wales No. 1047315), which is a member of the GlaxoSmithKline group of companies. The registered address of GlaxoSmithKline Services Unlimited is 980 Great West Road, Brentford, Middlesex TW8 9GS. ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss