obconversion_readstring.py

Reading a smiles string in python.

import openbabel as ob

# Initialize the OBConversion object
conv = ob.OBConversion()
if not conv.SetInFormat('smi'):
  print 'could not find smiles format'

# Read the smiles string
mol = ob.OBMol()
if not conv.ReadString(mol, 'CCCC'):
  print 'could not read the smiles string'

# ... Use OBMol object ...
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines