From: S J. S. <swa...@gm...> - 2006-06-29 23:51:05
|
Hello, How are we to use OpenBabel::OBTypeTable in python? It seems as if the wrapper is broken. Josh |
From: Geoffrey H. <ge...@ge...> - 2006-06-30 14:54:43
|
On Jun 29, 2006, at 6:50 PM, S Joshua Swamidass wrote: > How are we to use OpenBabel::OBTypeTable in python? > > It seems as if the wrapper is broken. As I don't use Python much myself, I think you'll have to be a bit more specific. What did you try to do that didn't work? What version of the wrapper (and Open Babel) are you using? Thanks, -Geoff |
From: S J. S. <swa...@gm...> - 2006-06-30 18:45:48
|
Geoff, So here is an interactive session which displays the unusability of OBTypeTable: I think the problem lyes in the Translate method. It should be rerwapped ot take a single int as input and return a string or throw an exception. Josh =========================== >>> import openbabel >>> ttab=openbabel.OBTypeTable() >>> ttab.SetToType("SYB") True >>> ttab.SetFromType("INT") True >>> ttab.Translate(1) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/dock/linux/lib/python2.4/site-packages/openbabel.py", line 188, in Translate def Translate(*args): return _openbabel.OBTypeTable_Translate(*args) NotImplementedError: No matching function for overloaded 'OBTypeTable_Translate' >>> ttab.Translate(1,1) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/dock/linux/lib/python2.4/site-packages/openbabel.py", line 188, in Translate def Translate(*args): return _openbabel.OBTypeTable_Translate(*args) NotImplementedError: No matching function for overloaded 'OBTypeTable_Translate' >>> ttab.Translate('1','1') ============================== *** Open Babel Warning in Translate Cannot perform atom type translation: table cannot find requested types. False On 6/30/06, Geoffrey Hutchison <ge...@ge...> wrote: > > On Jun 29, 2006, at 6:50 PM, S Joshua Swamidass wrote: > > > How are we to use OpenBabel::OBTypeTable in python? > > > > It seems as if the wrapper is broken. > > As I don't use Python much myself, I think you'll have to be a bit > more specific. What did you try to do that didn't work? What version > of the wrapper (and Open Babel) are you using? > > Thanks, > -Geoff > |
From: S J. S. <swa...@gm...> - 2006-06-30 18:49:08
|
On second thought, maybe not modified to take a single string OR int (as required) for input and output a stirng OR int (as required). Right now, I think it is output its value by reference through the second arg. This arg isn't being output. A single working example whoudl be very useful. Josh On 6/30/06, S Joshua Swamidass <swa...@gm...> wrote: > Geoff, > > So here is an interactive session which displays the unusability of > OBTypeTable: I think the problem lyes in the Translate method. It > should be rerwapped ot take a single int as input and return a string > or throw an exception. > > Josh > > =========================== > > >>> import openbabel > >>> ttab=openbabel.OBTypeTable() > >>> ttab.SetToType("SYB") > True > >>> ttab.SetFromType("INT") > True > > >>> ttab.Translate(1) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/home/dock/linux/lib/python2.4/site-packages/openbabel.py", > line 188, in Translate > def Translate(*args): return _openbabel.OBTypeTable_Translate(*args) > NotImplementedError: No matching function for overloaded 'OBTypeTable_Translate' > > >>> ttab.Translate(1,1) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/home/dock/linux/lib/python2.4/site-packages/openbabel.py", > line 188, in Translate > def Translate(*args): return _openbabel.OBTypeTable_Translate(*args) > NotImplementedError: No matching function for overloaded 'OBTypeTable_Translate' > > >>> ttab.Translate('1','1') > ============================== > *** Open Babel Warning in Translate > Cannot perform atom type translation: table cannot find requested types. > False > > On 6/30/06, Geoffrey Hutchison <ge...@ge...> wrote: > > > > On Jun 29, 2006, at 6:50 PM, S Joshua Swamidass wrote: > > > > > How are we to use OpenBabel::OBTypeTable in python? > > > > > > It seems as if the wrapper is broken. > > > > As I don't use Python much myself, I think you'll have to be a bit > > more specific. What did you try to do that didn't work? What version > > of the wrapper (and Open Babel) are you using? > > > > Thanks, > > -Geoff > > > |
From: Geoffrey H. <ge...@ge...> - 2006-06-30 20:51:08
|
On Jun 30, 2006, at 2:45 PM, S Joshua Swamidass wrote: > So here is an interactive session which displays the unusability of > OBTypeTable: I think the problem lyes in the Translate method. That might not be a bad idea, but the current code works just fine. If you're looking for examples, you should take a look at the various file format translators, e.g., src/format/tinkerformat.cpp. In general, the current code doesn't use exceptions. Historically, it hasn't always been well supported by >>>> ttab.Translate('1','1') > ============================== > *** Open Babel Warning in Translate > Cannot perform atom type translation: table cannot find requested > types. > False Yes, but "1" isn't a valid INT atom type. (Check data/types.txt if you're curious) I'm also not sure what Python thinks about returning something into the constant string '1'. How about: ttab.Translate(dest, "C3") I bet that works. Check dest for the output. -Geoff |
From: S J. S. <swa...@gm...> - 2006-06-30 20:56:48
|
The problem is that 'dest' is not accessible from the swig wrapped code. You have to specify it as an output typmap for that to work. ttab.Translate(dest, "C3") Doesn't work because in pythong strings are immutable. So the function signature should be changed in the wrapper to be somethign like: dest=ttab.Translate("C3") Once again, this can be done by a typemap in swig (i think). Josh On 6/30/06, Geoffrey Hutchison <ge...@ge...> wrote: > > On Jun 30, 2006, at 2:45 PM, S Joshua Swamidass wrote: > > > So here is an interactive session which displays the unusability of > > OBTypeTable: I think the problem lyes in the Translate method. > > That might not be a bad idea, but the current code works just fine. > If you're looking for examples, you should take a look at the various > file format translators, e.g., src/format/tinkerformat.cpp. > > In general, the current code doesn't use exceptions. Historically, it > hasn't always been well supported by > > >>>> ttab.Translate('1','1') > > ============================== > > *** Open Babel Warning in Translate > > Cannot perform atom type translation: table cannot find requested > > types. > > False > > Yes, but "1" isn't a valid INT atom type. (Check data/types.txt if > you're curious) I'm also not sure what Python thinks about returning > something into the constant string '1'. > > How about: > ttab.Translate(dest, "C3") > > I bet that works. Check dest for the output. > > -Geoff > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |
From: S J. S. <swa...@gm...> - 2006-07-03 05:14:39
|
Hello All, I found a fix for this problem in the babel wrapper. Add this line right before the %import "data.h" line in the openbabel.i file. %apply std::string &OUTPUT { std::string &to }; The only problem is that this fix exposes a bug in the swig wrapper code, causing a leak. This leak is a documented bug set to be fixed in the near future. I think it is worth adding this line right now anyway because this fucntion is rarely called from python and the bug should be fixed in the near future. Also, without this line, the Translage methods output is completely unaccessable from python. ALSO, it should be possible using the swig exception handler to make all functions using bool to throw python exceptions. Please let me know if this is worth the effort. Thanks! Josh On 6/30/06, S Joshua Swamidass <swa...@gm...> wrote: > The problem is that 'dest' is not accessible from the swig wrapped > code. You have to specify it as an output typmap for that to work. > > ttab.Translate(dest, "C3") > > Doesn't work because in pythong strings are immutable. So the function > signature should be changed in the wrapper to be somethign like: > > dest=ttab.Translate("C3") > > Once again, this can be done by a typemap in swig (i think). > > Josh > > On 6/30/06, Geoffrey Hutchison <ge...@ge...> wrote: > > > > On Jun 30, 2006, at 2:45 PM, S Joshua Swamidass wrote: > > > > > So here is an interactive session which displays the unusability of > > > OBTypeTable: I think the problem lyes in the Translate method. > > > > That might not be a bad idea, but the current code works just fine. > > If you're looking for examples, you should take a look at the various > > file format translators, e.g., src/format/tinkerformat.cpp. > > > > In general, the current code doesn't use exceptions. Historically, it > > hasn't always been well supported by > > > > >>>> ttab.Translate('1','1') > > > ============================== > > > *** Open Babel Warning in Translate > > > Cannot perform atom type translation: table cannot find requested > > > types. > > > False > > > > Yes, but "1" isn't a valid INT atom type. (Check data/types.txt if > > you're curious) I'm also not sure what Python thinks about returning > > something into the constant string '1'. > > > > How about: > > ttab.Translate(dest, "C3") > > > > I bet that works. Check dest for the output. > > > > -Geoff > > > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > OpenBabel-scripting mailing list > > Ope...@li... > > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > > |