2020
2121import java .io .IOException ;
2222import java .io .Serializable ;
23- import static java .lang .System .getProperty ;
24-
2523import java .util .Collection ;
2624import java .util .HashMap ;
2725import java .util .List ;
3432import org .openscience .cdk .exception .CDKException ;
3533import org .openscience .cdk .interfaces .IAtomContainer ;
3634import org .openscience .cdk .silent .SilentChemObjectBuilder ;
37- import static org .openscience .cdk .smiles .SmilesGenerator .unique ;
3835import org .openscience .cdk .smiles .SmilesParser ;
3936import com .bioinceptionlabs .reactionblast .mapping .algorithm .Holder ;
4037import static org .openscience .smsd .tools .ExtAtomContainerManipulator .removeHydrogens ;
5047 */
5148public final class RuleBasedMappingHandler implements Serializable {
5249
53- static final String NEW_LINE = getProperty ("line.separator" );
54- private final static boolean DEBUG1 = false ;
55- private final static boolean DEBUG2 = false ;
5650 private static final long serialVersionUID = 88765671L ;
5751 private final static ILoggingTool LOGGER
5852 = createLoggingTool (RuleBasedMappingHandler .class );
@@ -106,9 +100,6 @@ public RuleBasedMappingHandler(Holder matrixHolder,
106100 List <String > EdMapOrignal , List <String > PdMapOrignal )
107101 throws CDKException , IOException {
108102 setRulesSmiles ();
109- if (DEBUG1 ) {
110- LOGGER .debug ("Mapping Rules Checked" );
111- }
112103 this .matrixHolder = matrixHolder ;
113104 this .matchedRowColoumn = new HashMap <>();
114105 setRuleMatched (false );
@@ -118,9 +109,6 @@ public RuleBasedMappingHandler(Holder matrixHolder,
118109 for (int i = 0 ; i < this .matrixHolder .getReactionContainer ().getEductCount (); i ++) {
119110 IAtomContainer ac1 = new AtomContainer (this .matrixHolder .getReactionContainer ().getEduct (i ));
120111 ac1 = removeHydrogens (ac1 );
121- if (DEBUG1 ) {
122- LOGGER .debug ("Educt " + unique ().create (ac1 ));
123- }
124112
125113 if (ac1 .getAtomCount () >= getSmartsPhosphate ().getAtomCount ()
126114 || ac1 .getAtomCount () >= getSmartsSulphate ().getAtomCount ()) {
@@ -131,15 +119,9 @@ public RuleBasedMappingHandler(Holder matrixHolder,
131119 }
132120 }
133121 }
134- if (DEBUG1 ) {
135- LOGGER .debug ("smallestMatchedReactant " + smallestMatchedReactant );
136- }
137122 for (int j = 0 ; j < this .matrixHolder .getReactionContainer ().getProductCount (); j ++) {
138123 IAtomContainer ac2 = new AtomContainer (this .matrixHolder .getReactionContainer ().getProduct (j ));
139124 ac2 = removeHydrogens (ac2 );
140- if (DEBUG1 ) {
141- LOGGER .debug ("Product " + unique ().create (ac2 ));
142- }
143125 if (ac2 .getAtomCount () >= getSmartsPhosphate ().getAtomCount ()
144126 || ac2 .getAtomCount () >= getSmartsSulphate ().getAtomCount ()) {
145127 if (isMatch (getSmartsPhosphate (), ac2 , false ) || isMatch (getSmartsSulphate (), ac2 , false )) {
@@ -149,10 +131,6 @@ public RuleBasedMappingHandler(Holder matrixHolder,
149131 }
150132 }
151133 }
152- if (DEBUG1 ) {
153- LOGGER .debug ("smallestMatchedProduct " + smallestMatchedProduct );
154- LOGGER .debug (NEW_LINE + NEW_LINE + "----------------------" + NEW_LINE + NEW_LINE + NEW_LINE );
155- }
156134
157135 boolean phosphate_changed = phosphate_cleaved (this .matrixHolder .getReactionContainer ().getEducts (), this .matrixHolder .getReactionContainer ().getProducts ());
158136
@@ -161,29 +139,12 @@ public RuleBasedMappingHandler(Holder matrixHolder,
161139 IAtomContainer educt = this .matrixHolder .getReactionContainer ().getEduct (i );
162140 IAtomContainer ac1 = new AtomContainer (educt );
163141 ac1 = removeHydrogens (ac1 );
164- if (DEBUG2 ) {
165- LOGGER .debug (NEW_LINE + NEW_LINE + NEW_LINE + "Educt " + unique ().create (ac1 ));
166- LOGGER .debug ("Educt found " + ac1 .getAtomCount ());
167- }
168142
169143 for (int j = 0 ; j < this .matrixHolder .getReactionContainer ().getProductCount (); j ++) {
170144 IAtomContainer product = this .matrixHolder .getReactionContainer ().getProduct (j );
171145 IAtomContainer ac2 = new AtomContainer (product );
172146 ac2 = removeHydrogens (ac2 );
173147
174- if (DEBUG2 ) {
175- LOGGER .debug ("Product " + unique ().create (ac2 ));
176- LOGGER .debug ("Product found " + ac2 .getAtomCount ());
177- }
178- if (DEBUG2 ) {
179- LOGGER .debug ("Match 1 " + isMatch (getSmartsWater (), ac1 , false ));
180- LOGGER .debug ("Match 2 " + isMatch (getSmartsPhosphate (), ac2 , false ));
181- LOGGER .debug ("Query " + ac1 .getAtomCount ());
182- LOGGER .debug ("Target " + ac2 .getAtomCount ());
183- LOGGER .debug ("smallest R " + smallestMatchedReactant );
184- LOGGER .debug ("smallest P " + smallestMatchedProduct );
185- }
186-
187148 if (this .matrixHolder .getCliqueMatrix ().getValue (i , j ) == 0 ) {
188149 continue ;
189150 }
@@ -196,16 +157,8 @@ && isMatch(getSmartsWater(), ac1, false)
196157 && isMatch (getSmartsPhosphate (), ac2 , false )
197158 && !isMatch (getSmartsDoublePhosphate (), ac2 , false )
198159 && ac2 .getAtomCount () == smallestMatchedProduct ) {
199- if (DEBUG2 ) {
200- LOGGER .debug ("Match " );
201- LOGGER .debug ("smallest R phosphate " + smallestMatchedReactant );
202- LOGGER .debug ("smallest P phosphate " + smallestMatchedProduct );
203- }
204160 setRuleMatched (true );
205161 matchedRowColoumn .put (i , j );
206- if (DEBUG1 ) {
207- LOGGER .debug (" Rule 1 water and Phosphate" );
208- }
209162
210163 }
211164 /*
@@ -217,16 +170,8 @@ && isMatch(getSmartsWater(), ac2, false)
217170 && isMatch (getSmartsPhosphate (), ac1 , false )
218171 && !isMatch (getSmartsDoublePhosphate (), ac1 , false )
219172 && ac1 .getAtomCount () == smallestMatchedReactant ) {
220- if (DEBUG2 ) {
221- LOGGER .debug ("Match " );
222- LOGGER .debug ("smallest R phosphate " + smallestMatchedReactant );
223- LOGGER .debug ("smallest P phosphate " + smallestMatchedProduct );
224- }
225173 setRuleMatched (true );
226174 matchedRowColoumn .put (i , j );
227- if (DEBUG1 ) {
228- LOGGER .debug (" Rule 1 phosphate and water" );
229- }
230175
231176 }
232177
@@ -237,41 +182,22 @@ && isMatch(getSmartsPhosphate(), ac1, false)
237182 && isMatch (getSmartsWater (), ac1 , false )
238183 && isMatch (getSmartsSulphate (), ac2 , false )
239184 && ac2 .getAtomCount () == smallestMatchedProduct ) {
240- if (DEBUG2 ) {
241- LOGGER .debug ("Match " );
242- LOGGER .debug ("smallest R sulphate " + smallestMatchedReactant );
243- LOGGER .debug ("smallest P sulphate " + smallestMatchedProduct );
244- }
245185 setRuleMatched (true );
246186 matchedRowColoumn .put (i , j );
247- if (DEBUG1 ) {
248- LOGGER .debug (" Rule 1 water and Sulphate" );
249- }
250187
251188 } else /*
252189 Rule 1_D Sulphate and water
253190 */ if (ac2 .getAtomCount () == 1
254191 && isMatch (getSmartsWater (), ac2 , false )
255192 && isMatch (getSmartsSulphate (), ac1 , false )
256193 && ac1 .getAtomCount () == smallestMatchedReactant ) {
257- if (DEBUG2 ) {
258- LOGGER .debug ("Match " );
259- LOGGER .debug ("smallest R sulphate " + smallestMatchedReactant );
260- LOGGER .debug ("smallest P sulphate " + smallestMatchedProduct );
261- }
262194 setRuleMatched (true );
263195 matchedRowColoumn .put (i , j );
264- if (DEBUG1 ) {
265- LOGGER .debug (" Rule 1 Sulphate and water" );
266- }
267196
268197 }/*
269198 Rule 11 C04666_C04916
270199 */ else if (isMatch (getSmartsC04666Rule (), ac1 , false ) && isMatch (getSmartsC04916Rule (), ac2 , false )
271200 || (isMatch (getSmartsC04916Rule (), ac1 , false ) && isMatch (getSmartsC04666Rule (), ac2 , false ))) {
272- if (DEBUG1 ) {
273- LOGGER .debug ("Rule 11 C04666 with C04916 found" );
274- }
275201 setRuleMatched (true );
276202 matchedRowColoumn .put (i , j );
277203 } /*
@@ -282,9 +208,6 @@ && isMatch(getSmartsGlutamate(), ac1, false) && isMatch(getSmartsGlutamine(), ac
282208 && isMatch (getSmartsGlutamine (), ac1 , false ) && isMatch (getSmartsGlutamate (), ac2 , false ))) {
283209 setRuleMatched (true );
284210 matchedRowColoumn .put (i , j );
285- if (DEBUG1 ) {
286- LOGGER .debug ("Rule 2.1 L-Glutamate with L-Glutamine found" );
287- }
288211 } /*
289212 Rule 2 L_Glutamate and L_Glutamine_clipped
290213 */ else if ((ac1 .getAtomCount () == 10 && ac2 .getAtomCount () == 10
@@ -293,9 +216,6 @@ && isMatch(getSmartsGlutamateClipped(), ac1, false) && isMatch(getSmartsGlutamin
293216 && isMatch (getSmartsGlutamineClipped (), ac1 , false ) && isMatch (getSmartsGlutamateClipped (), ac2 , false ))) {
294217 setRuleMatched (true );
295218 matchedRowColoumn .put (i , j );
296- if (DEBUG1 ) {
297- LOGGER .debug ("Rule 2.2 L-Glutamate with L-Glutamine found" );
298- }
299219 }/*
300220 Rule 3 D_Glutamate and TwoOxoglutarate
301221 */ else if ((ac2 .getAtomCount () == 10 && ac1 .getAtomCount () == 10
@@ -305,19 +225,13 @@ && isMatch(getSmartsTwoOxoglutarate(), ac1, false) && isMatch(getSmartsD_Glutama
305225
306226 setRuleMatched (true );
307227 matchedRowColoumn .put (i , j );
308- if (DEBUG1 ) {
309- LOGGER .debug ("Rule 3 D-Glutamate with 2-Oxoglutarate found" );
310- }
311228
312229 }/*
313230 Rule 4 water and Acetate (exact match)
314231 */ else if ((ac1 .getAtomCount () == 1 && isMatch (getSmartsWater (), ac1 , false )
315232 && ac2 .getAtomCount () == getSmartsAcetate ().getAtomCount () && isMatch (getSmartsAcetate (), ac2 , false ))
316233 || (ac2 .getAtomCount () == 1 && isMatch (getSmartsWater (), ac2 , false )
317234 && ac1 .getAtomCount () == getSmartsAcetate ().getAtomCount () && isMatch (getSmartsAcetate (), ac1 , false ))) {
318- if (DEBUG1 ) {
319- LOGGER .debug ("Rule 4 Water and Acetate found" );
320- }
321235 setRuleMatched (true );
322236 matchedRowColoumn .put (i , j );
323237 }/*
@@ -326,9 +240,6 @@ && isMatch(getSmartsTwoOxoglutarate(), ac1, false) && isMatch(getSmartsD_Glutama
326240 && isMatch (getSmartsADP (), ac2 , false ))
327241 || (ac1 .getAtomCount () == getSmartsADP ().getAtomCount () && isMatch (getSmartsADP (), ac1 , false )
328242 && isMatch (getSmartsATP (), ac2 , false ))) {
329- if (DEBUG1 ) {
330- LOGGER .debug ("Rule 5 ADP_ATP found" );
331- }
332243 setRuleMatched (true );
333244 matchedRowColoumn .put (i , j );
334245 }/*
@@ -337,9 +248,6 @@ && isMatch(getSmartsATP(), ac2, false))) {
337248 && isMatch (getSmartsAcetyl_CoA (), ac2 , false ))
338249 || (ac1 .getAtomCount () == getSmartsAcetyl_CoA ().getAtomCount () && isMatch (getSmartsAcetyl_CoA (), ac1 , false )
339250 && isMatch (getSmartsCoA (), ac2 , false ))) {
340- if (DEBUG1 ) {
341- LOGGER .debug ("Rule 6 CoA_Acetyl_CoA found" );
342- }
343251 setRuleMatched (true );
344252 matchedRowColoumn .put (i , j );
345253 }/*
@@ -348,9 +256,6 @@ && isMatch(getSmartsCoA(), ac2, false))) {
348256 && isMatch (getSmartsC00006 (), ac2 , false ))
349257 || (ac1 .getAtomCount () == getSmartsC00006 ().getAtomCount () && isMatch (getSmartsC00006 (), ac1 , false )
350258 && isMatch (getSmartsC00003 (), ac2 , false ))) {
351- if (DEBUG1 ) {
352- LOGGER .debug ("Rule 7 C00003_C00006 found" );
353- }
354259 setRuleMatched (true );
355260 matchedRowColoumn .put (i , j );
356261 }/*
@@ -359,9 +264,6 @@ && isMatch(getSmartsC00003(), ac2, false))) {
359264 && isMatch (getSmartsC00005 (), ac2 , false ))
360265 || (ac1 .getAtomCount () == getSmartsC00005 ().getAtomCount () && isMatch (getSmartsC00005 (), ac1 , false )
361266 && isMatch (getSmartsC00004 (), ac2 , false ))) {
362- if (DEBUG1 ) {
363- LOGGER .debug ("Rule 8 C00004_C00005 found" );
364- }
365267 setRuleMatched (true );
366268 matchedRowColoumn .put (i , j );
367269 } /*
@@ -370,18 +272,12 @@ && isMatch(getSmartsC00004(), ac2, false))) {
370272 && isMatch (getSmartsAlanine (), ac2 , false ))
371273 || (ac1 .getAtomCount () == getSmartsAlanine ().getAtomCount () && isMatch (getSmartsAlanine (), ac1 , false )
372274 && isMatch (getSmartsPyruvate (), ac2 , false ))) {
373- if (DEBUG1 ) {
374- LOGGER .debug ("Rule 9 C00022_C00041 found" );
375- }
376275 setRuleMatched (true );
377276 matchedRowColoumn .put (i , j );
378277 }/*
379278 Rule 10 N_C
380279 */ else if (isMatch (getSmartsNRule (), ac1 , false ) && isMatch (getSmartsCRule (), ac2 , false )
381280 || (isMatch (getSmartsCRule (), ac1 , false ) && isMatch (getSmartsNRule (), ac2 , false ))) {
382- if (DEBUG1 ) {
383- LOGGER .debug ("Rule 10 N with C found" );
384- }
385281 setRuleMatched (true );
386282 matchedRowColoumn .put (i , j );
387283 }
0 commit comments