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 > > > |