# System requirements

The `rawrr` package reads Thermo Fisher raw files through a self-contained
.NET console application, the `rawrr` executable. Prebuilt binaries are
provided for six runtimes:

| OS      | x64         | arm64         |
|---------|-------------|---------------|
| Linux   | `linux-x64` | `linux-arm64` |
| macOS   | `osx-x64`   | `osx-arm64`   |
| Windows | `win-x64`   | `win-arm64`   |

The runtime is derived from the running R session (`R.version$arch`), so an
x64 R running under emulation (e.g. Rosetta 2) uses the x64 binary.

The executable is stored in the rawrr cache directory:

```
tools::R_user_dir("rawrr", which = "cache")/rawrrassembly/<runtime>/rawrr[.exe]
```

`rawrr::rawrrAssemblyPath()` returns the directory for the current session.


## Install the prebuilt executable (recommended)

No .NET installation is required.

```{r}
rawrr::installRawrrExe()
```

Use `force = TRUE` to replace an existing executable.


## Compile and link yourself

In case you prefer to compile the `rawrr` executable from C# source code,
please install the .NET 8.0 SDK.

### Linux (debian:12/ubuntu:24.04)

```{sh}
sudo apt-get install dotnet-sdk-8.0
```

### macOS (Catalina/BigSur/.../Sequoia)

https://dotnet.microsoft.com/en-us/download

### Microsoft Windows

https://dotnet.microsoft.com/en-us/download

### Build from R

```{r}
## build for the runtime of the current R session
rawrr::buildRawrrExe()

## cross-build for another runtime
rawrr::buildRawrrExe(runtime = "osx-arm64")
```

`buildRawrrExe()`

* downloads the Thermo Fisher `ThermoFisher.CommonCore` NuGet packages (once)
  into a local feed `<cache>/rawrrassembly/nupkgs`,
* runs `dotnet publish --runtime <runtime>` in a temporary directory, passing
  nuget.org and the local feed via `--source`,
* writes the executable to `<cache>/rawrrassembly/<runtime>/`.

The user's global NuGet configuration is not modified. Older rawrr versions
registered the local feed with `dotnet nuget add source`; stale entries can
make restores fail with `NU1301`. List and remove them with

```{sh}
dotnet nuget list source
dotnet nuget remove source "<name>"
```

### Build all runtimes (maintainers)

`inst/rawrrassembly/build.sh` builds all six runtimes and copies the binaries
into a versioned tree, as served by `installRawrrExe()`:

```{sh}
inst/rawrrassembly/build.sh <repo_dir> <dist_dir>
## -> <dist_dir>/<pkg_version>/<runtime>/rawrr[.exe]
```


## The Thermo Fisher RawFileReader .NET assemblies

The `ThermoFisher.CommonCore` NuGet packages (.NET 8, version 8.0.42) can be
obtained through:

https://github.com/thermofisherlsms/RawFileReader

or

by contacting Jim Shofstahl using

jim.Shofstahl@thermofisher.com

Using them requires accepting the Thermo Fisher license agreement
(`inst/rawrrassembly/RawFileReaderLicense.txt`); in interactive sessions
rawrr asks for it once.


## Test the executable

`rawrr:::.isAssemblyWorking()` only checks that the executable starts. The
test suite additionally compares the reader output of `inst/extdata/sample.raw`
against reference values (`tests/testthat/test-reference.R`).

From a source checkout, run the tests against the installed package:

```{r}
testthat::test_dir("tests/testthat", package = "rawrr",
                   load_package = "installed")
```

Or install the package including its tests and run them from anywhere:

```{sh}
R CMD INSTALL --install-tests .
Rscript -e 'testthat::test_package("rawrr")'
```

Note that the tests always use the executable of the current runtime.


## Docker

The `Dockerfile` performing `R CMD build` and `R CMD check` requires

```
from bioconductor/bioconductor_docker:devel
run apt-get update && apt-get install dotnet-sdk-8.0 -y
run R -q -e "BiocManager::install(c('BiocStyle', 'ExperimentHub', 'knitr', 'protViz', 'rmarkdown', 'tartare', 'testthat'))"
```


## Required packages to run `R CMD INSTALL`

```
BiocManager::install('ExperimentHub')
BiocManager::install('tartare')
```
