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
- OS: Windows, Linux (macOS not tested)
- Python: >= 3.9
- 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).
- Requires Thermo Fisher CommonCore DLLs (
Installation
-
Clone the repository
git clone https://github.com/bertis-informatics/pymsio.git cd pymsio
-
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
- Download (or
git clone) RawFileReader: https://github.com/thermofisherlsms/RawFileReader - Copy the two DLLs from
RawFileReader/Libs/Net471/:ThermoFisher.CommonCore.Data.dllThermoFisher.CommonCore.RawFileReader.dll
- 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 runningpip 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/
- Copy the DLLs into
- 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~/.bashrcto keep it persistent.) - Copy the DLLs into the folder referenced by the variable.
- Windows example:
- Option A — Bundle DLLs inside the package
-
-
Install pymsio
Option A — Conda environment
conda create -n pymsio-env python=3.9 -y conda activate pymsio-env pip install -e .
Option B — pip + venv
python -m venv .venv # Linux/macOS source .venv/bin/activate # Windows PowerShell # .\.venv\Scripts\Activate.ps1 pip install -e .
Quick Start
Read a file (Thermo RAW or mzML) via ReaderFactory
from pathlib import Path
from pymsio.readers import ReaderFactory
path = Path("path/to/your/file.raw") # or .mzML
# 1) Get appropriate reader
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), [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)
Read multiple frames
frame_nums = meta_df["frame_num"].to_list() # or List[] which has frame numbers
peak_arr = reader.get_frames(frame_nums)
print(peak_arr.shape)
Notes
- If Thermo RAW fails with missing assemblies, double-check that the two DLLs are in:
PYMSIO_THERMO_DLL_DIR(Environment variable) or.../{cwd}/dlls/thermo_fisher/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymsio-0.1.5.tar.gz.
File metadata
- Download URL: pymsio-0.1.5.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c00b789aad0a50a10b0f1d25bb295564f908c20708318f9a296a515b751b6c89
|
|
| MD5 |
9debd01b523a2744fd5e2d9b38700f29
|
|
| BLAKE2b-256 |
1db6bb18dc9b955ffcfc76336b339d33c8e35211172de5451523808b82498422
|
File details
Details for the file pymsio-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pymsio-0.1.5-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8677691da1934cccd208951d6934762eaad3b5c599b7a1e51e4f4b02a96fa2d9
|
|
| MD5 |
ae10ce85d9016ef502ad63a0450536d6
|
|
| BLAKE2b-256 |
708e83087692213b19ac6555cb0eb5eaa64ec1de540f0ae65f995c6563a512f2
|