Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

s/IMolecule/IAtomContainer/

Change-Id: Ibdb34dd07d3119ac80dd6c5defa325ea24362b95
  • Loading branch information...
commit fbfab7b34404e1cd191a2ad0ee72a00ebd0d1812 1 parent bad27b6
Egon Willighagen authored May 28, 2012
19  src/main/org/openscience/cdk/smiles/FixBondOrdersTool.java
@@ -35,7 +35,6 @@
35 35
 import org.openscience.cdk.interfaces.IAtomContainer;
36 36
 import org.openscience.cdk.interfaces.IAtomType.Hybridization;
37 37
 import org.openscience.cdk.interfaces.IBond;
38  
-import org.openscience.cdk.interfaces.IMolecule;
39 38
 import org.openscience.cdk.interfaces.IRing;
40 39
 import org.openscience.cdk.interfaces.IRingSet;
41 40
 import org.openscience.cdk.ringsearch.SSSRFinder;
@@ -145,10 +144,10 @@ public FixBondOrdersTool() {
145 144
  * @throws CDKException 
146 145
  */
147 146
     @TestMethod("testLargeRingSystem")
148  
-    public IMolecule kekuliseAromaticRings(IMolecule molecule) throws CDKException {
149  
-        IMolecule mNew = null;
  147
+    public IAtomContainer kekuliseAromaticRings(IAtomContainer molecule) throws CDKException {
  148
+    	IAtomContainer mNew = null;
150 149
         try {
151  
-            mNew = (IMolecule) molecule.clone();
  150
+            mNew = (IAtomContainer) molecule.clone();
152 151
         } catch (Exception e) {
153 152
             throw new CDKException("Failed to clone source molecule");
154 153
         }
@@ -238,7 +237,7 @@ public IMolecule kekuliseAromaticRings(IMolecule molecule) throws CDKException {
238 237
      * @param m The {@link IMolecule} from which we want to remove rings
239 238
      * @return The set of reduced rings
240 239
      */
241  
-    private IRingSet removeExtraRings(IMolecule m) throws Exception {
  240
+    private IRingSet removeExtraRings(IAtomContainer m) throws Exception {
242 241
 
243 242
         SSSRFinder arf = new SSSRFinder(m);
244 243
         IRingSet rs = arf.findSSSR();
@@ -272,7 +271,7 @@ private IRingSet removeExtraRings(IMolecule m) throws Exception {
272 271
      * @return The List of Integer arrays for the bond numbers of each ringSet
273 272
      */
274 273
     
275  
-    private List<Integer[]> getRingSystem(IMolecule mol, IRingSet ringSet) {
  274
+    private List<Integer[]> getRingSystem(IAtomContainer mol, IRingSet ringSet) {
276 275
         List<Integer[]> bondsArray;
277 276
         bondsArray = new ArrayList<Integer[]>();
278 277
         for (int r = 0; r < ringSet.getAtomContainerCount(); ++r) {
@@ -380,7 +379,7 @@ private Boolean setAllRingBondsSingleOrder(List<Integer> ringGroup, IRingSet rin
380 379
      * @param {@link IRingSet} ringSet
381 380
      * @return List of atom numbers for each set
382 381
      */
383  
-    private List getAtomNosForRingGroup(IMolecule molecule, List<Integer> ringGroup, IRingSet ringSet) {
  382
+    private List getAtomNosForRingGroup(IAtomContainer molecule, List<Integer> ringGroup, IRingSet ringSet) {
384 383
         List atc = new ArrayList<Integer>();
385 384
         for (Integer i : ringGroup) {
386 385
             for (IAtom atom : ringSet.getAtomContainer(i).atoms()) {
@@ -404,7 +403,7 @@ private List getAtomNosForRingGroup(IMolecule molecule, List<Integer> ringGroup,
404 403
      * @param {@link IRingSet} ringSet
405 404
      * @return List of bond numbers for each set
406 405
      */
407  
-    private List getBondNosForRingGroup(IMolecule molecule, List<Integer> ringGroup, IRingSet ringSet) {
  406
+    private List getBondNosForRingGroup(IAtomContainer molecule, List<Integer> ringGroup, IRingSet ringSet) {
408 407
         List btc = new ArrayList<Integer>();
409 408
         for (Integer i : ringGroup) {
410 409
             for (IBond bond : ringSet.getAtomContainer(i).bonds()) {
@@ -427,7 +426,7 @@ private List getBondNosForRingGroup(IMolecule molecule, List<Integer> ringGroup,
427 426
      * @param bondsToCheck
428 427
      * @return List of atom pairs
429 428
      */
430  
-    private List getAtomNoPairsForRingGroup(IMolecule molecule, List<Integer> bondsToCheck) {
  429
+    private List getAtomNoPairsForRingGroup(IAtomContainer molecule, List<Integer> bondsToCheck) {
431 430
         List aptc = new ArrayList<Integer[]>();
432 431
         for (Integer i : bondsToCheck) {
433 432
             Integer[] aps = new Integer[2];
@@ -446,7 +445,7 @@ private List getAtomNoPairsForRingGroup(IMolecule molecule, List<Integer> bondsT
446 445
      * @param M
447 446
      * @return The List of free valencies available for extra ring bonding
448 447
      */
449  
-    private List getFreeValenciesForRingGroup(IMolecule molecule, List<Integer> atomsToCheck, Matrix M, IRingSet rs) {
  448
+    private List getFreeValenciesForRingGroup(IAtomContainer molecule, List<Integer> atomsToCheck, Matrix M, IRingSet rs) {
450 449
         List fvtc = new ArrayList<Integer>();
451 450
         for (int i = 0; i < atomsToCheck.size(); i++) {
452 451
             int j = atomsToCheck.get(i);
103  src/test/org/openscience/cdk/smiles/FixBondOrdersToolTest.java
@@ -28,17 +28,14 @@
28 28
 import org.openscience.cdk.DefaultChemObjectBuilder;
29 29
 import org.openscience.cdk.config.Elements;
30 30
 import org.openscience.cdk.interfaces.IAtom;
  31
+import org.openscience.cdk.interfaces.IAtomContainer;
31 32
 import org.openscience.cdk.interfaces.IAtomType.Hybridization;
32 33
 import org.openscience.cdk.interfaces.IBond;
33 34
 import org.openscience.cdk.interfaces.IBond.Order;
34  
-import org.openscience.cdk.interfaces.IMolecule;
35  
-import org.openscience.cdk.nonotify.NNAtom;
36  
-import org.openscience.cdk.nonotify.NNBond;
37  
-import org.openscience.cdk.nonotify.NNMolecule;
38  
-import org.openscience.cdk.ringsearch.AllRingsFinder;
39  
-import org.openscience.cdk.smiles.SmilesParser;
  35
+import org.openscience.cdk.silent.Atom;
  36
+import org.openscience.cdk.silent.AtomContainer;
  37
+import org.openscience.cdk.silent.Bond;
40 38
 import org.openscience.cdk.silent.SilentChemObjectBuilder;
41  
-import org.openscience.cdk.tools.CDKHydrogenAdder;
42 39
 import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
43 40
 
44 41
 /**
@@ -72,12 +69,12 @@
72 69
 	public void testPyrrole() throws Exception {
73 70
         String smiles = "c2ccc3n([H])c1ccccc1c3(c2)";
74 71
         SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
75  
-        IMolecule molecule = smilesParser.parseSmiles(smiles);
  72
+        IAtomContainer molecule = smilesParser.parseSmiles(smiles);
76 73
         
77 74
         molecule = fbot.kekuliseAromaticRings(molecule);
78 75
         Assert.assertNotNull(molecule);
79 76
 
80  
-        molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
  77
+        molecule = (IAtomContainer) AtomContainerManipulator.removeHydrogens(molecule);
81 78
         int doubleBondCount = 0;
82 79
         for (int i = 0; i < molecule.getBondCount(); i++) {
83 80
         	IBond bond = molecule.getBond(i);
@@ -91,12 +88,12 @@ public void testPyrrole() throws Exception {
91 88
 	public void testPyrrole_Silent() throws Exception {
92 89
         String smiles = "c2ccc3n([H])c1ccccc1c3(c2)";
93 90
         SmilesParser smilesParser = new SmilesParser(SilentChemObjectBuilder.getInstance());
94  
-        IMolecule molecule = smilesParser.parseSmiles(smiles);
  91
+        IAtomContainer molecule = smilesParser.parseSmiles(smiles);
95 92
         
96 93
         molecule = fbot.kekuliseAromaticRings(molecule);
97 94
         Assert.assertNotNull(molecule);
98 95
 
99  
-        molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
  96
+        molecule = (IAtomContainer) AtomContainerManipulator.removeHydrogens(molecule);
100 97
         int doubleBondCount = 0;
101 98
         for (int i = 0; i < molecule.getBondCount(); i++) {
102 99
         	IBond bond = molecule.getBond(i);
@@ -110,12 +107,12 @@ public void testPyrrole_Silent() throws Exception {
110 107
     public void testLargeRingSystem() throws Exception {
111 108
         String smiles = "O=C1Oc6ccccc6(C(O)C1C5c2ccccc2CC(c3ccc(cc3)c4ccccc4)C5)";
112 109
         SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
113  
-        IMolecule molecule = smilesParser.parseSmiles(smiles);
  110
+        IAtomContainer molecule = smilesParser.parseSmiles(smiles);
114 111
         
115 112
         molecule = fbot.kekuliseAromaticRings(molecule);
116 113
         Assert.assertNotNull(molecule);
117 114
 
118  
-        molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
  115
+        molecule = (IAtomContainer) AtomContainerManipulator.removeHydrogens(molecule);
119 116
         Assert.assertEquals(34, molecule.getAtomCount());
120 117
 
121 118
         // we should have 14 double bonds
@@ -134,12 +131,12 @@ public void testLargeRingSystem() throws Exception {
134 131
     public void testLargeBioclipseUseCase() throws Exception {
135 132
         String smiles = "COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56";
136 133
         SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
137  
-        IMolecule molecule = smilesParser.parseSmiles(smiles);
  134
+        IAtomContainer molecule = smilesParser.parseSmiles(smiles);
138 135
         
139 136
         molecule = fbot.kekuliseAromaticRings(molecule);
140 137
         Assert.assertNotNull(molecule);
141 138
 
142  
-        molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
  139
+        molecule = (IAtomContainer) AtomContainerManipulator.removeHydrogens(molecule);
143 140
         Assert.assertEquals(40, molecule.getAtomCount());
144 141
 
145 142
         // we should have 14 double bonds
@@ -155,27 +152,27 @@ public void testLargeBioclipseUseCase() throws Exception {
155 152
 	 * @cdk.inchi InChI=1/C4H5N/c1-2-4-5-3-1/h1-5H 
156 153
 	 */
157 154
 	@Test public void xtestPyrrole() throws Exception {
158  
-		IMolecule enol = new NNMolecule();
  155
+		IAtomContainer enol = new AtomContainer();
159 156
 		
160 157
 		// atom block
161  
-		IAtom atom1 = new NNAtom(Elements.CARBON);
  158
+		IAtom atom1 = new Atom(Elements.CARBON);
162 159
 		atom1.setHybridization(Hybridization.SP2);
163  
-		IAtom atom2 = new NNAtom(Elements.CARBON);
  160
+		IAtom atom2 = new Atom(Elements.CARBON);
164 161
 		atom2.setHybridization(Hybridization.SP2);
165  
-		IAtom atom3 = new NNAtom(Elements.CARBON);
  162
+		IAtom atom3 = new Atom(Elements.CARBON);
166 163
 		atom3.setHybridization(Hybridization.SP2);
167  
-		IAtom atom4 = new NNAtom(Elements.CARBON);
  164
+		IAtom atom4 = new Atom(Elements.CARBON);
168 165
 		atom4.setHybridization(Hybridization.SP2);
169  
-		IAtom atom5 = new NNAtom(Elements.NITROGEN);
  166
+		IAtom atom5 = new Atom(Elements.NITROGEN);
170 167
 		atom5.setHybridization(Hybridization.SP2);
171 168
 		atom5.setImplicitHydrogenCount(1);
172 169
 		
173 170
 		// bond block
174  
-		IBond bond1 = new NNBond(atom1, atom2);
175  
-		IBond bond2 = new NNBond(atom2, atom3);
176  
-		IBond bond3 = new NNBond(atom3, atom4);
177  
-		IBond bond4 = new NNBond(atom4, atom5);
178  
-		IBond bond5 = new NNBond(atom5, atom1);
  171
+		IBond bond1 = new Bond(atom1, atom2);
  172
+		IBond bond2 = new Bond(atom2, atom3);
  173
+		IBond bond3 = new Bond(atom3, atom4);
  174
+		IBond bond4 = new Bond(atom4, atom5);
  175
+		IBond bond5 = new Bond(atom5, atom1);
179 176
 		
180 177
 		enol.addAtom(atom1);
181 178
 		enol.addAtom(atom2);
@@ -205,29 +202,29 @@ public void testLargeBioclipseUseCase() throws Exception {
205 202
 	}
206 203
 
207 204
 	@Test public void xtestPyridine() throws Exception {
208  
-		IMolecule enol = new NNMolecule();
  205
+		IAtomContainer enol = new AtomContainer();
209 206
 		
210 207
 		// atom block
211  
-		IAtom atom1 = new NNAtom(Elements.CARBON);
  208
+		IAtom atom1 = new Atom(Elements.CARBON);
212 209
 		atom1.setHybridization(Hybridization.SP2);
213  
-		IAtom atom2 = new NNAtom(Elements.CARBON);
  210
+		IAtom atom2 = new Atom(Elements.CARBON);
214 211
 		atom2.setHybridization(Hybridization.SP2);
215  
-		IAtom atom3 = new NNAtom(Elements.CARBON);
  212
+		IAtom atom3 = new Atom(Elements.CARBON);
216 213
 		atom3.setHybridization(Hybridization.SP2);
217  
-		IAtom atom4 = new NNAtom(Elements.CARBON);
  214
+		IAtom atom4 = new Atom(Elements.CARBON);
218 215
 		atom4.setHybridization(Hybridization.SP2);
219  
-		IAtom atom5 = new NNAtom(Elements.CARBON);
  216
+		IAtom atom5 = new Atom(Elements.CARBON);
220 217
 		atom5.setHybridization(Hybridization.SP2);
221  
-		IAtom atom6 = new NNAtom(Elements.NITROGEN);
  218
+		IAtom atom6 = new Atom(Elements.NITROGEN);
222 219
 		atom6.setHybridization(Hybridization.SP2);
223 220
 		
224 221
 		// bond block
225  
-		IBond bond1 = new NNBond(atom1, atom2);
226  
-		IBond bond2 = new NNBond(atom2, atom3);
227  
-		IBond bond3 = new NNBond(atom3, atom4);
228  
-		IBond bond4 = new NNBond(atom4, atom5);
229  
-		IBond bond5 = new NNBond(atom5, atom6);
230  
-		IBond bond6 = new NNBond(atom6, atom1);
  222
+		IBond bond1 = new Bond(atom1, atom2);
  223
+		IBond bond2 = new Bond(atom2, atom3);
  224
+		IBond bond3 = new Bond(atom3, atom4);
  225
+		IBond bond4 = new Bond(atom4, atom5);
  226
+		IBond bond5 = new Bond(atom5, atom6);
  227
+		IBond bond6 = new Bond(atom6, atom1);
231 228
 		
232 229
 		enol.addAtom(atom1);
233 230
 		enol.addAtom(atom2);
@@ -270,29 +267,29 @@ public void testLargeBioclipseUseCase() throws Exception {
270 267
 	 * @cdk.bug   1931262
271 268
 	 */
272 269
 	@Test public void xtestBenzene() throws Exception {
273  
-		IMolecule enol = new NNMolecule();
  270
+		IAtomContainer enol = new AtomContainer();
274 271
 		
275 272
 		// atom block
276  
-		IAtom atom1 = new NNAtom(Elements.CARBON);
  273
+		IAtom atom1 = new Atom(Elements.CARBON);
277 274
 		atom1.setHybridization(Hybridization.SP2);
278  
-		IAtom atom2 = new NNAtom(Elements.CARBON);
  275
+		IAtom atom2 = new Atom(Elements.CARBON);
279 276
 		atom2.setHybridization(Hybridization.SP2);
280  
-		IAtom atom3 = new NNAtom(Elements.CARBON);
  277
+		IAtom atom3 = new Atom(Elements.CARBON);
281 278
 		atom3.setHybridization(Hybridization.SP2);
282  
-		IAtom atom4 = new NNAtom(Elements.CARBON);
  279
+		IAtom atom4 = new Atom(Elements.CARBON);
283 280
 		atom4.setHybridization(Hybridization.SP2);
284  
-		IAtom atom5 = new NNAtom(Elements.CARBON);
  281
+		IAtom atom5 = new Atom(Elements.CARBON);
285 282
 		atom5.setHybridization(Hybridization.SP2);
286  
-		IAtom atom6 = new NNAtom(Elements.CARBON);
  283
+		IAtom atom6 = new Atom(Elements.CARBON);
287 284
 		atom6.setHybridization(Hybridization.SP2);
288 285
 		
289 286
 		// bond block
290  
-		IBond bond1 = new NNBond(atom1, atom2);
291  
-		IBond bond2 = new NNBond(atom2, atom3);
292  
-		IBond bond3 = new NNBond(atom3, atom4);
293  
-		IBond bond4 = new NNBond(atom4, atom5);
294  
-		IBond bond5 = new NNBond(atom5, atom6);
295  
-		IBond bond6 = new NNBond(atom6, atom1);
  287
+		IBond bond1 = new Bond(atom1, atom2);
  288
+		IBond bond2 = new Bond(atom2, atom3);
  289
+		IBond bond3 = new Bond(atom3, atom4);
  290
+		IBond bond4 = new Bond(atom4, atom5);
  291
+		IBond bond5 = new Bond(atom5, atom6);
  292
+		IBond bond6 = new Bond(atom6, atom1);
296 293
 		
297 294
 		enol.addAtom(atom1);
298 295
 		enol.addAtom(atom2);
@@ -337,7 +334,7 @@ public void testLargeBioclipseUseCase() throws Exception {
337 334
 	public void testAcyclic() throws Exception {
338 335
         String smiles = "CCCCCCC";
339 336
         SmilesParser smilesParser = new SmilesParser(SilentChemObjectBuilder.getInstance());
340  
-        IMolecule molecule = smilesParser.parseSmiles(smiles);
  337
+        IAtomContainer molecule = smilesParser.parseSmiles(smiles);
341 338
         
342 339
         molecule = fbot.kekuliseAromaticRings(molecule);
343 340
         Assert.assertNotNull(molecule);

0 notes on commit fbfab7b

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