Skip to content

Commit

Permalink
Don't change anything except the hydrogen count
Browse files Browse the repository at this point in the history
Change-Id: I0933be18bef3cf9221d39a1485c6e396ec06d3cf
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
egonw authored and johnmay committed Oct 20, 2013
1 parent 03d56bb commit 92577b0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/test/org/openscience/cdk/CDKTestCase.java
Expand Up @@ -29,7 +29,6 @@
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.tools.CDKHydrogenAdder;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;

import javax.vecmath.Point2d;
import javax.vecmath.Point3d;
Expand Down Expand Up @@ -175,13 +174,22 @@ protected void addExplicitHydrogens(IAtomContainer container) throws Exception {
* @param container to which implicit hydrogens are added.
*/
protected void addImplicitHydrogens(IAtomContainer container) throws Exception {
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder());
for (IAtom atom : container.atoms()) {
IAtomType type = matcher.findMatchingAtomType(container, atom);
AtomTypeManipulator.configure(atom, type);
}
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder());
int atomCount = container.getAtomCount();
String[] originalAtomTypeNames = new String[atomCount];
for (int i=0; i<atomCount; i++) {
IAtom atom = container.getAtom(i);
IAtomType type = matcher.findMatchingAtomType(container, atom);
originalAtomTypeNames[i] = atom.getAtomTypeName();
atom.setAtomTypeName(type.getAtomTypeName());
}
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder());
hAdder.addImplicitHydrogens(container);
// reset to the original atom types
for (int i=0; i<atomCount; i++) {
IAtom atom = container.getAtom(i);
atom.setAtomTypeName(originalAtomTypeNames[i]);
}
}

/**
Expand Down

0 comments on commit 92577b0

Please sign in to comment.