public class CDKHydrogenAdder extends Object
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);
| Modifier and Type | Method and Description |
|---|---|
void |
addImplicitHydrogens(IAtomContainer container)
Sets implicit hydrogen counts for all atoms in the given IAtomContainer.
|
void |
addImplicitHydrogens(IAtomContainer container,
IAtom atom)
Sets the implicit hydrogen count for the indicated IAtom in the given IAtomContainer.
|
static CDKHydrogenAdder |
getInstance(IChemObjectBuilder builder) |
public static CDKHydrogenAdder getInstance(IChemObjectBuilder builder)
public void addImplicitHydrogens(IAtomContainer container) throws CDKException
container - The molecule to which H's will be addedCDKException - Throws if insufficient information is presentpublic void addImplicitHydrogens(IAtomContainer container, IAtom atom) throws CDKException
container - The molecule to which H's will be addedatom - IAtom to set the implicit hydrogen count forCDKException - Throws if insufficient information is presentCopyright © 2017. All rights reserved.