Files
openbabel/scripts/python/examples/examples.py
Geoffrey Hutchison 113220be4c Merged revisions 1918-1933 via svnmerge from
https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/branches/openbabel-2-1-x

........
  r1918 | ghutchis | 2007-03-30 14:25:42 -0400 (Fri, 30 Mar 2007) | 2 lines
  
  Produce a better "clean" before creating a distribution tar
........
  r1919 | ghutchis | 2007-03-30 16:46:51 -0400 (Fri, 30 Mar 2007) | 7 lines
  
    * include/openbabel/residue.h: Hide some residue names (e.g.,
    _1MG) from SWIG wrappers -- such constants are not valid symbols
    in some languages like Ruby.
  
    * scripts/ Update accordingly.
........
  r1920 | ghutchis | 2007-03-30 16:47:12 -0400 (Fri, 30 Mar 2007) | 4 lines
  
    * src/base.cpp: Additional "What's new" documentation for 2.1
    release.
........
  r1921 | ghutchis | 2007-03-30 16:47:34 -0400 (Fri, 30 Mar 2007) | 2 lines
  
  (missed changelog update.)
........
  r1922 | ghutchis | 2007-03-30 17:53:27 -0400 (Fri, 30 Mar 2007) | 2 lines
  
  Updated to use Ruby-style API names via SWIG -autorename
........
  r1923 | ghutchis | 2007-04-02 22:41:53 -0400 (Mon, 02 Apr 2007) | 7 lines
  
    * include/openbabel/residue.h: Undo previous change. Rich Apodaca
    suggested some SWIG-fu instead.
  
    * scripts/ Update accordingly. Includes ruby changes, new README
    and examples.
........
  r1924 | ghutchis | 2007-04-03 22:51:43 -0400 (Tue, 03 Apr 2007) | 2 lines
  
  Updated for 2.1 release of scripting interfaces.
........
  r1925 | ghutchis | 2007-04-04 00:06:50 -0400 (Wed, 04 Apr 2007) | 2 lines
  
  Moved examples to subdir (for cleaner-looking dist) and MANIFEST
........
  r1926 | ghutchis | 2007-04-04 20:58:12 -0400 (Wed, 04 Apr 2007) | 2 lines
  
  Updated for new Doxygen update (and new warnings)
........
  r1927 | timvdm | 2007-04-05 17:41:37 -0400 (Thu, 05 Apr 2007) | 4 lines
  
  - documentation update
  - covert to dative bonds (for psa)
  - psa.txt: fix smiles for 3-rings
........
  r1929 | ghutchis | 2007-04-07 14:43:05 -0400 (Sat, 07 Apr 2007) | 3 lines
  
    * NEWS: Minor fixes for 2.1.0 final release.
........
  r1930 | ghutchis | 2007-04-07 15:07:08 -0400 (Sat, 07 Apr 2007) | 2 lines
  
  Minor fixes. Corresponds to 2.1.0 released source.
........
  r1933 | ghutchis | 2007-04-13 13:44:01 -0400 (Fri, 13 Apr 2007) | 8 lines
  
    * src/formats/inchi/strutil.c: Bug reported on the InChI mailing
    list.
  
    * src/formats/inchiformat.cpp: Bug caught during ChemSpotlight
    testing -- some files don't have chirality information (e.g., 3D
    files but with 0.0 coordinates throughout). Warn and give up.
........
2007-04-13 18:44:10 +00:00

31 lines
626 B
Python

import openbabel
mol = openbabel.OBMol()
print 'Should print 0 (atoms)'
print mol.NumAtoms()
a = mol.NewAtom()
b = mol.NewAtom()
mol.AddBond(1, 2, 1)
print 'Should print 2 (atoms)'
print mol.NumAtoms()
print 'Should print 1 (bond)'
print mol.NumBonds()
obConversion = openbabel.OBConversion()
obConversion.SetInAndOutFormats("smi", "mdl")
mol.Clear()
obConversion.ReadString(mol, "C1=CC=CS1")
print 'Should print 5 (atoms)'
print mol.NumAtoms()
mol.AddHydrogens()
print 'Should print 9 (atoms) after adding hydrogens'
print mol.NumAtoms()
outMDL = obConversion.WriteString(mol)
obConversion.WriteFile(mol, 'temp.mdl')