On 14/11/2012 18:43, David van der Spoel wrote:
> On 2012-11-14 17:36, Chris Morley wrote:
>> On 14/11/2012 16:02, David van der Spoel wrote:
>>> Hi,
>>>
>>> if I have an existing OBMol object, is there a simple way to get an
>>> InChi from it in C++ without rereading the file?
>>>
>>> Thanks,
>>>
>>
>> OBMol mol;
>> ...
>> OBConversion conv;
>> conv.SetOutFormat("inchi");
>> std::string s = conv.WriteString(&mol);
>
> close but no cigar:
>
> InChI=1S/H2O/h1H2

>
> should be
>
> InChI=1S/H2O/h1H2
>
> and
> InChI=1S/C2H6OS/c1-4(2)3/h1-2H3

> should be
> InChI=1S/C2H6OS/c1-4(2)3/h1-2H3
>
> Can I just chop off the last 5 characters? Looks like a line feed or so.

Sorry, it should have been

std::string s = conv.WriteString(&mol, true);

(Presumably because a string intended for a file used to require a new 
line at the end, but InChI and SMILES don't.)

Chris

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to