Permalink
Browse files

Don't change anything except the hydrogen count

Change-Id: I0933be18bef3cf9221d39a1485c6e396ec06d3cf
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information...
1 parent 03d56bb commit 92577b0d2ceacaf75c4677d28b9b2675881ce5a6 @egonw egonw committed with johnmay Oct 16, 2013
Showing with 14 additions and 6 deletions.
  1. +14 −6 src/test/org/openscience/cdk/CDKTestCase.java
@@ -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;
@@ -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]);
+ }
}
/**

0 comments on commit 92577b0

Please sign in to comment.