From 544498565662f5f7bd23a71c657356db2a2f78ea Mon Sep 17 00:00:00 2001 From: Christian Panse Date: Tue, 29 Oct 2024 19:19:24 +0100 Subject: [PATCH] #75 --- DESCRIPTION | 2 +- R/dotNetAssembly.R | 14 +++++++++++++- R/rawrr.R | 20 ++++++++++++++------ inst/rawrrassembly/README.md | 7 +++++++ inst/rawrrassembly/rawrr-dotnet.csproj | 17 +++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 inst/rawrrassembly/rawrr-dotnet.csproj diff --git a/DESCRIPTION b/DESCRIPTION index e15719e..270b79a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rawrr Type: Package Title: Direct Access to Orbitrap Data and Beyond -Version: 1.15.0 +Version: 1.15.1 Authors@R: c(person("Christian", "Panse", email = "cp@fgcz.ethz.ch", role = c("aut", "cre"), diff --git a/R/dotNetAssembly.R b/R/dotNetAssembly.R index a276c08..46ac310 100644 --- a/R/dotNetAssembly.R +++ b/R/dotNetAssembly.R @@ -24,7 +24,7 @@ # execute rawrr.exe assembly and keep output string rvs <- "?" - if (Sys.info()['sysname'] %in% c("Darwin", "Linux")){ + if (Sys.info()['sysname'] %in% c("Darwin", "Linux") && !exists('RAWRRDOTNET')){ if (file.exists(exe) && Sys.which('mono') != ""){ rvs <- system2(Sys.which('mono'), args = c(shQuote(exe)), stdout = TRUE) @@ -113,6 +113,18 @@ rawrrAssemblyPath <- function(){ .rawrrAssembly <- function(){ f <- file.path(rawrrAssemblyPath(), 'rawrr.exe') + + if (exists('RAWRRDOTNET')){ + if (Sys.info()['sysname'] == "Darwin"){ + file.path(rawrr::rawrrAssemblyPath(), 'osx-x64', 'rawrr') -> f + } else if (Sys.info()['sysname'] == "Linux"){ + file.path(rawrr::rawrrAssemblyPath(), 'linux-x64', 'rawrr') -> f + } else { + file.path(rawrr::rawrrAssemblyPath(), 'win-x64', 'rawrr.exe') -> f + } + message("Using '", f, "' ...") + } + return(f) } diff --git a/R/rawrr.R b/R/rawrr.R index 398b99d..f26734f 100644 --- a/R/rawrr.R +++ b/R/rawrr.R @@ -87,7 +87,9 @@ mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE exe <- .rawrrAssembly() - + + + tfi <- tempfile(tmpdir=tmpdir, fileext = ".txt") tfo <- tempfile(tmpdir=tmpdir, fileext = ".R") tfstdout <- tempfile(tmpdir=tmpdir, fileext = ".stdout") @@ -97,8 +99,9 @@ if(isFALSE(file.exists(tfi))){ stop(paste0("No input file '", tfi, "' available!")) } + - if (mono){ + if (mono && !exists('RAWRRDOTNET')){ if (system2(command = "/usr/bin/which", args = c("mono"), stderr = FALSE, stdout = FALSE) != 0){ stop("mono is not available; please check https://www.mono-project.com/") @@ -252,7 +255,8 @@ readIndex <- function (rawfile) TRUE else FALSE exe <- .rawrrAssembly() - if (mono) { + + if (mono && !exists('RAWRRDOTNET')){ con <- textConnection(system2(Sys.which("mono"), args = c(shQuote(exe), shQuote(rawfile), "index"), @@ -283,6 +287,7 @@ filter <- function(rawfile, filter = "ms", precision = 10, tmpdir=tempdir()){ .checkRawFile(rawfile) mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE exe <- .rawrrAssembly() + tfstderr <- tempfile(tmpdir=tmpdir) tfo <- tempfile(tmpdir=tmpdir, fileext = ".txt") @@ -290,6 +295,7 @@ filter <- function(rawfile, filter = "ms", precision = 10, tmpdir=tempdir()){ cmd <- exe + if (exists('RAWRRDOTNET')){ mono <<- FALSE} if (mono){ rvs <- system2(Sys.which("mono"), args = c(shQuote(exe), shQuote(rawfile), @@ -621,6 +627,7 @@ readSpectrum <- function(rawfile, scan = NULL, tmpdir = tempdir(), mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE exe <- .rawrrAssembly() + tfstdout <- tempfile(fileext = ".stdout", tmpdir = tmpdir) tfstderr <- tempfile(fileext = ".stderr", tmpdir = tmpdir) @@ -629,7 +636,7 @@ readSpectrum <- function(rawfile, scan = NULL, tmpdir = tempdir(), system2args <- c(shQuote(rawfile), "chromatogram", shQuote(filter), tfcsv) - if (mono){ + if (mono && !exists('RAWRRDOTNET')){ rvs <- system2("mono", args = c(shQuote(exe), system2args), stdout=tfstdout, stderr=tfstderr) }else{ rvs <- system2(exe, args = system2args, stdout=tfstdout, stderr=tfstderr) @@ -1589,12 +1596,13 @@ readTrailer <- function(rawfile, label = NULL) { mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE exe <- .rawrrAssembly() + cmd <- exe if (is.null(label)){ # should return all available trailer label - if (mono){ + if (mono && !exists('RAWRRDOTNET')){ con <- textConnection(system2(Sys.which("mono"), args = c(shQuote(exe), shQuote(rawfile), "trailer"), stdout = TRUE)) @@ -1605,7 +1613,7 @@ readTrailer <- function(rawfile, label = NULL) { } }else{ # use case for providing a trailer label - if (mono){ + if (mono && !exists('RAWRRDOTNET')){ con <- textConnection(system2(Sys.which("mono"), args = c(shQuote(exe), shQuote(rawfile), "trailer", shQuote(label)), diff --git a/inst/rawrrassembly/README.md b/inst/rawrrassembly/README.md index e809cd8..fbd0dcf 100644 --- a/inst/rawrrassembly/README.md +++ b/inst/rawrrassembly/README.md @@ -20,3 +20,10 @@ rawrr.exe chromatogram ``` +## Howto build + +``` +dotnet publish rawrr-dotnet.csproj --os osx -a x64 --output /Users/cp/Library/Caches/org.R-project.R/R/rawrr/rawrrassembly/osx-x64 +dotnet publish rawrr-dotnet.csproj --os win -a x64 --output /Users/cp/Library/Caches/org.R-project.R/R/rawrr/rawrrassembly/win-x64 +dotnet publish rawrr-dotnet.csproj --os linux -a x64 --output /Users/cp/Library/Caches/org.R-project.R/R/rawrr/rawrrassembly/linux-x64 +``` diff --git a/inst/rawrrassembly/rawrr-dotnet.csproj b/inst/rawrrassembly/rawrr-dotnet.csproj new file mode 100644 index 0000000..5480680 --- /dev/null +++ b/inst/rawrrassembly/rawrr-dotnet.csproj @@ -0,0 +1,17 @@ + + + + Exe + net8.0 + rawrr + true + true + + + + + + + + +