<!--
SPDX-FileCopyrightText: 2024 Helmholtz-Zentrum Dresden - Rossendorf (HZDR)

SPDX-License-Identifier: CC-BY-SA-4.0
-->

# METABOLATOR: Analysis of Microcalorimetric Metabolic Data Using Monod's Equation

Curve fitting automation for metabolic load of bacteria in solutions.
The service is deployed at HZDR and available at <https://metabolator.hzdr.de>.
See also our software presentation
[in the Helmholtz Research Software Directory](https://helmholtz.software/software/metabolator).

![Screenshot of the METABOLATOR application](.gitlab/METABOLATOR.png)

## Installation

To install METABOLATOR with pipx, run:

```bash
pipx install git+https://codebase.helmholtz.cloud/metabolator/metabolator.git
```

## Usage

Start the METABOLATOR web app by running the following command:

```bash
metabolator-web
```

This is roughly equivalent to `voila metabolator/METABOLATOR.ipynb`.
However, `metabolator-web` loads the notebook file from the package resources.
Thus, it can be run without checking out the git repository.
Voilà's command line options may be passed to `metabolator-web` as well.

## CLI Tool

A first iteration of a basic command line tool is provided with METABOLATOR.
You can run it as `metabolator` which is equivalent to `python -m metabolator.cli`.
To perform analysis on an example dataset, run:

```bash
metabolator 10.14278/rodare.3175 Schizophyllum_example.xls 0
```

## Development

For development, check out the repository, then install METABOLATOR including its dev dependencies
in editiable mode:

```bash
python -m venv venv
source venv/bin/activate
python -m pip install -e .[dev]
```

Use Ruff to format your code contributions:

```bash
ruff format .
```

Run the linter and apply potential fixes:

```bash
ruff check --fix .
```

If the environment variable `METABOLATOR_DEVELOPMENT` is set, the app presents itself as a
development instance (e.g. via the header text).

## Deployment

The `conf` directory contains an [example service file for systemd](conf/metabolator.service.example)
as well as an [example nginx configuration](conf/metabolator.example.com).
We suggest running the application service as a dedicated user (not root).
This can be achieved by enabling lingering for the user with `loginctl`.
For more information see the [Voilà documentation](https://voila.readthedocs.io/en/stable/deploy.html#running-voila-on-a-private-server).

## Providing (Example) Datasets

Example dataset files (common spreadsheet formats) can be placed inside the
`metabolator/static/datasets` directory.
Please make sure to place a license file next to the dataset.
This can be done with `reuse annotate`

The app also shows search links for Rodare and Zenodo.
These searches will find publications of type dataset on the respective platform that have been
tagged with the keyword `metabolator`.
