Class CDKHydrogenAdder
java.lang.Object
org.openscience.cdk.tools.CDKHydrogenAdder
Adds implicit hydrogens based on atom type definitions. The class assumes
that CDK atom types are already detected. A full code example is:
IAtomContainer methane = new AtomContainer();
IAtom carbon = new Atom("C");
methane.addAtom(carbon);
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(methane.getNewBuilder());
for (IAtom atom : methane.atoms) {
IAtomType type = matcher.findMatchingAtomType(methane, atom);
AtomTypeManipulator.configure(atom, type);
}
CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(methane.getNewBuilder());
adder.addImplicitHydrogens(methane);
If you want to add the hydrogens to a specific atom only, use this example:
IAtomContainer ethane = new AtomContainer();
IAtom carbon1 = new Atom("C");
IAtom carbon2 = new Atom("C");
ethane.addAtom(carbon1);
ethane.addAtom(carbon2);
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(ethane.getNewBuilder());
IAtomType type = matcher.findMatchingAtomType(ethane, carbon1);
AtomTypeManipulator.configure(carbon1, type);
CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(ethane.getNewBuilder());
adder.addImplicitHydrogens(ethane, carbon1);
- Author:
- egonw
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddImplicitHydrogens(IAtomContainer container) Sets implicit hydrogen counts for all atoms in the given IAtomContainer.voidaddImplicitHydrogens(IAtomContainer container, IAtom atom) Sets the implicit hydrogen count for the indicated IAtom in the given IAtomContainer.static CDKHydrogenAddergetInstance(IChemObjectBuilder builder)
-
Method Details
-
getInstance
-
addImplicitHydrogens
Sets implicit hydrogen counts for all atoms in the given IAtomContainer.- Parameters:
container- The molecule to which H's will be added- Throws:
CDKException- Throws if insufficient information is present- Keywords:
- hydrogens, adding
-
addImplicitHydrogens
Sets the implicit hydrogen count for the indicated IAtom in the given IAtomContainer. If the atom type is "X", then the atom is assigned zero implicit hydrogens.- Parameters:
container- The molecule to which H's will be addedatom- IAtom to set the implicit hydrogen count for- Throws:
CDKException- Throws if insufficient information is present
-