12.3 Updating Implicit Hydrogen Counts

For most simple molecules, OEChem can deduce the number of implicit hydrogens that are required to fill valence on each atom. Provided that the molecule doesn't contain radicals, unusual charge states, underfilled or overfilled valences, the number of implicit hydrogens can be deduced from the atomic number and formal charges on atoms, and the bond orders of the bonds of a molecule.

The function to call to automatically update the implicit hydrogen counts of each atom is called OEAssignImplicitHydrogens.

 1 /**************************************************************
 2  * Copyright 2005, OpenEye Scientific Software, Inc.
 3  *************************************************************/
 4
 5 import openeye.oechem.*;
 6
 7 public class AddingImplicitH {
 8     public static void main(String argv[]) {
 9         OEGraphMol mol = new OEGraphMol();
10         OEAtomBase o  = mol.NewAtom(OEElemNo.O);
11         oechem.OEAssignImplicitHydrogens(mol);
12
13         System.out.println(o.GetImplicitHCount());
14     }
15 }

Listing:12.4 Adding implicit hydrogens

The OEAssignMDLHydrogens command implements a simple model of valence suitable for guessing the number of hydrogens expected to be present on each atom when the formal charge has correctly been assigned.