Skip to content

Commit

Permalink
#75
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Oct 29, 2024
1 parent 5e5b736 commit 5444985
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre"),
Expand Down
14 changes: 13 additions & 1 deletion R/dotNetAssembly.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down
20 changes: 14 additions & 6 deletions R/rawrr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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/")
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -283,13 +287,15 @@ 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")
tfstdout <- tempfile(tmpdir=tmpdir)

cmd <- exe

if (exists('RAWRRDOTNET')){ mono <<- FALSE}
if (mono){
rvs <- system2(Sys.which("mono"),
args = c(shQuote(exe), shQuote(rawfile),
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand All @@ -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)),
Expand Down
7 changes: 7 additions & 0 deletions inst/rawrrassembly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ rawrr.exe <rawfile> 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
```
17 changes: 17 additions & 0 deletions inst/rawrrassembly/rawrr-dotnet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <!-- Or net7.0, depending on your setup -->
<AssemblyName>rawrr</AssemblyName>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ThermoFisher.CommonCore.BackgroundSubtraction" Version="8.0.6" />
<PackageReference Include="Thermofisher.CommonCore.MassPrecisionEstimator" Version="8.0.6" />
<PackageReference Include="ThermoFisher.CommonCore.RawFileReader" Version="8.0.6" />
</ItemGroup>
</Project>

0 comments on commit 5444985

Please sign in to comment.