Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a new flag: SINGLE_OR_DOUBLE

  • Loading branch information...
commit 46b1e9e73bdccf9b9a4e35b08114f1330d1b6694 1 parent be3795f
@KlasJoensson KlasJoensson authored egonw committed
View
15 src/main/org/openscience/cdk/CDKConstants.java
@@ -170,11 +170,24 @@
public static final int IS_TYPEABLE = 0x0800; // 1 << 11
/**
+ * Flag used for marking uncertainty of the bond order.
+ * If used on an <br>
+ * <ul>
+ * <li>IMolecule it means that one or several of the bonds have
+ * this flag raised (which may indicate aromaticity).</li>
+ * <li>IBond it means that it's unclear whether the bond is a single or
+ * double bond.</li>
+ * <li>IAtom it is a way for the Smiles parser to indicate that this atom was
+ * written with a lowercase letter, e.g. 'c' rather than 'C'</li>
+ * </ul>
+ */
+ public final static int SINGLE_OR_DOUBLE = 12;
+ /**
* Maximum flags array index. Please update this if the value exceeds 16 -
* the flags are currently stored as a single short value (16-bit) in the
* ChemObject implementations (default, silent and query).
*/
- public final static int MAX_FLAG_INDEX = 12;
+ public final static int MAX_FLAG_INDEX = 13;
// array of flags is initialised using the static constructor
public final static int[] FLAG_MASKS = new int[MAX_FLAG_INDEX + 1];
View
3  src/main/org/openscience/cdk/interfaces/IBond.java
@@ -49,7 +49,8 @@
SINGLE,
DOUBLE,
TRIPLE,
- QUADRUPLE
+ QUADRUPLE,
+ UNSET
}
/**
View
51 src/test/org/openscience/cdk/CDKConstantsTest.java
@@ -28,6 +28,13 @@
import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKConstants;
+import org.openscience.cdk.config.Elements;
+import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IMolecule;
+import org.openscience.cdk.ringsearch.AllRingsFinder;
+import org.openscience.cdk.smiles.DeduceBondSystemTool;
+import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
/**
* Included so that CoreCoverageTest won't complain. The class does not have
@@ -44,6 +51,50 @@ public void testCDKConstants() {
Assert.assertFalse(CDKConstants.ISAROMATIC == -1);
}
+ @Test
+ public void testSingleOrDoubleFlag() throws Exception {
+ AtomContainer mol = new AtomContainer();
+
+ IAtom atom1 = new Atom(Elements.CARBON);
+ atom1.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
+ IAtom atom2 = new Atom(Elements.CARBON);
+ IAtom atom3 = new Atom(Elements.CARBON);
+ IAtom atom4 = new Atom(Elements.CARBON);
+ IAtom atom5 = new Atom(Elements.CARBON);
+
+ IBond bond1 = new Bond(atom1, atom2);
+ bond1.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
+ IBond bond2 = new Bond(atom2, atom3);
+ IBond bond3 = new Bond(atom3, atom4);
+ IBond bond4 = new Bond(atom4, atom5);
+ IBond bond5 = new Bond(atom5, atom1);
+
+ mol.addAtom(atom1);
+ mol.addAtom(atom2);
+ mol.addAtom(atom3);
+ mol.addAtom(atom4);
+ mol.addAtom(atom5);
+
+ mol.addBond(bond1);
+ mol.addBond(bond2);
+ mol.addBond(bond3);
+ mol.addBond(bond4);
+ mol.addBond(bond5);
+
+ for (int i=0; i<5; i++){
+ if (mol.getAtom(i).getFlag(CDKConstants.SINGLE_OR_DOUBLE))
+ mol.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
+ }
+
+ // Now we have created a molecule, so let's test it...
+ Assert.assertTrue(atom1.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
+ Assert.assertTrue(bond1.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
+ Assert.assertTrue(mol.getAtom(0).getFlag(CDKConstants.SINGLE_OR_DOUBLE));
+ Assert.assertTrue(mol.getBond(0).getFlag(CDKConstants.SINGLE_OR_DOUBLE));
+ Assert.assertTrue(mol.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
+
+ }
+
// FIXME: should add a test here that used introspection and test whether there
// are not constant conflicts
Please sign in to comment.
Something went wrong with that request. Please try again.