Re: [Open Babel] smarts matching using the command line
On Mon, Sep 19, 2011 at 11:23 AM, Martin Guetlein < martin.guetl...@googlemail.com> wrote: > On Mon, Sep 19, 2011 at 11:04 AM, Chris Morley > wrote: > > On 19/09/2011 09:32, Martin Guetlein wrote: > >> Hi, > >> > >> I would like to do smarts matching with OpenBabel, and for some > >> reasons I am restricted to use the command line interface. > >> Is there an efficient way to match a range of smarts strings against a > dataset? > >> > >> What I found out is that I could use the "-s" option, but I would have > >> to call babel once for each smarts, right? > > If the SMARTS patterns are sufficiently simple to be SMILES, then they > > can all be put in a file whose name is used with the -s option. The > > matching is OR - any single match will do. The file could be any any > > molecular format, but must have the appropriate extension. > I would have to run this once for each smarts, right? (This would produce quite a file parsing overhead.) > >> > >> A second option I found would be to edit the patterns.txt file and use > >> the FP3 fingerprint ("-ofpt -xfFP3 -xs"). I dont like the idea of > >> editing a file in advance, though (The smarts matching is part of some > >> software I am working on). Is there a way to provide an own patterns > >> file? > > > > You can make your own fingerprint by making a data file with SMARTS > > patterns, like patterns.txt (or with a couple of other slightly > > different formats) and specifying the details by making an entry in a > > plugindefines.txt. The MACCS fingerprint is defined there in this way. > > This looks good, I will give it a try, thanks, > Martin > Hmm, it worked fine in Linux, not for Windows, though. The plugindefines.txt is in a folder that requires admin rights to be edited (C:\Program Files\OpenBabel-2.3.0\data). Is there a way around that? > > > > > > For extra flexibility you could define a compound filter to be used with > > the --filter option, where SMARTS tests can be combined with conditions > > based on other molecular (or SDF type) properties. > Same as for the -s option here, I have to run it once for each smarts, right? Regards, Martin > > > > Chris > > > > > -- > > BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA > > Learn about the latest advances in developing for the > > BlackBerry® mobile platform with sessions, labs & more. > > See new tools and technologies. Register for BlackBerry® DevCon > today! > > http://p.sf.net/sfu/rim-devcon-copy1 > > ___ > > OpenBabel-discuss mailing list > > OpenBabel-discuss@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > > > > > -- > Dipl-Inf. Martin Gütlein > Phone: > +49 (0)761 203 7633 (office) > +49 (0)177 623 9499 (mobile) > Email: > guetl...@informatik.uni-freiburg.de > -- Dipl-Inf. Martin Gütlein Phone: +49 (0)761 203 7633 (office) +49 (0)177 623 9499 (mobile) Email: guetl...@informatik.uni-freiburg.de -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
Dear all, openbabel.py provides an interface to use python scripts to call C/C++ functions of open babel, in which C built-in datatypes are mapped into the closest Python equivalent. for example: int, long, short <---> Python integers. float, double <---> Python floats char, char * <---> Python strings. However, if a C++ function returns a variable with other datatypes, for example: std:string, How can we deal with that? Below is an example: >>import openbabel as ob >>pat=ob.OBSmartsPatten() >>pat.Init('c1c1') >>pat_str=pat.GetSMARTS() >>print pat_str Since the function GetSMARTS() returns a std::string, the printed result is not "c1c1", but a swig object like sth below: "_20748c03_p_std__string" >>pat_str Does anyone know how to deal with this problem? 2011-09-26 Mingyue Zheng, Ph.D. Drug Discovery and Design Center (DDDC) Box 1201, Shanghai Institute of Materia Medica. No. 555 Rd. Zuchongzhi, Shanghai, China Tel: 86-021-50806600-1308 Email: myzh...@mail.shcnc.ac.cn -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
Is there a reason you need to call GetString()? I would recommend that you work around the problem by storing the strings in the Python script along with the corresponding OBSmartsPattern? The underlying problem is that pointers to objects are not wrapped by the code. This is most easily fixed by changing the API. However, I don't like to do this if the problem can be worked around by the user. - Noel On 26 September 2011 16:59, Mingyue Zheng wrote: > Dear all, > openbabel.py provides an interface to use python scripts to call C/C++ > functions of open babel, > in which C built-in datatypes are mapped into the closest Python equivalent. > for example: > int, long, short <---> Python integers. > float, double <---> Python floats > char, char * <---> Python strings. > However, if a C++ function returns a variable with other datatypes, for > example: std:string, How can we deal with that? > Below is an example: > >>>import openbabel as ob >>>pat=ob.OBSmartsPatten() >>>pat.Init('c1c1') >>>pat_str=pat.GetSMARTS() >>>print pat_str > > Since the function GetSMARTS() returns a std::string, > the printed result is not "c1c1", > but a swig object like sth below: > "_20748c03_p_std__string" >>>pat_str > > > Does anyone know how to deal with this problem? > > 2011-09-26 > > Mingyue Zheng, Ph.D. > Drug Discovery and Design Center (DDDC) > Box 1201, Shanghai Institute of Materia Medica. > No. 555 Rd. Zuchongzhi, Shanghai, China > Tel: 86-021-50806600-1308 > Email: myzh...@mail.shcnc.ac.cn > > > > > -- > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > ___ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
Sorry - meant "GetSMARTS()" not "GetString()"... On 26 September 2011 17:10, Noel O'Boyle wrote: > Is there a reason you need to call GetString()? I would recommend that > you work around the problem by storing the strings in the Python > script along with the corresponding OBSmartsPattern? > > The underlying problem is that pointers to objects are not wrapped by > the code. This is most easily fixed by changing the API. However, I > don't like to do this if the problem can be worked around by the user. > > - Noel > > On 26 September 2011 16:59, Mingyue Zheng wrote: >> Dear all, >> openbabel.py provides an interface to use python scripts to call C/C++ >> functions of open babel, >> in which C built-in datatypes are mapped into the closest Python equivalent. >> for example: >> int, long, short <---> Python integers. >> float, double <---> Python floats >> char, char * <---> Python strings. >> However, if a C++ function returns a variable with other datatypes, for >> example: std:string, How can we deal with that? >> Below is an example: >> import openbabel as ob pat=ob.OBSmartsPatten() pat.Init('c1c1') pat_str=pat.GetSMARTS() print pat_str >> >> Since the function GetSMARTS() returns a std::string, >> the printed result is not "c1c1", >> but a swig object like sth below: >> "_20748c03_p_std__string" pat_str >> >> >> Does anyone know how to deal with this problem? >> >> 2011-09-26 >> >> Mingyue Zheng, Ph.D. >> Drug Discovery and Design Center (DDDC) >> Box 1201, Shanghai Institute of Materia Medica. >> No. 555 Rd. Zuchongzhi, Shanghai, China >> Tel: 86-021-50806600-1308 >> Email: myzh...@mail.shcnc.ac.cn >> >> >> >> >> -- >> All the data continuously generated in your IT infrastructure contains a >> definitive record of customers, application performance, security >> threats, fraudulent activity and more. Splunk takes this data and makes >> sense of it. Business sense. IT sense. Common sense. >> http://p.sf.net/sfu/splunk-d2dcopy1 >> ___ >> OpenBabel-discuss mailing list >> OpenBabel-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss >> > -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
Ok, the script I pasted is just an example and meaningless. I just want to know if there is any convenient way to unwrap a swig object like that, without changing the API. Thanks for your reply. 2011-09-27 Mingyue Zheng, Ph.D. Drug Discovery and Design Center (DDDC) Box 1201, Shanghai Institute of Materia Medica. No. 555 Rd. Zuchongzhi, Shanghai, China Tel: 86-021-50806600-1308 Email: myzh...@mail.shcnc.ac.cn FROM:Noel O'Boyle DATE:2011-09-27 00:10:51 TO:Mingyue Zheng CC:openbabel-discuss SUBJECT:Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py Is there a reason you need to call GetString()? I would recommend that you work around the problem by storing the strings in the Python script along with the corresponding OBSmartsPattern? The underlying problem is that pointers to objects are not wrapped by the code. This is most easily fixed by changing the API. However, I don't like to do this if the problem can be worked around by the user. - Noel On 26 September 2011 16:59, Mingyue Zheng wrote: > Dear all, > openbabel.py provides an interface to use python scripts to call C/C++ > functions of open babel, > in which C built-in datatypes are mapped into the closest Python equivalent. > for example: > int, long, short <---> Python integers. > float, double <---> Python floats > char, char * <---> Python strings. > However, if a C++ function returns a variable with other datatypes, for > example: std:string, How can we deal with that? > Below is an example: > >>>import openbabel as ob >>>pat=ob.OBSmartsPatten() >>>pat.Init('c1c1') >>>pat_str=pat.GetSMARTS() >>>print pat_str > > Since the function GetSMARTS() returns a std::string, > the printed result is not "c1c1", > but a swig object like sth below: > "_20748c03_p_std__string" >>>pat_str > > > Does anyone know how to deal with this problem? > > 2011-09-26 > > Mingyue Zheng, Ph.D. > Drug Discovery and Design Center (DDDC) > Box 1201, Shanghai Institute of Materia Medica. > No. 555 Rd. Zuchongzhi, Shanghai, China > Tel: 86-021-50806600-1308 > Email: myzh...@mail.shcnc.ac.cn > > > > > -- > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > ___ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
After checking this some more, I found this (http://old.nabble.com/Printing-std%3Astring---return-param-in-python-td30668781.html), and saw that it should work for OB as it is returning a const reference to a std::string: const std::string& GetSMARTS() const The problem is that this seems to be shadowed by the non-const version which is also there. Once I made a change to the header file, it seems to pick up on the const version fine: >>> import pybel >>> print pybel.Smarts("CC").obsmarts.GetSMARTS() CC If you want to see the details of what I changed, go to http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/trunk/include/openbabel/parsmart.h?r1=4610&r2=4609&pathrev=4610 - Noel On 26 September 2011 17:32, Mingyue Zheng wrote: > Ok, the script I pasted is just an example and meaningless. I just want to > know if there is any convenient way to unwrap a swig object like that, > without changing the API. > Thanks for your reply. > > 2011-09-27 > > Mingyue Zheng, Ph.D. > Drug Discovery and Design Center (DDDC) > Box 1201, Shanghai Institute of Materia Medica. > No. 555 Rd. Zuchongzhi, Shanghai, China > Tel: 86-021-50806600-1308 > Email: myzh...@mail.shcnc.ac.cn > > > > FROM:Noel O'Boyle > DATE:2011-09-27 00:10:51 > TO:Mingyue Zheng > CC:openbabel-discuss > SUBJECT:Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py > > Is there a reason you need to call GetString()? I would recommend that > you work around the problem by storing the strings in the Python > script along with the corresponding OBSmartsPattern? > > The underlying problem is that pointers to objects are not wrapped by > the code. This is most easily fixed by changing the API. However, I > don't like to do this if the problem can be worked around by the user. > > - Noel > > On 26 September 2011 16:59, Mingyue Zheng wrote: >> Dear all, >> openbabel.py provides an interface to use python scripts to call C/C++ >> functions of open babel, >> in which C built-in datatypes are mapped into the closest Python equivalent. >> for example: >> int, long, short <---> Python integers. >> float, double <---> Python floats >> char, char * <---> Python strings. >> However, if a C++ function returns a variable with other datatypes, for >> example: std:string, How can we deal with that? >> Below is an example: >> import openbabel as ob pat=ob.OBSmartsPatten() pat.Init('c1c1') pat_str=pat.GetSMARTS() print pat_str >> >> Since the function GetSMARTS() returns a std::string, >> the printed result is not "c1c1", >> but a swig object like sth below: >> "_20748c03_p_std__string" pat_str >> >> >> Does anyone know how to deal with this problem? >> >> 2011-09-26 >> >> Mingyue Zheng, Ph.D. >> Drug Discovery and Design Center (DDDC) >> Box 1201, Shanghai Institute of Materia Medica. >> No. 555 Rd. Zuchongzhi, Shanghai, China >> Tel: 86-021-50806600-1308 >> Email: myzh...@mail.shcnc.ac.cn >> >> >> >> >> -- >> All the data continuously generated in your IT infrastructure contains a >> definitive record of customers, application performance, security >> threats, fraudulent activity and more. Splunk takes this data and makes >> sense of it. Business sense. IT sense. Common sense. >> http://p.sf.net/sfu/splunk-d2dcopy1 >> ___ >> OpenBabel-discuss mailing list >> OpenBabel-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss >> > -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py
Hi Noel, Great! Many thanks for your quick response and fix. Regards, Mingyue 2011-09-27 Mingyue Zheng, Ph.D. Drug Discovery and Design Center (DDDC) Box 1201, Shanghai Institute of Materia Medica. No. 555 Rd. Zuchongzhi, Shanghai, China Tel: 86-021-50806600-1308 Email: myzh...@mail.shcnc.ac.cn FROM:Noel O'Boyle DATE:2011-09-27 02:40:50 TO:Mingyue Zheng CC:openbabel-discuss SUBJECT:Re: Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py After checking this some more, I found this (http://old.nabble.com/Printing-std%3Astring---return-param-in-python-td30668781.html), and saw that it should work for OB as it is returning a const reference to a std::string: const std::string& GetSMARTS() const The problem is that this seems to be shadowed by the non-const version which is also there. Once I made a change to the header file, it seems to pick up on the const version fine: >>> import pybel >>> print pybel.Smarts("CC").obsmarts.GetSMARTS() CC If you want to see the details of what I changed, go to http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/trunk/include/openbabel/parsmart.h?r1=4610&r2=4609&pathrev=4610 - Noel On 26 September 2011 17:32, Mingyue Zheng wrote: > Ok, the script I pasted is just an example and meaningless. I just want to > know if there is any convenient way to unwrap a swig object like that, > without changing the API. > Thanks for your reply. > > 2011-09-27 > > Mingyue Zheng, Ph.D. > Drug Discovery and Design Center (DDDC) > Box 1201, Shanghai Institute of Materia Medica. > No. 555 Rd. Zuchongzhi, Shanghai, China > Tel: 86-021-50806600-1308 > Email: myzh...@mail.shcnc.ac.cn > > > > FROM:Noel O'Boyle > DATE:2011-09-27 00:10:51 > TO:Mingyue Zheng > CC:openbabel-discuss > SUBJECT:Re: [Open Babel] Fw: Interfacing C/C++ and Python with openbabel.py > > Is there a reason you need to call GetString()? I would recommend that > you work around the problem by storing the strings in the Python > script along with the corresponding OBSmartsPattern? > > The underlying problem is that pointers to objects are not wrapped by > the code. This is most easily fixed by changing the API. However, I > don't like to do this if the problem can be worked around by the user. > > - Noel > > On 26 September 2011 16:59, Mingyue Zheng wrote: >> Dear all, >> openbabel.py provides an interface to use python scripts to call C/C++ >> functions of open babel, >> in which C built-in datatypes are mapped into the closest Python equivalent. >> for example: >> int, long, short <---> Python integers. >> float, double <---> Python floats >> char, char * <---> Python strings. >> However, if a C++ function returns a variable with other datatypes, for >> example: std:string, How can we deal with that? >> Below is an example: >> import openbabel as ob pat=ob.OBSmartsPatten() pat.Init('c1c1') pat_str=pat.GetSMARTS() print pat_str >> >> Since the function GetSMARTS() returns a std::string, >> the printed result is not "c1c1", >> but a swig object like sth below: >> "_20748c03_p_std__string" pat_str >> >> >> Does anyone know how to deal with this problem? >> >> 2011-09-26 >> >> Mingyue Zheng, Ph.D. >> Drug Discovery and Design Center (DDDC) >> Box 1201, Shanghai Institute of Materia Medica. >> No. 555 Rd. Zuchongzhi, Shanghai, China >> Tel: 86-021-50806600-1308 >> Email: myzh...@mail.shcnc.ac.cn >> >> >> >> >> -- >> All the data continuously generated in your IT infrastructure contains a >> definitive record of customers, application performance, security >> threats, fraudulent activity and more. Splunk takes this data and makes >> sense of it. Business sense. IT sense. Common sense. >> http://p.sf.net/sfu/splunk-d2dcopy1 >> ___ >> OpenBabel-discuss mailing list >> OpenBabel-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss >> > -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss