|
From: Noel O'B. <bao...@gm...> - 2007-05-17 11:46:12
|
On 17/05/07, Jens Thomas <j.m...@dl...> wrote: > Hi Noel, > > I've just worked out that the problem arose because I hadn't installed > anything and was running it directly from the build directory. I assume > it looks in a set directory for the files to dynamically configure the > supported formats. Can this be changed with an environment variable? The answer is yes.You need to set LD_LIBRARY_PATH to point to the directory containing libopenbabel.so, etc. You still need to run "make install" beforehand, though, to install all the formats to the correct location. I describe both "local" and "global" intalls on the wiki page. > Anyway, it's not important as once I'd installed everything into a > directory structure it then worked fine. > I should probably mention that I hit problems with the default version > of SWIG on Ubuntu wasn't able to handle the "-naturalvar" flag, so I had > to install swig 1.3.31 to get the build to work. I will add this to the install notes. > Many thanks for your help. > > Jens > > Noel O'Boyle wrote: > > The good news is that all the Python stuff seems to be working fine > > (no initialisation necessary). The bad news is that the C++ stuff > > isn't working properly. > > > > I'm betting that if you try "babel -H" and look under "The following > > file formats are recognized", you will see nothing there. Which is > > what you're also seeing in python. To verify, try to convert a file > > using babel. This is because the file formats are loaded dynamically > > as plugins, so there can be problems if you compile with particular > > settings. > > > > How exactly are you compiling the software? Did you follow the > > instructions on the web exactly (see > > http://openbabel.sourceforge.net/wiki/Install_%28source_code%29), or > > are you doing something different? I'm using an old version of Ubuntu > > myself, so there's no reason we can't get it to work. > > > > Regards > > Noel > > > > On 15/05/07, Jens Thomas <j.m...@dl...> wrote: > >> Hello! > >> > >> It's taken me a little while to grind through all the usual little > >> hiccups that come when building an unfamiliar code straight out of the > >> repository, but I've now got what (I think) is the correct version. > >> > >> I checked out the code at r1954 and patched with r1958 as suggested > >> by Noel. > >> > >> However, I'm not getting anything from pybel.informats or > >> OBConversion.GetSupportedInputFormats as shown below: > >> > >> > >> Python 2.4.3 (#2, Oct 6 2006, 07:52:30) > >> [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 > >> Type "help", "copyright", "credits" or "license" for more information. > >> >>> import pybel > >> >>> pybel.informats > >> {} > >> >>> pybel.outformats > >> {} > >> >>> import openbabel > >> >>> obc = openbabel.OBConversion() > >> >>> i= obc.GetSupportedInputFormat() > >> >>> print i > >> () > >> >>> dir(i) > >> ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', > >> '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', > >> '__getslice__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', > >> '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', > >> '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__str__'] > >> > >> > >> Is there some sort of initialisation I need to do to get the dictionary > >> populated? > >> > >> Many thanks, > >> > >> Jens > >> > >> Noel O'Boyle wrote: > >> > I've already noticed that the latest SVN is not compatible with SWIG > >> > due to changes introducted at r1954. You'll need to check out r1953, > >> > and use "svn merge -r 1957:1958" to patch with r1958. > >> > > >> > Noel > >> > > >> > On 14/05/07, Jens Thomas <j.m...@dl...> wrote: > >> >> Hi Noel, Jerome and Chris, > >> >> > >> >> Firstly, many thanks for the quick response and warm welcome to the > >> >> list! Please accept my apologies for not replying sooner, but I've > >> been > >> >> away without access to email. > >> >> > >> >> I've tried checking out the latest version of openbabel from SVN > >> onto my > >> >> Ubuntu box (Dapper on a Pentium 4) so that I can try some of the > >> changes > >> >> you've committed. I ran a normal configure (./configure), but the > >> make > >> >> currently fails with: > >> >> > >> >> make[2]: Leaving directory `/home/jmht/openbabel/test/cmltest' > >> >> make[2]: Entering directory `/home/jmht/openbabel/test' > >> >> g++ -DHAVE_CONFIG_H -I. -I../src -I../include > >> >> -DTESTDATADIR="\"../test/files/\"" -g -O2 -MT roundtrip.o -MD > >> -MP -MF > >> >> .deps/roundtrip.Tpo -c -o roundtrip.o roundtrip.cpp > >> >> mv -f .deps/roundtrip.Tpo .deps/roundtrip.Po > >> >> /bin/sh ../libtool --tag=CXX --mode=link g++ -g -O2 -o roundtrip > >> >> roundtrip.o ../src/libopenbabel.la -ldl -lm > >> >> mkdir .libs > >> >> g++ -g -O2 -o .libs/roundtrip roundtrip.o > >> ../src/.libs/libopenbabel.so > >> >> -ldl -lm -Wl,--rpath -Wl,/usr/local/lib > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBFormat::FormatFromMIME(char const*)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBPlugin::Display(std::basic_string<char, > >> >> std::char_traits<char>, std::allocator<char> >&, char const*, char > >> >> const*)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to `vtable for > >> >> OpenBabel::OBDescriptor' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBDescriptor::Compare(OpenBabel::OBBase*, > >> >> std::basic_istream<char, std::char_traits<char> >&, bool)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to `vtable for > >> >> OpenBabel::OBPlugin' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBPlugin::ListAsVector(char const*, char const*, > >> >> std::vector<std::basic_string<char, std::char_traits<char>, > >> >> std::allocator<char> >, std::allocator<std::basic_string<char, > >> >> std::char_traits<char>, std::allocator<char> > > >&)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to `typeinfo for > >> >> OpenBabel::OBPlugin' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBDescriptor::AddProperties(OpenBabel::OBBase*, > >> >> std::basic_string<char, std::char_traits<char>, > >> std::allocator<char> > > >> >> const&)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBDescriptor::GetStringValue(OpenBabel::OBBase*, > >> >> std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> >> >&)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBDescriptor::FilterCompare(OpenBabel::OBBase*, > >> >> std::basic_istream<char, std::char_traits<char> >&, bool)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBFormat::RegisterFormat(char const*, char const*)' > >> >> ../src/.libs/libopenbabel.so: undefined reference to `typeinfo for > >> >> OpenBabel::OBDescriptor' > >> >> ../src/.libs/libopenbabel.so: undefined reference to > >> >> `OpenBabel::OBDescriptor::DeleteProperties(OpenBabel::OBBase*, > >> >> std::basic_string<char, std::char_traits<char>, > >> std::allocator<char> > > >> >> const&)' > >> >> collect2: ld returned 1 exit status > >> >> make[2]: *** [roundtrip] Error 1 > >> >> > >> >> I'm not that familiar with C++ and so am bit stuck as to how to sort > >> >> this one out. > >> >> > >> >> Do you have any suggestions? > >> >> > >> >> Best wishes, > >> >> > >> >> Jens > >> >> > >> >> > >> >> Noel O'Boyle wrote: > >> >> > On 12/05/07, Chris Morley <c.m...@ds...> wrote: > >> >> > > >> >> >> In the revamped code for formats (and other plugins) recently > >> >> committed > >> >> >> to SVN HEAD (for the next OB version) I tried to maintain backward > >> >> >> compatibility as far as possible. So > >> >> OBConversion::SupportedInputFormat() > >> >> >> works as before but, you'll be pleased to hear, without the > >> >> '[Read-only]'. > >> >> >> > >> >> > Sounds good but SWIG doesn't like the new code. When I try to > >> compile > >> >> > openbabel_python.cpp, I get: > >> >> > > >> >> > ../../include/openbabel/fingerprint.h:48: error: 'static > >> >> > std::map<const char*, OpenBabel::OBPlugin*, > >> >> > OpenBabel::OBPlugin::CharPtrLess, std::allocator<std::pair<const > >> char* > >> >> > const, OpenBabel::OBPlugin*> > >& OpenBabel::OBFingerprint::Map()' > >> >> > cannot be overloaded > >> >> > ../../include/openbabel/fingerprint.h:43: error: with 'static > >> >> > std::map<const char*, OpenBabel::OBPlugin*, > >> >> > OpenBabel::OBPlugin::CharPtrLess, std::allocator<std::pair<const > >> char* > >> >> > const, OpenBabel::OBPlugin*> > >& OpenBabel::OBFingerprint::Map()' > >> >> > ../../include/openbabel/fingerprint.h:53: error: 'static > >> >> > OpenBabel::OBFingerprint*& OpenBabel::OBFingerprint::Default()' > >> cannot > >> >> > be overloaded > >> >> > ../../include/openbabel/fingerprint.h:43: error: with 'static > >> >> > OpenBabel::OBFingerprint*& OpenBabel::OBFingerprint::Default()' > >> >> > ../../include/openbabel/fingerprint.h: In constructor > >> >> > 'OpenBabel::OBFingerprint::OBFingerprint(std::string, bool)': > >> >> > ../../include/openbabel/fingerprint.h:63: error: no match for > >> >> > 'operator[]' in 'OpenBabel::OBFingerprint::Map()[ID]' > >> >> > /usr/include/c++/4.0.2/bits/stl_map.h:331: note: candidates are: > >> _Tp& > >> >> > std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) > >> [with > >> >> > _Key = const char*, _Tp = OpenBabel::OBPlugin*, _Compare = > >> >> > OpenBabel::OBPlugin::CharPtrLess, _Alloc = > >> >> > std::allocator<std::pair<const char* const, > >> OpenBabel::OBPlugin*> >] > >> >> > > >> >> > > >> >> >> But in an effort to provide more choice on the form of the output, > >> >> there > >> >> >> are three functions which provide a list of formats(or other > >> plugin > >> >> >> classes): OBPlugin::ListAsVector, ListAsString and List. The first > >> >> two > >> >> >> were intended to be compatible with scripting, although I need > >> some > >> >> >> advice here. ListAsString returns a (big) std::string, but > >> >> ListAsVector > >> >> >> has a parameter which is a reference to a std::vector. If this is > >> >> >> incompatible with scripting languages I should change it. > >> >> >> > >> >> > There's no problem with vectors in general; these are simply > >> >> > translated to lists by SWIG. > >> >> > > >> >> > > >> >> >> All three have a parameter which can control what is in the > >> >> output. For > >> >> >> example if it contains "verbose" it output the whole > >> description, not > >> >> >> just the first line. So it would be easy to add code (4 extra > >> >> lines) to > >> >> >> output only the IDs if that would be useful: > >> >> >> ListAsVector("formats","in/ids", stringvector) > >> >> >> > >> >> >> Post-processing in pybel I'm sure is useful, but if the C++ > >> code was > >> >> >> adequate it could serve other scripting languages as well. > >> >> >> > >> >> > I think so too. In the meanwhile, I would like to push out a > >> Windows > >> >> > Python release based on 2.1.0 with the current pybel > >> enhancements. I'm > >> >> > going to try to get this together this weekend and do some testing. > >> >> > > >> >> > Noel > >> >> > > >> >> > > >> >> >> Chris > >> >> >> > >> >> >> Noel O'Boyle wrote: > >> >> >> > >> >> >>> After looking at the C++ code, I realise that maybe returning > >> a list > >> >> >>> of strings is the only choice for SupportedInputFormat. Anyway, > >> >> in the > >> >> >>> meanwhile I've added some code to pybel, so that if you access > >> >> >>> pybel.informats or outformats, you will get a dictionary of > >> >> supported > >> >> >>> formats. > >> >> >>> > >> >> >>> On 12/05/07, Noel O'Boyle <bao...@gm...> wrote: > >> >> >>> > >> >> >>>> Actually, a vector of std::strings had not yet been > >> swigified, so I > >> >> >>>> needed to added to a line to openbabel-python.i to set it up > >> >> (not yet > >> >> >>>> checked in). However, there's an additional problem, which > >> >> Jerome may > >> >> >>>> like to address. > >> >> >>>> > >> >> >>>> The data that's returned is similar to: > >> >> >>>> ('acr -- ACR format [Read-only]', 'alc -- Alchemy format', ... ) > >> >> >>>> > >> >> >>>> whereas it would make more sense to me either to return: > >> >> >>>> ('acr', 'alc', ...) > >> >> >>>> or > >> >> >>>> a std::map (i.e. a Python dict) of ['acr' : 'ACR format', 'alc': > >> >> >>>> 'Alchemy format'] > >> >> >>>> > >> >> >>>> Note that the text [Read-only] is not really necessary in a > >> list of > >> >> >>>> supported input formats. > >> >> >>>> > >> >> >>>> Since this function was added for the benefit of scripting > >> >> interfaces, > >> >> >>>> it makes sense to make it as easy as possible to access the > >> list of > >> >> >>>> formats. > >> >> >>>> > >> >> >>>> Noel > >> >> >>>> > >> >> >>>> On 11/05/07, Noel O'Boyle <bao...@gm...> wrote: > >> >> >>>> > >> >> >>>>> Hello again Jens, > >> >> >>>>> > >> >> >>>>> Good to hear from you on this list... :-) > >> >> >>>>> > >> >> >>>>> On 10/05/07, Jens Thomas <j.m...@dl...> wrote: > >> >> >>>>> > >> >> >>>>>> Hi, > >> >> >>>>>> > >> >> >>>>>> I'm trying to enable our ccp1gui code > >> >> >>>>>> (http://sourceforge.net/projects/ccp1gui/) to use openbabel so > >> >> that we > >> >> >>>>>> no longer have to support so many formats. > >> >> >>>>>> > >> >> >>>>>> I've got most of the machinery in place, but am a bit stuck on > >> >> how to > >> >> >>>>>> dynamically determine what input formats are supported by > >> >> openbabel. > >> >> >>>>>> > >> >> >>>>>> I originally tried to use OBConversion.GetNextFormat, but ran > >> >> into the > >> >> >>>>>> ground fairly quickly. I then discovered the post at: > >> >> >>>>>> > >> >> >>>>>> > >> >> > >> http://sourceforge.net/mailarchive/forum.php?thread_name=200702191105.25888.j.pansanel%40pansanel.net&forum_name=openbabel-scripting > >> > >> >> > >> >> >>>>>> > >> >> >>>>>> which suggest that I should be able to get what I want using > >> >> >>>>>> GetSupportedInputFormat(), however, I'm currently pretty > >> >> clueless as to > >> >> >>>>>> how I extract the information from the object. I get something > >> >> back as > >> >> >>>>>> shown below, but I'd appreciated any advice on what I then > >> >> need to do > >> >> >>>>>> with it. > >> >> >>>>>> > >> >> >> > >> >> > >> ------------------------------------------------------------------------- > >> > >> >> > >> >> >> This SF.net email is sponsored by DB2 Express > >> >> >> Download DB2 Express C - the FREE version of DB2 express and take > >> >> >> control of your XML. No limits. Just data. Click to get it now. > >> >> >> http://sourceforge.net/powerbar/db2/ > >> >> >> _______________________________________________ > >> >> >> OpenBabel-scripting mailing list > >> >> >> Ope...@li... > >> >> >> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > >> >> >> > >> >> >> > >> >> > > >> >> > > >> >> > >> ------------------------------------------------------------------------- > >> > >> >> > >> >> > This SF.net email is sponsored by DB2 Express > >> >> > Download DB2 Express C - the FREE version of DB2 express and take > >> >> > control of your XML. No limits. Just data. Click to get it now. > >> >> > http://sourceforge.net/powerbar/db2/ > >> >> > _______________________________________________ > >> >> > OpenBabel-scripting mailing list > >> >> > Ope...@li... > >> >> > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > >> >> > > >> >> > > >> >> > >> >> > >> > > >> > >> > > > > |