Skip to main content

MS I/O readers with optional vendor bindings

Project description

Pymsio

Pymsio is a lightweight module for reading mass-spectrometry data files into a unified NumPy/Polars representation.
Its design and implementation are based on the AlphaRaw project: https://github.com/MannLabs/alpharaw/.

It currently supports:

  • Thermo RAW files (via pythonnet + Thermo Fisher CommonCore DLLs)
  • mzML files

Both formats are exposed through a common interface.


Requirements

  • Supported OS: Windows, Linux
  • Python: >= 3.8
  • Thermo RAW:
    • Requires Thermo Fisher CommonCore DLLs (ThermoFisher.CommonCore.Data.dll, ThermoFisher.CommonCore.RawFileReader.dll) obtained from the RawFileReader project (https://github.com/thermofisherlsms/RawFileReader).
    • Linux also needs Mono (use install_mono.sh).

Installation

  1. Clone the repository

    git clone https://github.com/bertis-informatics/pymsio.git
    cd pymsio
    
  2. Quick Install (recommended)

    The install script downloads the Thermo RawFileReader DLLs (with license agreement) and installs pymsio in one step.

    Windows PowerShell

    .\install.ps1
    

    Linux / macOS

    chmod +x install.sh
    ./install.sh
    
  3. Manual Install

    Click to expand manual installation steps

    a. Provide the Thermo DLLs (only needed for Thermo RAW)

    • Linux only: ensure Mono is installed (required by pythonnet). Use the helper script:

      ./install_mono.sh
      
    1. Download (or git clone) RawFileReader: https://github.com/thermofisherlsms/RawFileReader
    2. Copy the two DLLs from RawFileReader/Libs/Net471/:
      • ThermoFisher.CommonCore.Data.dll
      • ThermoFisher.CommonCore.RawFileReader.dll
    3. Make the DLLs discoverable:
      • Option A — Bundle DLLs inside the package <path-to-pymsio>/pymsio/dlls/thermo_fisher/
        • Copy the DLLs into pymsio/dlls/thermo_fisher/ before running pip install -e . so they ship with the installation.
        • Example:
          mkdir -p pymsio/dlls/thermo_fisher
          cp /path/to/RawFileReader/Libs/Net471/*.dll /path/to/pymsio/pymsio/dlls/thermo_fisher/
          
      • Option B — Set up an environment variable PYMSIO_THERMO_DLL_DIR
        • Windows example:
          setx PYMSIO_THERMO_DLL_DIR "<path-to-your-dll-folder>"
          
        • Linux example:
          export PYMSIO_THERMO_DLL_DIR="<path-to-your-dll-folder>"
          
          (Add the export line to ~/.bashrc to keep it persistent.)
        • Copy the DLLs into the folder referenced by the variable.

    b. Install pymsio

    pip install .
    

Quick Test

Run the test suite with pytest:

# Basic tests (import check, DLL binding check)
pytest tests/

# With reader tests (provide file paths)
pytest tests/ --raw "path/to/file.raw" --mzml "path/to/file.mzML"

Tests for readers whose file path is not provided will be automatically skipped.


Code Example

Click to expand
from pathlib import Path
from pymsio.readers import ReaderFactory

path = Path("path/to/your/file.raw")  # or .mzML

# 1) Get appropriate reader (Thermo RAW or mzML)
reader = ReaderFactory.get_reader(path)

# 2) Read metadata (Polars DataFrame)
meta_df = reader.get_meta_df()
print(meta_df.head())

# 3) Read one frame (np.ndarray, shape (N, 2), columns: [mz, intensity])
frame_num = int(meta_df.item(0, "frame_num"))
peaks = reader.get_frame(frame_num)
print(peaks.shape)

# 4) Load full dataset
msdata = reader.load()
print(msdata.peak_arr.shape)

License

This project is licensed under the Apache License 2.0.

Note: The Thermo RawFileReader DLLs are proprietary and subject to their own license. They are not included in this repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymsio-0.1.12.tar.gz (393.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymsio-0.1.12-py3-none-any.whl (392.2 kB view details)

Uploaded Python 3

File details

Details for the file pymsio-0.1.12.tar.gz.

File metadata

  • Download URL: pymsio-0.1.12.tar.gz
  • Upload date:
  • Size: 393.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pymsio-0.1.12.tar.gz
Algorithm Hash digest
SHA256 9332be3fbcc01e490540afdc73f1f66671a2758ad545667748898740a2d768f6
MD5 406c6196944297736d445c6fc60fc313
BLAKE2b-256 4d2265ea9fa16a6b09b624f7db188b54d2c4d52d03f7d65d9628b031bb074647

See more details on using hashes here.

File details

Details for the file pymsio-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: pymsio-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 392.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pymsio-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 62aad52741303065fe0b18d18a755d2eaf4f799e857ece6f7327a6cc1e1e8a3c
MD5 9fbff11c3d175da9dfeecde739ba4493
BLAKE2b-256 699bbe33f0f59fa60c3e05d29dbe2ef18e8d1a29596f5aa966a1f3b5e87c6843

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page