Skip to content

Commit

Permalink
Build molecules with aromatic bonds if labelled with 'p'
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
gilleain authored and egonw committed Oct 7, 2010
1 parent 2085e1a commit 922575a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -22,6 +22,7 @@
*/
package org.openscience.cdk.signature;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IAtom;
Expand Down Expand Up @@ -70,6 +71,13 @@ public void makeEdge(int vertexIndex1, int vertexIndex2,
container.addBond(vertexIndex1, vertexIndex2, IBond.Order.DOUBLE);
} else if (edgeLabel.equals("#")) {
container.addBond(vertexIndex1, vertexIndex2, IBond.Order.TRIPLE);
} else if (edgeLabel.equals("p")) {
IBond bond = builder.newInstance(IBond.class,
container.getAtom(vertexIndex1),
container.getAtom(vertexIndex2),
IBond.Order.SINGLE);
bond.setFlag(CDKConstants.ISAROMATIC, true);
container.addBond(bond);
}
}

Expand Down
Expand Up @@ -24,6 +24,7 @@

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -191,6 +192,24 @@ public void makeEdgeTest_tripleBond() {
Assert.assertEquals(IBond.Order.TRIPLE, product.getBond(0).getOrder());
}

@Test
public void makeEdgeTest_aromaticBond() {
MoleculeFromSignatureBuilder builder =
new MoleculeFromSignatureBuilder(
NoNotificationChemObjectBuilder.getInstance());
builder.makeGraph();
builder.makeVertex("C");
builder.makeVertex("C");
builder.makeEdge(0, 1, "C", "C", "p");

IAtomContainer product = builder.getAtomContainer();
Assert.assertEquals(2, product.getAtomCount());
Assert.assertEquals(1, product.getBondCount());
IBond bond = product.getBond(0);
Assert.assertEquals(IBond.Order.SINGLE, bond.getOrder());
Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
}

@Test
public void getAtomContainerTest() {
MoleculeFromSignatureBuilder builder =
Expand Down

0 comments on commit 922575a

Please sign in to comment.