Skip to content

Commit

Permalink
Resolution for bug1269 - stop the hydrogen placer attempting to place…
Browse files Browse the repository at this point in the history
… hydrogens on null atoms.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jun 8, 2013
1 parent 7c47f79 commit 3207c58
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
7 changes: 4 additions & 3 deletions src/main/org/openscience/cdk/layout/HydrogenPlacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ public void placeHydrogens2D(IAtomContainer atomContainer, double bondLength){
for (int f = 0; f < atomContainer.getAtomCount();f++)
{
atom = atomContainer.getAtom(f);
// if (!atom.getSymbol().equals("H"))
// {
// only place hydrogens when for atoms which have coordinates
if (atom.getPoint2d() != null)
{
if (debug1) System.out.println("Now placing hydrogens at atom " + f);
logger.debug("Now placing hydrogens at atom " + f);
placeHydrogens2D(atomContainer, atom, bondLength);
// }
}
}
logger.debug("Hydrogen Placement finished");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,25 +942,23 @@ public void testBug1234() throws Exception {

}

/**
* Tests case where calling generateExperimentalCoordinates
* threw an NPE.
*
* @throws Exception if the test failed
* @cdk.bug 1269
*/
@Test (timeout=5000, expected=CDKException.class)
public void testBug1269() throws Exception {

SmilesParser sp =
new SmilesParser(NoNotificationChemObjectBuilder.getInstance());
String smiles = "O=C(O)[C@H](N)C"; // L-alanine, but any [C@H] will do
IMolecule mol = sp.parseSmiles(smiles);

StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(mol);
sdg.generateExperimentalCoordinates(new Vector2d(0, 1));
}
/**
* Tests case where calling generateExperimentalCoordinates threw an NPE.
*
* @cdk.bug 1269
*/
@Test(timeout = 5000)
public void testBug1269() throws Exception {

SmilesParser sp =
new SmilesParser(NoNotificationChemObjectBuilder.getInstance());
String smiles = "O=C(O)[C@H](N)C"; // L-alanine, but any [C@H] will do
IMolecule mol = sp.parseSmiles(smiles);

StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(mol);
sdg.generateExperimentalCoordinates(new Vector2d(0, 1));
}

/**
* Does the SDG handle non-connected molecules?
Expand Down

0 comments on commit 3207c58

Please sign in to comment.