Transfer mass spectrometry files (mzML/MSZ) between endpoints using mscompress
Project description
mstransfer
Transfer mass spectrometry files (mzML / MSZ) between machines over HTTP. Files are always transported in compressed MSZ format using mscompress — mzML sources are compressed on-the-fly without temp files, and the receiving end can optionally decompress back to mzML.
Install
# Recommended — installs as an isolated CLI tool
uv tool install mstransfer
# Or with pipx
pipx install mstransfer
# Or as a project dependency
uv pip install mstransfer
pip install mstransfer
Quick start
Start a server on the receiving machine:
mstransfer serve --port 1319 --store-as msz
Upload files from the source machine:
mstransfer upload /data/experiment1.mzML /data/batch/ remote-host:1319
Usage
mstransfer serve
Start the receiver server.
mstransfer serve [--host 0.0.0.0] [--port 1319] [--output-dir ./received] [--store-as msz|mzml]
| Flag | Default | Description |
|---|---|---|
--host |
0.0.0.0 |
Bind address |
--port |
1319 |
Listen port |
--output-dir |
./received |
Where received files are written |
--store-as |
msz |
Store as msz (compressed) or mzml (decompress on arrival) |
mstransfer upload
Upload files to a server. Accepts any mix of files and directories. The last positional argument is the target.
mstransfer upload <paths...> <host[:port]> [--recursive] [--parallel 4]
| Flag | Default | Description |
|---|---|---|
--recursive, -r |
off | Recurse into directories |
--parallel, -p |
4 |
Number of concurrent uploads |
Supported file types: .mzML, .msz, .mszx.
- mzML files are compressed to MSZ on-the-fly via
compress_stream()and streamed directly into the HTTP request — no temp files on the sender. - MSZ / MSZX files are streamed as-is.
Programmatic access
You can use mstransfer as a library to send files from your own Python code:
from pathlib import Path
from mstransfer.client import send_file, send_batch
# Send a single file (Path)
result = send_file(Path("experiment.mzML"), "http://remote-host:1319")
# Send an already-opened mscompress object
from mscompress import MZMLFile, MSZFile
from mscompress.mszx import MSZXFile
mzml = MZMLFile(b"/data/experiment.mzML")
send_file(mzml, "http://remote-host:1319")
msz = MSZFile(b"/data/experiment.msz")
send_file(msz, "http://remote-host:1319")
mszx = MSZXFile.open("/data/experiment.mszx")
send_file(mszx, "http://remote-host:1319")
# Send multiple files in parallel
send_batch(
[Path("a.mzML"), Path("b.msz"), mszx],
"http://remote-host:1319",
parallel=4,
)
send_file and send_batch accept any mix of Path, MZMLFile, MSZFile, and MSZXFile inputs.
API
The server exposes a REST API under /v1/:
| Endpoint | Method | Description |
|---|---|---|
/v1/health |
GET | Server status, version, storage mode |
/v1/upload |
POST | Upload a file (streamed MSZ body) |
/v1/transfer/{id}/status |
GET | Poll transfer state |
Embedding in another app
The server is built as a FastAPI app factory:
from mstransfer import create_app
# Standalone
app = create_app(output_dir="/data/ms", store_as="mzml")
# Mount in an existing FastAPI app
from fastapi import FastAPI
main_app = FastAPI()
main_app.mount("/transfer", create_app())
How it works
flowchart LR
subgraph Sender
mzML[".mzML"] --> compress["compress_stream()"]
msz[".msz / .mszx"] --> read["read file"]
end
compress --> upload["POST /v1/upload\n(MSZ bytes)"]
read --> upload
subgraph Server
upload --> mode{store-as?}
mode -- msz --> write["write to disk"]
mode -- mzml --> temp["write temp .msz"]
temp --> decompress["decompress"]
decompress --> cleanup["cleanup temp"]
end
Development
uv sync --dev
uv run pytest
uv run ruff check src/ tests/
Pre-commit hooks
Install the pre-commit hooks to automatically run linting, type checking, and tests before each commit:
uv run pre-commit install
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
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 mstransfer-0.2.0.tar.gz.
File metadata
- Download URL: mstransfer-0.2.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68d9820f829623f2c01822f54878fc501dc080a64c98d3b4f9c7896e20fcf956
|
|
| MD5 |
dbb207245626b6a1beeb479fe6ddd292
|
|
| BLAKE2b-256 |
7aea013c2f6a5fa236503c40182812edd3cd6065b686577d74202fc713c8bba2
|
Provenance
The following attestation bundles were made for mstransfer-0.2.0.tar.gz:
Publisher:
publish.yml on chrisagrams/mstransfer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mstransfer-0.2.0.tar.gz -
Subject digest:
68d9820f829623f2c01822f54878fc501dc080a64c98d3b4f9c7896e20fcf956 - Sigstore transparency entry: 1164550545
- Sigstore integration time:
-
Permalink:
chrisagrams/mstransfer@15b0b24724aaec9f1ecf184a0791508046a3c5cd -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/chrisagrams
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15b0b24724aaec9f1ecf184a0791508046a3c5cd -
Trigger Event:
release
-
Statement type:
File details
Details for the file mstransfer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mstransfer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77f53788b7b0461d1e4297b2e16f614a71284e529f99bd6e38693ef8ff73ae70
|
|
| MD5 |
b1be60bdd3d53dc724343badbc564345
|
|
| BLAKE2b-256 |
d2431ebbff0a6c9719948b80b508c811a544fbb6c2f3a9e851389573d2df114e
|
Provenance
The following attestation bundles were made for mstransfer-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on chrisagrams/mstransfer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mstransfer-0.2.0-py3-none-any.whl -
Subject digest:
77f53788b7b0461d1e4297b2e16f614a71284e529f99bd6e38693ef8ff73ae70 - Sigstore transparency entry: 1164550586
- Sigstore integration time:
-
Permalink:
chrisagrams/mstransfer@15b0b24724aaec9f1ecf184a0791508046a3c5cd -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/chrisagrams
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15b0b24724aaec9f1ecf184a0791508046a3c5cd -
Trigger Event:
release
-
Statement type: