Re: [Rdkit-discuss] PyObject * - RDKit::ROMol *

2012-04-30 Thread Uwe Hoffmann
Hi,
Am 29.04.2012 16:19, schrieb Paul Emsley:

 I am trying to write a C++ function to examine an RDKit::ROMol... but
 running it from a python script:

 m = Chem.MolFromSmilesString('Oc1c1')
 do_cool_stuff(m)

 my C++ (which gets swigged) is:

 PyObject *do_cool_stuff(PyObject *pyo) {

  RDKit::ROMol *mol = magic(pyo);
using a reference instead of pointer access:

RDKit::ROMol  mol = boost::python::extractRDKit::ROMol(m);

via pointer access:

RDKit::ROMol  *mol;
mol=boost::python::extractRDKit::ROMol*(m);

  inner_cool_stuff(mol);
  ...

Regards

Uwe


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] PyObject * - RDKit::ROMol *

2012-04-30 Thread Paul Emsley
On 30/04/12 08:39, Uwe Hoffmann wrote:
 Hi,
 Am 29.04.2012 16:19, schrieb Paul Emsley:

 I am trying to write a C++ function to examine an RDKit::ROMol... but
 running it from a python script:

 m = Chem.MolFromSmilesString('Oc1c1')
 do_cool_stuff(m)

 my C++ (which gets swigged) is:

 PyObject *do_cool_stuff(PyObject *pyo) {

   RDKit::ROMol *mol = magic(pyo);
 using a reference instead of pointer access:

 RDKit::ROMolmol = boost::python::extractRDKit::ROMol(m);



Ah!  Magic!  Just what I wanted.

(actually, I forgot that Greg was away, or I would have held back on 
sending this :-)

Cheers,

Paul.



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Molecule with no atoms, so is it valid?

2012-04-30 Thread Jan Holst Jensen
On 2012-04-30 13:41, Paul Emsley wrote:
 On 30/04/12 01:03, Eddie Cao wrote:
 Hi Andrew,

 I also prefer #2. #1 is not quite sensible because many readers like 
 MolFromSmiles will return None on failure and it will be hard to distinguish 
 bad input from an empty one if we choose to do #1. Semantically, in many 
 RDKit use cases, None and Empty Mol are as different as a webpage not found 
 (HTTP 404) and a blank web page.
 FWIW, I agree to #2 too.

 Paul.

My humble opinion would also be that #2 is the best option. In line with 
the analogy given by Eddie, treating an empty molecule as an error is 
equivalent to saying that a blank string is equal to NULL - which would 
be unfortunate, since there is a big semantic difference.

Also, imagine that you delete all atoms and bonds in a molecule in order 
to replace them. Enforcing the semantics of empty molecules are 
invalid should then cause your code to break half-way through the process ?

Cheers
-- Jan Holst Jensen

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Failed Expression: pick = 0

2012-04-30 Thread Andrew Dalke
I'm desalting the ChEMBL data set and generating the corresponding de-salted SD 
and SMILES files. I found a problem in the conversion step, and found that the 
problem has nothing to do with the de-salting.

My code failed with CHEMBL1269997, which is record ~750,200 out of 1,142,974. 
(In other words, it took a while to get to this point.) Here's a reproducible:

 from rdkit import Chem
 writer = Chem.SDWriter(/dev/stdout)
 for mol in Chem.ForwardSDMolSupplier(CHEMBL1269997.sdf):
...   writer.write(mol)
... 
[22:11:05] 


Invariant Violation

Violation occurred on line 388 in file 
/tmp/homebrew-rdkit-HEAD-Ebdo/Code/GraphMol/FileParsers/MolFileStereochem.cpp
Failed Expression: pick = 0


Traceback (most recent call last):
 File stdin, line 2, in module
RuntimeError: Invariant Violation
 Chem.MolToSmiles(mol)
'OCC1=CC2OC(CC(C)C)(CC(C)C)C3C456C(OC(C)(C)O5)C1(O)C46C23'
 Chem.MolToSmiles(mol, isomericSmiles=True)
'OCC1=C[C@@H]2OC(CC(C)C)(CC(C)C)[C@@H]3[C@H]4CCC[C@@]56[C@@H](OC(C)(C)O5)[C@]1(O)[C@]46[C@H]23'
 

You can see that the molecule was read in, is not None, and can be used to 
generate a SMILES.

The CHEMBL1269997.sdf is attached.

This error was previously reported in the thread JP started, titled Invariant 
violation..., dated July 6, 2011. Greg replied:

 Wow that is certainly an error I never expected to see. From the code,
 I guess the molecule has a stereocenter that is surrounded by other
 stereocenters and something extremely unfortunate is happening with
 the way decisions are being made about which bonds to wedge. As Eddie
 requested in an earlier message, it would be helpful to have the input
 that produced the error so that it can be added to the test cases (and
 so that I can be sure the problem is fixed once I figure out how to).

but I see no posting of a failing structure. I hope the attached structure 
helps resolve this problem.



Andrew
da...@dalkescientific.com



CHEMBL1269997.sdf
Description: Binary data
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss