Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a new flag: SINGLE_OR_DOUBLE

  • Loading branch information...
commit 46b1e9e73bdccf9b9a4e35b08114f1330d1b6694 1 parent be3795f
KlasJoensson authored April 03, 2012 egonw committed October 07, 2012
15  src/main/org/openscience/cdk/CDKConstants.java
@@ -170,11 +170,24 @@
170 170
     public static final int IS_TYPEABLE              = 0x0800;  // 1 << 11
171 171
 
172 172
     /**
  173
+     * Flag used for marking uncertainty of the bond order.
  174
+     * If used on an <br>
  175
+     * <ul>
  176
+     *  <li>IMolecule it means that one or several of the bonds have 
  177
+     * 		this flag raised (which may indicate aromaticity).</li>
  178
+     *  <li>IBond it means that it's unclear whether the bond is a single or
  179
+     * 		double bond.</li>
  180
+     *  <li>IAtom it is a way for the Smiles parser to indicate that this atom was 
  181
+     * 		written with a lowercase letter, e.g. 'c' rather than 'C'</li>
  182
+     * </ul>
  183
+     */
  184
+    public final static int SINGLE_OR_DOUBLE = 12;
  185
+    /**
173 186
      * Maximum flags array index. Please update this if the value exceeds 16 -
174 187
      * the flags are currently stored as a single short value (16-bit) in the
175 188
      * ChemObject implementations (default, silent and query).
176 189
      */
177  
-    public final static int MAX_FLAG_INDEX = 12;
  190
+    public final static int MAX_FLAG_INDEX = 13;
178 191
 
179 192
     // array of flags is initialised using the static constructor
180 193
     public final static int[] FLAG_MASKS = new int[MAX_FLAG_INDEX + 1];
3  src/main/org/openscience/cdk/interfaces/IBond.java
@@ -49,7 +49,8 @@
49 49
 		SINGLE,
50 50
 		DOUBLE,
51 51
 		TRIPLE,
52  
-		QUADRUPLE
  52
+		QUADRUPLE,
  53
+		UNSET
53 54
 	}
54 55
 	
55 56
 	/**
51  src/test/org/openscience/cdk/CDKConstantsTest.java
@@ -28,6 +28,13 @@
28 28
 import org.junit.Assert;
29 29
 import org.junit.Test;
30 30
 import org.openscience.cdk.CDKConstants;
  31
+import org.openscience.cdk.config.Elements;
  32
+import org.openscience.cdk.interfaces.IAtom;
  33
+import org.openscience.cdk.interfaces.IBond;
  34
+import org.openscience.cdk.interfaces.IMolecule;
  35
+import org.openscience.cdk.ringsearch.AllRingsFinder;
  36
+import org.openscience.cdk.smiles.DeduceBondSystemTool;
  37
+import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
31 38
 
32 39
 /**
33 40
  * Included so that CoreCoverageTest won't complain. The class does not have
@@ -44,6 +51,50 @@ public void testCDKConstants() {
44 51
         Assert.assertFalse(CDKConstants.ISAROMATIC == -1);
45 52
     }
46 53
     
  54
+    @Test
  55
+    public void testSingleOrDoubleFlag() throws Exception {
  56
+    	AtomContainer mol = new AtomContainer();
  57
+    	
  58
+    	IAtom atom1 = new Atom(Elements.CARBON);
  59
+    	atom1.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
  60
+    	IAtom atom2 = new Atom(Elements.CARBON);
  61
+    	IAtom atom3 = new Atom(Elements.CARBON);
  62
+    	IAtom atom4 = new Atom(Elements.CARBON);
  63
+    	IAtom atom5 = new Atom(Elements.CARBON);
  64
+    	
  65
+    	IBond bond1 = new Bond(atom1, atom2);
  66
+    	bond1.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
  67
+    	IBond bond2 = new Bond(atom2, atom3);
  68
+    	IBond bond3 = new Bond(atom3, atom4);
  69
+    	IBond bond4 = new Bond(atom4, atom5);
  70
+    	IBond bond5 = new Bond(atom5, atom1);
  71
+    	
  72
+    	mol.addAtom(atom1);
  73
+    	mol.addAtom(atom2);
  74
+    	mol.addAtom(atom3);
  75
+    	mol.addAtom(atom4);
  76
+    	mol.addAtom(atom5);
  77
+    	
  78
+    	mol.addBond(bond1);
  79
+    	mol.addBond(bond2);
  80
+    	mol.addBond(bond3);
  81
+    	mol.addBond(bond4);
  82
+    	mol.addBond(bond5);
  83
+    	  	
  84
+    	for (int i=0; i<5; i++){
  85
+    		if (mol.getAtom(i).getFlag(CDKConstants.SINGLE_OR_DOUBLE))
  86
+    			mol.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
  87
+    	}
  88
+    	
  89
+    	// Now we have created a molecule, so let's test it...
  90
+    	Assert.assertTrue(atom1.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
  91
+    	Assert.assertTrue(bond1.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
  92
+    	Assert.assertTrue(mol.getAtom(0).getFlag(CDKConstants.SINGLE_OR_DOUBLE));
  93
+    	Assert.assertTrue(mol.getBond(0).getFlag(CDKConstants.SINGLE_OR_DOUBLE));
  94
+    	Assert.assertTrue(mol.getFlag(CDKConstants.SINGLE_OR_DOUBLE));
  95
+    	
  96
+    }
  97
+    
47 98
     // FIXME: should add a test here that used introspection and test whether there
48 99
     // are not constant conflicts
49 100
     

0 notes on commit 46b1e9e

Please sign in to comment.
Something went wrong with that request. Please try again.