Re: [Rdkit-devel] Adding RDKit::ROMol *s to a boost::python::list

2017-07-17 Thread Paul Emsley


So, to wind up and answer the question... and for future reference for myself in 5 years 
time perhaps.


I did indeed need to wrap the RDKit::ROMol * - with a boost shared pointer.

 RDKit::ROMol *cm_p = new RDKit::ROMol(rdkm);
 boost::shared_ptr xx(cm_p);
 boost::python::object obj(xx);
 rdkit_mols_list.append(obj);


On 16/07/2017 20:32, Paul Emsley wrote:


Oh good grief...

I did a bit of googling: "python::object RDKit::ROMol" to see if I could find someone having 
similar problems:


The first non-rdkit page was this:

ftp://ftp.ccp4.ac.uk/ccp4/7.0/unpacked/checkout/coot-0.8.2/lbg/qed-interface.cc

i.e... Just what I needed - hooray - it was the same problem!

But... Hmm... that's not surprising - it's code I had written 5 years ago and had forgotten 
about (quite likely after having asked on the list a similar question :-)).


Cheers,

Paul.


On 16/07/2017 16:58, Greg Landrum wrote:
It's been a while since I've seen one of these, but could it be that you either haven't 
imported rdkit.Chem (in Python) before calling the function that returns the RDKit 
molecule or that your extension module is linked against a different rdkit library than 
the rdkit extension module that you're using?


-greg


On Sun, Jul 16, 2017 at 4:40 PM, Paul Emsley > wrote:



Hi,

I'd like to bring to python a function that returns a list (or vector?) of 
RDKit
molecules. But I am lost in boost::python.

BOOST_PYTHON_MODULE(pyrogen) {
def("extract_ligands_from_coords_file", 
coot::extract_ligands_from_coords_file);
}

boost::python::list
coot::extract_ligands_from_coords_file(const std::string _name) {

boost::python::list rdkit_mols_list;
std::vector mols_vec = my_get_mols(file_name);
for(unsigned int i=0; i>> m = pyrogen.extract_ligands_from_coords_mol('test.pdb')
TypeError: No to_python (by-value) converter found for C++ type: 
RDKit::ROMol

I am not sure what I should do (instead). At a guess, maybe I need to 
convert/wrap the
mols_vec[i] before using it in append()? Please advise.

Thanks,

Paul.




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel


Re: [Rdkit-devel] Adding RDKit::ROMol *s to a boost::python::list

2017-07-16 Thread Paul Emsley


Oh good grief...

I did a bit of googling: "python::object RDKit::ROMol" to see if I could find someone having 
similar problems:


The first non-rdkit page was this:

ftp://ftp.ccp4.ac.uk/ccp4/7.0/unpacked/checkout/coot-0.8.2/lbg/qed-interface.cc

i.e... Just what I needed - hooray - it was the same problem!

But... Hmm... that's not surprising - it's code I had written 5 years ago and had forgotten 
about (quite likely after having asked on the list a similar question :-)).


Cheers,

Paul.


On 16/07/2017 16:58, Greg Landrum wrote:
It's been a while since I've seen one of these, but could it be that you either haven't 
imported rdkit.Chem (in Python) before calling the function that returns the RDKit molecule 
or that your extension module is linked against a different rdkit library than the rdkit 
extension module that you're using?


-greg


On Sun, Jul 16, 2017 at 4:40 PM, Paul Emsley > wrote:



Hi,

I'd like to bring to python a function that returns a list (or vector?) of 
RDKit
molecules. But I am lost in boost::python.

BOOST_PYTHON_MODULE(pyrogen) {
def("extract_ligands_from_coords_file", 
coot::extract_ligands_from_coords_file);
}

boost::python::list
coot::extract_ligands_from_coords_file(const std::string _name) {

boost::python::list rdkit_mols_list;
std::vector mols_vec = my_get_mols(file_name);
for(unsigned int i=0; i>> m = pyrogen.extract_ligands_from_coords_mol('test.pdb')
TypeError: No to_python (by-value) converter found for C++ type: 
RDKit::ROMol

I am not sure what I should do (instead). At a guess, maybe I need to 
convert/wrap the
mols_vec[i] before using it in append()? Please advise.

Thanks,

Paul.




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel


Re: [Rdkit-devel] Adding RDKit::ROMol *s to a boost::python::list

2017-07-16 Thread Greg Landrum
It's been a while since I've seen one of these, but could it be that you
either haven't imported rdkit.Chem (in Python) before calling the function
that returns the RDKit molecule or that your extension module is linked
against a different rdkit library than the rdkit extension module that
you're using?

-greg


On Sun, Jul 16, 2017 at 4:40 PM, Paul Emsley 
wrote:

>
> Hi,
>
> I'd like to bring to python a function that returns a list (or vector?) of
> RDKit molecules. But I am lost in boost::python.
>
> BOOST_PYTHON_MODULE(pyrogen) {
>def("extract_ligands_from_coords_file", coot::extract_ligands_from_coo
> rds_file);
> }
>
> boost::python::list
> coot::extract_ligands_from_coords_file(const std::string _name) {
>
>boost::python::list rdkit_mols_list;
>std::vector mols_vec = my_get_mols(file_name);
>for(unsigned int i=0; i   rdkit_mols_list.append(mols_vec[i]);
>}
>return rdkit_mols_list;
> }
>
> When I try to use it:
>
> >>> m = pyrogen.extract_ligands_from_coords_mol('test.pdb')
> TypeError: No to_python (by-value) converter found for C++ type:
> RDKit::ROMol
>
> I am not sure what I should do (instead). At a guess, maybe I need to
> convert/wrap the mols_vec[i] before using it in append()? Please advise.
>
> Thanks,
>
> Paul.
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-devel mailing list
> Rdkit-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-devel
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel