@@ -141,6 +141,7 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
141
141
peakXmsp <- peakXmsp [order(peakXmsp [, 1 ], decreasing = TRUE ), ]
142
142
peakXmsp <- peakXmsp [order(peakXmsp [, 2 ], decreasing = TRUE ), ]
143
143
# #
144
+ peakXcol <- NULL
144
145
LXDF <- dim(peakXmsp )[1 ]
145
146
# #
146
147
# #########################################################################
@@ -179,24 +180,30 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
179
180
# #
180
181
IDTC <- NULL
181
182
}
183
+ # #
182
184
# ###########################################################################
183
185
# #
184
186
} else {
185
187
# #
186
188
osType <- Sys.info()[[' sysname' ]]
187
189
# #
188
- if (osType == " Linux " ) {
190
+ if (osType == " Windows " ) {
189
191
# #
190
192
# #########################################################################
191
193
# #
192
- peakXmsp <- do.call(cbind , mclapply(seqMSP , function (i ) {
194
+ clust <- makeCluster(number_processing_threads )
195
+ clusterExport(clust , setdiff(ls(), c(" clust" , " L_MSP" )), envir = environment())
196
+ # #
197
+ peakXmsp <- do.call(cbind , parLapply(clust , 1 : L_MSP , function (i ) {
193
198
iCheck <- i %in% seqMSP
194
199
if (iCheck ) {
195
200
call_peakXmsp(i )
196
201
} else {
197
202
rep0LpeakXcol
198
203
}
199
- }, mc.cores = number_processing_threads ))
204
+ }))
205
+ # #
206
+ stopCluster(clust )
200
207
# #
201
208
# #########################################################################
202
209
# #
@@ -212,16 +219,22 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
212
219
# #
213
220
# #######################################################################
214
221
# #
215
- numberCSAdetFreq <- do.call(c , mclapply(1 : L_peakXcol , function (i ) {
222
+ clust <- makeCluster(number_processing_threads )
223
+ clusterExport(clust , c(" peakXmsp" ), envir = environment())
224
+ # #
225
+ numberCSAdetFreq <- do.call(c , parLapply(clust , 1 : L_peakXcol , function (i ) {
216
226
length(which(peakXmsp [i , ] > 0 ))
217
- }, mc.cores = number_processing_threads ))
227
+ }))
228
+ # #
229
+ stopCluster(clust )
218
230
# #
219
231
xDetFreq <- which(numberCSAdetFreq / L_MSP > = minPercenetageDetection / 100 )
220
232
# #
221
233
peakXmsp <- cbind(xDetFreq , peakXcol [xDetFreq , 2 : 3 ], peakXmsp [xDetFreq , ])
222
234
peakXmsp <- peakXmsp [order(peakXmsp [, 1 ], decreasing = TRUE ), ]
223
235
peakXmsp <- peakXmsp [order(peakXmsp [, 2 ], decreasing = TRUE ), ]
224
- # #
236
+ # #
237
+ peakXcol <- NULL
225
238
LXDF <- dim(peakXmsp )[1 ]
226
239
# #
227
240
# #######################################################################
@@ -232,10 +245,15 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
232
245
# #
233
246
# #######################################################################
234
247
# #
235
- peakXlist <- mclapply(1 : LXDF , function (i ) {
248
+ clust <- makeCluster(number_processing_threads )
249
+ clusterExport(clust , c(" peakXmsp" , " Lsamples" ), envir = environment())
250
+ # #
251
+ peakXlist <- parLapply(clust , 1 : LXDF , function (i ) {
236
252
px <- peakXmsp [i , 4 : Lsamples ]
237
253
px [px != 0 ]
238
- }, mc.cores = number_processing_threads )
254
+ })
255
+ # #
256
+ stopCluster(clust )
239
257
# #
240
258
names(peakXlist ) <- as.character(IDX )
241
259
# #
@@ -245,33 +263,34 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
245
263
# #
246
264
FSA_logRecorder(" Initiated calculating Tanimoto coefficients!" )
247
265
# #
248
- IDTC <- do.call(rbind , mclapply(1 : LXDF , function (i ) {
266
+ clust <- makeCluster(number_processing_threads )
267
+ clusterExport(clust , setdiff(ls(), c(" clust" , " LXDF" )), envir = environment())
268
+ # #
269
+ IDTC <- do.call(rbind , parLapply(clust , 1 : LXDF , function (i ) {
249
270
call_IDTC(i )
250
- }, mc.cores = number_processing_threads ))
271
+ }))
272
+ # #
273
+ stopCluster(clust )
251
274
# #
252
275
} else {
253
276
# #
254
277
IDTC <- NULL
255
278
}
256
- # #########################################################################
257
279
# #
258
- closeAllConnections()
259
- # #
260
- } else if (osType == " Windows" ) {
280
+ # #########################################################################
261
281
# #
262
- clust <- makeCluster(number_processing_threads )
263
- registerDoParallel(clust )
282
+ } else {
264
283
# #
265
284
# #########################################################################
266
285
# #
267
- peakXmsp <- foreach( i = 1 : L_MSP , .combine = ' cbind ' , .verbose = FALSE ) % dopar % {
286
+ peakXmsp <- do.call( cbind , mclapply( seqMSP , function ( i ) {
268
287
iCheck <- i %in% seqMSP
269
288
if (iCheck ) {
270
289
call_peakXmsp(i )
271
290
} else {
272
291
rep0LpeakXcol
273
292
}
274
- }
293
+ }, mc.cores = number_processing_threads ))
275
294
# #
276
295
# #########################################################################
277
296
# #
@@ -287,16 +306,17 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
287
306
# #
288
307
# #######################################################################
289
308
# #
290
- numberCSAdetFreq <- foreach( i = 1 : L_peakXcol , .combine = ' c ' , .verbose = FALSE ) % dopar % {
309
+ numberCSAdetFreq <- do.call( c , mclapply( 1 : L_peakXcol , function ( i ) {
291
310
length(which(peakXmsp [i , ] > 0 ))
292
- }
311
+ }, mc.cores = number_processing_threads ))
293
312
# #
294
313
xDetFreq <- which(numberCSAdetFreq / L_MSP > = minPercenetageDetection / 100 )
295
314
# #
296
315
peakXmsp <- cbind(xDetFreq , peakXcol [xDetFreq , 2 : 3 ], peakXmsp [xDetFreq , ])
297
316
peakXmsp <- peakXmsp [order(peakXmsp [, 1 ], decreasing = TRUE ), ]
298
317
peakXmsp <- peakXmsp [order(peakXmsp [, 2 ], decreasing = TRUE ), ]
299
318
# #
319
+ peakXcol <- NULL
300
320
LXDF <- dim(peakXmsp )[1 ]
301
321
# #
302
322
# #######################################################################
@@ -307,10 +327,10 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
307
327
# #
308
328
# #######################################################################
309
329
# #
310
- peakXlist <- foreach( i = 1 : LXDF , .verbose = FALSE ) % dopar % {
330
+ peakXlist <- mclapply( 1 : LXDF , function ( i ) {
311
331
px <- peakXmsp [i , 4 : Lsamples ]
312
332
px [px != 0 ]
313
- }
333
+ }, mc.cores = number_processing_threads )
314
334
# #
315
335
names(peakXlist ) <- as.character(IDX )
316
336
# #
@@ -320,17 +340,18 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
320
340
# #
321
341
FSA_logRecorder(" Initiated calculating Tanimoto coefficients!" )
322
342
# #
323
- IDTC <- foreach( i = 1 : LXDF , .combine = ' rbind ' , .verbose = FALSE ) % dopar % {
343
+ IDTC <- do.call( rbind , mclapply( 1 : LXDF , function ( i ) {
324
344
call_IDTC(i )
325
- }
345
+ }, mc.cores = number_processing_threads ))
326
346
# #
327
347
} else {
328
348
# #
329
349
IDTC <- NULL
330
350
}
331
351
# #########################################################################
332
352
# #
333
- stopCluster(clust )
353
+ closeAllConnections()
354
+ # #
334
355
}
335
356
}
336
357
# #############################################################################
@@ -391,23 +412,24 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
391
412
# #
392
413
} else {
393
414
# #
394
- if (osType == " Linux" ) {
395
- listXIDTC <- mclapply(1 : LidtIDTC , function (i ) {
396
- call_listXIDTC(i )
397
- }, mc.cores = number_processing_threads )
398
- # #
399
- closeAllConnections()
400
- # #
401
- } else if (osType == " Windows" ) {
415
+ if (osType == " Windows" ) {
402
416
# #
403
417
clust <- makeCluster(number_processing_threads )
404
- registerDoParallel (clust )
418
+ clusterExport (clust , c( " call_listXIDTC " , " idtIDTC " , " IDTC " ), envir = environment() )
405
419
# #
406
- listXIDTC <- foreach( i = 1 : LidtIDTC , .verbose = FALSE ) % dopar % {
420
+ listXIDTC <- parLapply( clust , 1 : LidtIDTC , function ( i ) {
407
421
call_listXIDTC(i )
408
- }
422
+ })
409
423
# #
410
424
stopCluster(clust )
425
+ # #
426
+ } else {
427
+ listXIDTC <- mclapply(1 : LidtIDTC , function (i ) {
428
+ call_listXIDTC(i )
429
+ }, mc.cores = number_processing_threads )
430
+ # #
431
+ closeAllConnections()
432
+ # #
411
433
}
412
434
}
413
435
# #
0 commit comments