Works for me as follows:

>>> import openbabel as ob
>>> mol = ob.OBMol()
>>> atom = mol.NewAtom()
>>> atom.SetAtomicNum(6)
>>> atom.SetVector( 1, 1, 1)
>>> conv = ob.OBConversion()
>>> success = conv.SetOutFormat("inchi")
>>> assert success
>>> conv.WriteString(mol)
'InChI=1S/CH4/h1H4\n'
>>>

- Noel


On 12 September 2011 22:12, vulcan[omni] <[email protected]> wrote:
> Hello,
>
> I am using the openbabel python module to compute the InChi string of an
> obmol object. However, I have to construct the obmol manually like so:
>
>  # Coordinates is this format:
> ((O,(0.0,0.0,0.0)),(H,(1.0,0.0,0.0)),(H,(-1.0,0.0,0.0))
>  mol = openbabel.OBMol()
>  for entry in coordinates:
>        newAtom = mol.NewAtom()
>        newAtom.SetAtomicNum(symbolToNumber(entry[0]))
>        newAtom.SetVector(*(map(float,entry[1])))
>
> Therefore, I need to have an OBConverter object with no input format and
> output format, ideally like this:
>
> converter.SetInAndOutFormats(None,"inchi")
>
> However, calling this and then doing:
>
> inchi = converter.WriteString(mol)
>
> just returns a blank string, even when mol is populated correctly. Is my
> problem with the setup of OBConverter or is it something else? I appreciate
> any insight.
>
> Thank you,
>
> Sam Manzer
>
> --
> View this message in context: 
> http://forums.openbabel.org/OBConversion-of-mol-object-without-input-format-tp3808639p3808639.html
> Sent from the openbabel-scripting mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Doing More with Less: The Next Generation Virtual Desktop
> What are the key obstacles that have prevented many mid-market businesses
> from deploying virtual desktops?   How do next-generation virtual desktops
> provide companies an easier-to-deploy, easier-to-manage and more affordable
> virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
> _______________________________________________
> OpenBabel-scripting mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
>

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
OpenBabel-scripting mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-scripting

Reply via email to