Mass spectrometry data format parsing
Use when you have raw MS/MS spectra in one of the supported exchange formats (.mgf, .mzML, or .msp) and need to ingest them into an MS2LDA pipeline for unsupervised motif discovery. This skill is required before any preprocessing, filtering, or ionization-mode-specific handling can occur.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mass-spectrometry-data-format-parsingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
7.0 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
mass-spectrometry-data-format-parsing
Summary
Load and parse tandem mass spectrometry (MS/MS) spectral data from standard interchange formats (.mgf, .mzML, .msp) into memory for downstream preprocessing and modeling. This is the essential first step that converts heterogeneous file formats into a unified in-memory representation suitable for spectral filtering, fragmentation analysis, and bag-of-fragments conversion.
When to use
You have raw MS/MS spectra in one of the supported exchange formats (.mgf, .mzML, or .msp) and need to ingest them into an MS2LDA pipeline for unsupervised motif discovery. This skill is required before any preprocessing, filtering, or ionization-mode-specific handling can occur.
When NOT to use
- Input is already in memory as Python objects or a parsed spectral object from another tool — skip directly to filtering.
- You have already extracted and aggregated fragment intensities into a bag-of-words or feature matrix — parsing is unnecessary.
- Input file format is not one of the three supported formats (.mgf, .mzML, .msp); conversion to a supported format is required first.
Inputs
- Mass spectrometry spectral file (.mgf format)
- Mass spectrometry spectral file (.mzML format)
- Mass spectrometry spectral file (.msp format)
Outputs
- Parsed spectrum collection (in-memory objects with precursor mass, fragments, intensities, ionization mode)
- Spectrum metadata (MS level, ionization mode, acquisition parameters)
How to apply
Use the MS2LDA.Preprocessing.load_and_clean module to read spectral data from disk. The loader automatically detects or accepts the input format (.mgf, .mzML, or .msp) and deserializes spectra into structured objects that preserve precursor mass, fragment m/z values, intensities, and ionization mode metadata. The module performs basic validation during parsing (e.g., checking for required fields, handling missing intensity values). The parsed spectrum collection is then passed directly to subsequent filtering and neutral loss extraction steps. Correct parsing is verified by confirming that spectrum count matches the input file's declared spectrum count, that all required fields (precursor mass, fragment m/z, intensity) are populated, and that no malformed records cause loader errors.
Related tools
- MS2LDA.Preprocessing.load_and_clean (Primary module for loading and parsing MS/MS spectral data from supported file formats into structured in-memory objects.) — https://github.com/vdhooftcompmet/MS2LDA
- MS2LDA (Broader toolkit that orchestrates preprocessing, modeling, and annotation; this skill is the data ingestion entry point.) — https://github.com/vdhooftcompmet/MS2LDA
Examples
from MS2LDA.Preprocessing import load_and_clean; spectra = load_and_clean.load_spectra('samples.mgf', ionization_mode='positive')
Evaluation signals
- Spectrum count in parsed collection matches declared count in input file (no records dropped due to parse errors).
- All spectra have populated precursor mass, fragment m/z arrays, and intensity arrays (no null/missing required fields).
- Ionization mode metadata (positive/negative) is correctly assigned to each spectrum based on file headers or user input.
- No parsing exceptions or malformed record warnings during load; loader completes without errors.
- Downstream filtering steps (noise removal, ionization-mode-specific handling) execute without type errors or schema violations.
Limitations
- Only three file formats (.mgf, .mzML, .msp) are supported; other MS data formats (e.g., raw proprietary formats, NetCDF) require conversion before ingestion.
- Parser assumes standard compliance with .mgf, .mzML, and .msp specifications; nonstandard or corrupted files may fail silently or produce incomplete records.
- No automatic ionization-mode detection in .mgf format; user must specify or file must include ionization mode in headers.
- Large files (>1 GB) may cause high memory consumption during parsing; chunked or streaming load is not explicitly documented.
Evidence
- [other] Load MS/MS spectra from supported input file formats (.mgf, .mzML, or .msp) using the MS2LDA.Preprocessing.load_and_clean module.: "Load MS/MS spectra from supported input file formats (.mgf, .mzML, or .msp) using the MS2LDA.Preprocessing.load_and_clean module."
- [readme] MS2LDA is an advanced tool designed for unsupervised substructure discovery in mass spectrometry data, utilizing topic modeling and providing automated annotation of discovered motifs.: "MS2LDA is an advanced tool designed for unsupervised substructure discovery in mass spectrometry data, utilizing topic modeling and providing automated annotation of discovered motifs."
- [methods] Preprocessing → filter & clean your spectra (positive/negative ion mode): "Preprocessing → filter & clean your spectra (positive/negative ion mode)"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.