Skip to content

Commit

Permalink
Inlining of hydrogen addition, to remove use of hydrogen placer.
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jul 31, 2013
1 parent 6694842 commit ba1698e
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions src/test/org/openscience/cdk/smiles/SmilesGeneratorTest.java
Expand Up @@ -155,8 +155,20 @@ public void testSmilesGenerator()
// 5
mol1.addBond(4, 6, IBond.Order.DOUBLE);
// 6
addExplicitHydrogens(mol1);
hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
// hydrogens in-lined from hydrogen adder/placer
mol1.addAtom(new Atom("H", new Point2d(0.13, -0.50)));
mol1.addBond(0, 7, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(1.87, -0.50)));
mol1.addBond(0, 8, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(-0.89, 0.45)));
mol1.addBond(3, 9, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(-0.45, -0.89)));
mol1.addBond(3, 10, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.89, -0.45)));
mol1.addBond(3, 11, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(1.00, 6.00)));
mol1.addBond(5, 12, IBond.Order.SINGLE);

IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
ifac.configureAtoms(mol1);

Expand Down Expand Up @@ -223,8 +235,29 @@ public void testSmilesGenerator()
// 5
mol1.addBond(7, 2, IBond.Order.SINGLE);
// 6
addExplicitHydrogens(mol1);
hydrogenPlacer.placeHydrogens2D(mol1, 1.0);

// hydrogens in-lined from hydrogen adder/placer
mol1.addAtom(new Atom("H", new Point2d(4.00, 1.00)));
mol1.addBond(0, 10, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.00, 1.00)));
mol1.addBond(3, 11, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(1.00, 0.00)));
mol1.addBond(3, 12, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.13, 4.50)));
mol1.addBond(4, 13, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.13, 3.50)));
mol1.addBond(4, 14, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(1.87, 5.50)));
mol1.addBond(5, 15, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.13, 5.50)));
mol1.addBond(5, 16, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(0.00, 2.00)));
mol1.addBond(6, 17, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(1.00, 1.00)));
mol1.addBond(6, 18, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(4.00, 2.00)));
mol1.addBond(8, 19, IBond.Order.SINGLE);

IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
ifac.configureAtoms(mol1);
String smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
Expand Down Expand Up @@ -358,8 +391,12 @@ public void testSmilesGenerator()
Assert.assertNotNull(smiles1);
Assert.assertEquals("F/C(=C\\(F)S)S", smiles1);

addExplicitHydrogens(mol1);
hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
// hydrogens in-lined from hydrogen adder/placer
mol1.addAtom(new Atom("H", new Point2d(-0.71, -0.71)));
mol1.addBond(0, 6, IBond.Order.SINGLE);
mol1.addAtom(new Atom("H", new Point2d(2.71, 3.71)));
mol1.addBond(5, 7, IBond.Order.SINGLE);

bool = new boolean[mol1.getBondCount()];
bool[2] = true;
smiles1 = sg.createSMILES(mol1, true, bool);
Expand Down

0 comments on commit ba1698e

Please sign in to comment.