Skip to main content

OpenTFRaw

CI DOI crates.io PyPI docs.rs License: Apache-2.0 Rust MSRV

Part of the OpenMassSpec stack for mass spectrometry raw-file access.

Rust and Python reader for Thermo Fisher .raw mass spectrometry files. It is tested on format versions 63, 64 and 66, from LTQ ion traps through Orbitrap Astral and TSQ Altis (see Known issues and gaps and CORPUS.md).

Documentation: sigilweaver.app/opentfraw/docs

Known issues and gaps

Measured on the public test corpus (291 files from 56 PRIDE datasets).

  • Scan metadata is wrong on 34 of 291 corpus files (12%). On these files the scan event is misread: MS level, polarity, analyzer, activation and precursor fields can be wrong, for example MS2 scans reported as negative-polarity MS1 in a positive-mode run. Peak m/z and intensity values are not affected. Affected: 30 of 52 Orbitrap Fusion Lumos files (PXD007683, PXD025230, PXD037285, PXD064117, PXD067311, PXD070648), 2 of 2 Orbitrap Ascend files (PXD061791), 1 of 18 Orbitrap Eclipse files (PXD054530) and 1 LTQ file (PXD039587).
  • Precursor m/z reads as 0.5 on the MS2 scans of 4 Orbitrap Fusion Lumos files (PXD023217): target_mz and selected_mz are 0.5 while the scan filter and the reaction hold the real precursor (for example 652.9).
  • Activation methods: CID, HCD, ETD and EThcD are identified. ETD and EThcD are read only from format version 66 files (no older ETD file is in the corpus). Other methods (UVPD, ECD, PQD and so on) decode as unknown, and mzML then has no dissociation-method term.
  • Scan filter lock token: scan_filter() renders lock only on a scan whose trailer reports at least one found lock mass. A scan that reports zero found but keeps the previous scan's nonzero correction renders no lock. This is the case for 24,273 of 27,832 scans in the public Q Exactive HF-X acquisition PXD071477 and 35,221 of 51,254 in the Exploris 480 acquisition PXD064947. The files do not show whether such a scan counts as lock-corrected: on the Q Exactive Plus and HF-X files a preamble byte separates it from both a found lock mass and a method with no lock mass, but the byte has no public documentation and is constant on Exploris 480, so it is not used.
  • Analyzer is not reported for Orbitrap Astral MS2 scans and for TSQ triple-quadrupole scans.
  • SRM data: polarity is always reported as positive and isolation width as 0.7. A TSQ Vantage (format version 63) flat-peak record does not state its peak count, so the reader checks the default count (data_size - 1, else data_size - 2) against the scan index: finite and ascending m/z, an intensity sum equal to the total current, m/z inside the indexed range (with a total current of 0 an agreeing read cannot be told from an all-zero misaligned one). When the default count disagrees, every count from data_size - 1 down to data_size - 12 is tried. If exactly one agrees the scan is recovered: its peaks use that count and the spectrum carries opentfraw.peak_count_recovered (1,969 of the 35,098 scans of PXD020246, none of the other public files). If none agrees, or more than one does (a tie is never broken), the scan is unverified: the default peaks are returned unchanged, may hold NaN or descending m/z, and the spectrum carries opentfraw.peak_count_unverified (none in the public corpus). A true count of zero is never tried, so a scan with data_size of 2 or more and no peaks is unverified, not empty. Recovered and unverified scans are counted wherever they are read: OpenTfRawSource::recovered_peak_count_scans() and unverified_peak_count_scans(), RawFileReader::peak_counts_recovered() and peak_counts_unverified() (decodes since open), the peak_count field of extract_spectrum / iter_spectra records, a UserWarning from Python peaks(), scan() and to_mzml, and a warning from the to_mzml example. A record that matches no layout raises an error, and to_mzml(..., skip_unreadable=True) (Python) or the to_mzml example's --skip-unreadable flag writes the other scans and reports how many were left out.
  • Profile spectra with an unrecognised calibration layout have NaN m/z values; mzML reports the count in opentfraw.unconverted_profile_bins.
  • m/z accuracy follows the instrument's stored calibration. In FTMS MS1 scans of 223 corpus files, background ions with known masses (polysiloxanes, diisooctyl phthalate) are within 0.55 ppm of their theoretical m/z at the median and 4.1 ppm at the 95th percentile.
  • Tested files: format versions 63, 64 and 66 only; positive polarity only in the corpus (two negative-mode Q Exactive Plus files back opt-in tests, see CORPUS.md); no GC-Orbitrap, LCQ-family, Orbitrap ID-X, Exactive, TSQ Quantis/Endura/Fortis or single-quadrupole files; no data from non-MS controllers (UV, PDA). Other versions and instruments may open but are untested.

Install

Prefer openmassspec-io with the thermo feature/extra unless you need this parser standalone (minimal dependencies, or building your own abstraction) - the umbrella gives you format auto-detection, mzML conversion, and Arrow streaming across all wired-in vendors for free:

cargo add openmassspec-io --features thermo
pip install openmassspec[thermo]

Standalone:

Rust:

cargo add opentfraw

Python:

pip install opentfraw

Quickstart

Rust:

use std::{fs::File, io::BufReader};
use opentfraw::RawFileReader;

let raw = RawFileReader::open_path("sample.raw")?;
// Buffer the scan reads: an unbuffered File is about 11x slower.
let mut file = BufReader::new(File::open("sample.raw")?);
let info = &raw.run_header.sample_info;
for scan_num in info.first_scan_number..=info.last_scan_number {
    let peaks = raw.read_scan_peaks(&mut file, scan_num)?;
    println!("scan {scan_num}: {} peaks", peaks.len());
}

Python:

import opentfraw

raw = opentfraw.RawFile("run.raw")
mz, intensity = raw.peaks(3)
print(raw.scan(3)["filter_string"])
raw.to_mzml("run.mzML")

See the docs site for the full guide, format specification, and API reference.

Used by

Project Description
Mascope by Ultra Trace Mass spectrometry data analysis platform using OpenTFRaw to ingest Thermo .raw files.

License

Apache-2.0. See LICENSE.

The format specification was developed by binary analysis of public mass-spectrometry datasets (PRIDE accessions). See CORPUS.md and ATTRIBUTION.md.

Metadata

Release files for opentfraw 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentfraw 3.1.1
File Size Uploaded Provenance Actions
opentfraw-3.1.1.tar.gz 162.0 kB With provenance Details for opentfraw-3.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for opentfraw 3.1.1
File Actions
opentfraw-3.1.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for opentfraw-3.1.1-cp38-abi3-win_amd64.whl
opentfraw-3.1.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for opentfraw-3.1.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
opentfraw-3.1.1-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for opentfraw-3.1.1-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
opentfraw-3.1.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for opentfraw-3.1.1-cp38-abi3-macosx_11_0_arm64.whl
opentfraw-3.1.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for opentfraw-3.1.1-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 3.5 MB

Release files / opentfraw-3.1.1.tar.gz

Download URL opentfraw-3.1.1.tar.gz
Size 162.0 kB
Tags Source
SHA-256 checksum
How to use checksums
71c9dd1783077986c6462eb071275b9e62b151c008128007bfd51da72f169243
BLAKE2b-256 checksum
How to use checksums
4102b3ce10eb30395be9dd4f8591686d4ebb6e6725de1e399594f4e250354f10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / opentfraw-3.1.1-cp38-abi3-win_amd64.whl

Download URL opentfraw-3.1.1-cp38-abi3-win_amd64.whl
Size 556.4 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c44ac5c556e21e7a404f432785bcc4f69a4244a5074194fae2b2dc7d134771f1
BLAKE2b-256 checksum
How to use checksums
22731879d3ab1b4ac8016ed2d7e4c35a0548286b8a174c8de5d525b382ba44f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / opentfraw-3.1.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL opentfraw-3.1.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 735.7 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
742faa998b7a1ff7dbf96bc964bf93f2734ec130d0f3ded74f5e5fcdbe18679a
BLAKE2b-256 checksum
How to use checksums
b3aab6c8609ad80ed349c0c23786f41e576192055e8be30eb340227ed407403b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / opentfraw-3.1.1-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL opentfraw-3.1.1-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 717.0 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0dbe6bcc84050d0fc063e38a93cac79ede16031ba80bd22e25e2ce20e053cfbb
BLAKE2b-256 checksum
How to use checksums
c3434e6c73a7b9b2947f3a7ad47ac9c8bc886dd0e959bd9c6b7c320f6eea8c02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / opentfraw-3.1.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL opentfraw-3.1.1-cp38-abi3-macosx_11_0_arm64.whl
Size 661.5 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f4cb5382092ea41ba85b741fd18e7c8d77ae6cd0bcff250978e391f644e318fa
BLAKE2b-256 checksum
How to use checksums
47c876647bf3a07acb214a72af0bf6b4c367f6881adf04a5b4da5b7319fdb113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / opentfraw-3.1.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL opentfraw-3.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 673.6 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5c18de75a46b828557c9d8f63cdcc9506d9c23d5e93625142bbbdcb6eb0a6ae7
BLAKE2b-256 checksum
How to use checksums
7cff765431808b7c36e5dbf657e593929e580e882a43e5c920b215da9ec8ce04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for opentfraw 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for opentfraw-3.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page