From 36def816408fe96aa2edaa8119d2c1f9ec28a70b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Sun, 23 Jun 2019 23:58:15 +0200
Subject: [PATCH] Add presc.p

* R/mix.R(presc.p): New function. Paralellises presc.single.

* NAMESPACE: New export.

* man: Update docs.
---
 NAMESPACE      |  1 +
 R/mix.R        | 22 +++++++++++++++++++++-
 man/presc.p.Rd | 31 +++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 man/presc.p.Rd

diff --git a/NAMESPACE b/NAMESPACE
index 7f850e6..ed32db2 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -2,6 +2,7 @@
 
 export(mb.do)
 export(mb.prep)
+export(presc.p)
 export(presc.single)
 export(presc.v)
 export(sw.do)
diff --git a/R/mix.R b/R/mix.R
index 3124d8d..a73ff8b 100644
--- a/R/mix.R
+++ b/R/mix.R
@@ -512,8 +512,28 @@ RMB_EIC_prescreen_df <- function (wd, RMB_mode, FileList, cmpd_list,
 
 
 
+##' Parallel version of presc.single.
+##'
+##' @title Parallel version of presc.single
+##' @param fn_data Sequence of mzML files.
+##' @param fn_cmpd_l Filename of the compound list.
+##' @param mode RMB mode.
+##' @param cl Cluster object.
+##' @param ppm_lim_fine See ReSOLUTION.
+##' @param EIC_limit See ReSOLUTION.
+##' @return Nothing useful.
+##' @author Todor Kondić
+##' @export
+presc.p<-function(fn_data,fn_cmpd_l,mode,cl=NULL,ppm_lim_fine=10,EIC_limit=0.001) {
+    idir<-function(n) file.path(".",stripext(n))
+    wd <- sapply(fn_data,idir)
+    stgs_alist <- sapply(wd,function(d) {paste(d,".ini",sep='')})
 
-
+    f <- function(fn_data,stgs_alist,wd) {
+         presc.single(fn_data,stgs_alist,wd,mode,fn_cmpd_l,ppm_lim_fine=ppm_lim_fine,EIC_limit=EIC_limit)}
+    parallel::clusterMap(cl,f,fn_data,stgs_alist,wd)
+    
+}
 
 
 
diff --git a/man/presc.p.Rd b/man/presc.p.Rd
new file mode 100644
index 0000000..ca03cc2
--- /dev/null
+++ b/man/presc.p.Rd
@@ -0,0 +1,31 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{presc.p}
+\alias{presc.p}
+\title{Parallel version of presc.single}
+\usage{
+presc.p(fn_data, fn_cmpd_l, mode, cl = NULL, ppm_lim_fine = 10,
+  EIC_limit = 0.001)
+}
+\arguments{
+\item{fn_data}{Sequence of mzML files.}
+
+\item{fn_cmpd_l}{Filename of the compound list.}
+
+\item{mode}{RMB mode.}
+
+\item{cl}{Cluster object.}
+
+\item{ppm_lim_fine}{See ReSOLUTION.}
+
+\item{EIC_limit}{See ReSOLUTION.}
+}
+\value{
+Nothing useful.
+}
+\description{
+Parallel version of presc.single.
+}
+\author{
+Todor Kondić
+}
-- 
GitLab