Metadata-Version: 2.4
Name: pythermo
Version: 0.2.7
Summary: A python-based reader for thermofisher's proprietary file formats.
License: Proprietary
License-File: LICENSE
Author: Bionsight
Author-email: dev@bionsight.com
Requires-Python: >=3.10, <3.13
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: loguru
Requires-Dist: numpy
Requires-Dist: pythonnet (>=3.0,<4.0)
Project-URL: Documentation, https://github.com/bionsight/pythermo
Project-URL: Homepage, https://github.com/bionsight/pythermo
Project-URL: Repository, https://github.com/bionsight/pythermo
Description-Content-Type: text/markdown

# PyThermo

This is a python module that allows access to Thermo Orbitrap raw mass spectrometer files. Using this library makes it possible to automate the analysis of mass spectra, without having to export the data first with another tool. This module is a wrapper that builds upon the RawFileReader project which is a library developed for C#. Structures have been implemented to make processing data more convenient for Python users.

This module is originally from [fisher_py](https://github.com/ethz-institute-of-microbiology/fisher_py), and it is still in development and is not yet ready for use.

## Getting Started

**For full access to Thermo Raw files, install .NET instead of Mono.**  
Mono has limitations and cannot provide complete functionality due to [this issue](https://github.com/bionsight/pythermo/blob/95e680aeb8941587d0d5d5759a2307f1692b723c/pythermo/raw_file_reader/raw_file_access.py#L145-L147).

Download .NET from: https://dotnet.microsoft.com/download/dotnet/8.0/runtime

### Linux Installation

Install `.NET` via `sanp` or `script` depending on your system.

**Option 1: Using snap**
```bash
sudo snap install dotnet-sdk --classic
# For specific version
sudo snap install dotnet-sdk --classic --channel 8.0/stable
```

**Option 2: Using installation script**
```bash
# Download the installer
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
# or
curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh

# Make executable and install
chmod +x ./dotnet-install.sh
./dotnet-install.sh --version latest
```

For more installation options, see: https://learn.microsoft.com/dotnet/core/install/linux

### Mono Installation

Install `mono` via `brew` or `conda` depending on your system.

**Option 1: Using conda**

```bash
conda install -c conda-forge mono
```

**Option 2: Using brew**

```bash
brew install mono
```

You may need extra packages to run tests, i.e. `make check && make test`:

```bash
conda install -c conda-forge pre-commit
```

### Pythermo Installation

Install `pythermo` from the internal PyPI repository:

```bash
pip install pythermo -i <internal PyPI repository URL> --trusted-host
```

See [Publishing to our Internal PyPI Repositories](#publishing-to-our-internal-pypi-repositories) for more details.

- [ ] apply mypy to pythonnet modules

## Development Setup

To kickstart your development:

1. Install Python3 and Poetry.

   ```bash
   poetry install  # This installs all project dependencies
   ```

2. To engage the virtual environment:

   ```bash
   poetry shell
   ```

## Documentation

Utilize Sphinx to curate documentation:

```bash
poetry shell
cd docs
# Note: Inspect source/conf.py and source/index.rst
make html
# Note: Access docs at docs/build/apidocs/index.html
```

For a streamlined approach:

```bash
make docs
```

The documentation is also hosted [here](https://super-adventure-gq2gr21.pages.github.io/).

## Version Management

We rely on the [poetry-bumpversion] plugin to synchronize versions in `pyproject.toml` and `__init__.py`. To bump the version, run:

```bash
poetry run bumpversion [major|minor|patch]
```

You can also set pre-release versions:

```bash
poetry run bumpversion --allow-dirty --no-tag [major|minor|patch]-dev
```

## Publishing to our Internal PyPI Repositories

Our organization maintains two PyPI servers: `bionsight` and `bionsight-dev`. Their URLs are:

```text
https://bionsight-229159756106.d.codeartifact.ap-northeast-1.amazonaws.com/pypi/pypi/simple/
https://bionsight-229159756106.d.codeartifact.ap-northeast-1.amazonaws.com/pypi/pypi-dev/simple/
```

Retrieve the authentication credentials from the AWS CodeArtifact dashboard or fetch them via the AWS CLI:

```bash
aws codeartifact get-authorization-token --domain bionsight --domain-owner 229159756106 --region ap-northeast-1 --query authorizationToken --output text
```

To configure `poetry`, either update its configuration or set environment variables:

```bash
export POETRY_HTTP_BASIC_BIONSIGHT_USERNAME=aws
export POETRY_HTTP_BASIC_BIONSIGHT_PASSWORD=<ACCESS TOKEN>

export POETRY_HTTP_BASIC_BIONSIGHT_DEV_USERNAME=aws
export POETRY_HTTP_BASIC_BIONSIGHT_DEV_PASSWORD=<ACCESS TOKEN>
```

You may use the following commands to get the token and publish to the internal PyPI repositories instead:

```bash
make get-pypi-token
make publish-rc  # Publish to bionsight-dev
make publish     # Publish to bionsight
```

### Linting and Testing

We harness `tox` to execute tests across various environments:

```bash
make check
```

Or,

```bash
make test
# Alternatively
poetry run tox run
```

### Troubleshooting

#### OSError: cannot load library '/path/to/libmonosgen-2.0.dylib'

This occurs when the `mono` library is not found. Make sure that `mono` is installed on your system.

```bash
conda install -c conda-forge mono
```

and set the pythonnet configuration as follows:

```bash
export PYTHONNET_MONO_LIBMONO=/path/to/libmonosgen-2.0.dylib
```

### Managing Dependencies with Poetry

Poetry is our choice for managing dependencies, Python versions, and virtual environments:

```
$: poetry search <Package-Name>
$: poetry add [-D] <Package-Name[==Package-Version]>
```

### Performance Profiling

To run performance profiling:

```
$: poetry run python ./pythermo/profiler.py
```

## License

MIT

## Third-party licenses and copyright

RawFileReader reading tool. Copyright © 2016 by Thermo Fisher Scientific, Inc. All rights reserved. See [RawFileReaderLicense.md](https://github.com/ethz-institute-of-microbiology/fisher_py/blob/main/RawFileReaderLicense.md) for licensing information.
Note: anyone receiving RawFileReader as part of a larger software distribution (in the current context, as part of fisher_py) is considered an "end user" under section 3.3 of the RawFileReader License, and is not granted rights to redistribute RawFileReader.

