On 08/01/2011 22:01, Andrew Dalke wrote: > How should I use "cansmi" and "cansmiNS" descriptors? > > I tried in pybel: > > In [44]: import pybel > In [45]: mol = pybel.readstring("smi", "c1ccccc1O") > In [46]: mol.calcdesc(["cansmi", "cansmiNS"]) > Out[46]: {'cansmi': nan, 'cansmiNS': nan} > > In [47]: > > > I tried stepping through the pybel implementation manually > > In [35]: import openbabel as ob > In [36]: mol = ob.OBMol() > In [37]: obconv = ob.OBConversion() > In [38]: obconv.SetInFormat("smi") > Out[38]: True > > ([39] was an oopsie) > > In [40]: obconv.ReadString(mol, "c1ccccc1O") > Out[40]: True > > In [41]: ob.OBDescriptor.FindType("cansmi").Predict(mol) > Out[41]: nan > > > The descriptor framework does work: > > In [42]: ob.OBDescriptor.FindType("MR").Predict(mol) > Out[42]: 28.465 > > > Since the function returns a string instead of a float, > it appears that I should call GetStringValue(). But how? > > > In [70]: ob.OBDescriptor.FindType("cansmi").GetStringValue(mol.OBMol) > --------------------------------------------------------------------------- > NotImplementedError Traceback (most recent call last) > > /Users/dalke/cvses/propbox/<ipython console> in<module>() > > NotImplementedError: Wrong number of arguments for overloaded function > 'OBDescriptor_GetStringValue'. > Possible C/C++ prototypes are: > GetStringValue(OpenBabel::OBDescriptor *,OpenBabel::OBBase > *,std::string&,std::string *) > GetStringValue(OpenBabel::OBDescriptor *,OpenBabel::OBBase *,std::string&) > > > I can't figure out what I should use to pass in a std::string& from Python. > > So my questions are: > - how do I figure out which return type is expected, so I know > which descriptor method to call, and > - how do I get string value from the descriptor API?
The string descriptors in OpenBabel mostly do not implement new functionality but are wrappers for use with command-line ops like --filter, --unique, etc. I have been thinking that it might have been better if OBDescriptor had been template class, which would have allowed a more regular interface (at least from C++) and an opportunity for a wider range of types. I can also see the need for functions to return metadata (currently there is only Description()). Maybe these changes could be made in future versions without too much disruption. In the meantime...Numeric descriptors have a straightforward interface - Predict() in C++ and calcdesc in Pybel. The information provided by the string descriptors is easily accessed in other ways. The current string descriptors are title, inchi, cansmi and canmiNS. The first is an API call, and the others are from "inchi" and "can" formats, with the i option being used for cansmiNS. Chris ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss