agentsclimarketplace

Ms2 fragmentation spectrum parsing

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/lc-ms/skills/ms2-fragmentation-spectrum-parsing

Use when you have raw MS2 spectra in common formats (mzML, mzXML, msp, MGF, JSON) and need to convert them into normalized, queryable spectral objects for downstream analysis such as MS2 fingerprinting, spectral similarity scoring, or sample comparison.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill ms2-fragmentation-spectrum-parsing

Assembled 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.2k tokens by cl100k_base, as published. Nobody here has run it

ms2-fragmentation-spectrum-parsing

Summary

Parse and normalize MS2 fragmentation spectra from raw mass spectrometry files into structured spectral objects with validated metadata. This is the foundational step for any downstream MS2-based analysis, enabling extraction of peaks, neutral losses, and chemical metadata for fingerprinting or similarity scoring.

When to use

You have raw MS2 spectra in common formats (mzML, mzXML, msp, MGF, JSON) and need to convert them into normalized, queryable spectral objects for downstream analysis such as MS2 fingerprinting, spectral similarity scoring, or sample comparison. Apply this skill when starting a metabolomics workflow where spectral data integrity, metadata consistency, and peak-loss extraction are prerequisites.

When NOT to use

  • Input is already a feature table or MS2 fingerprint (occurrence counts of peaks/losses across samples) — fingerprinting has already aggregated individual spectra.
  • MS1 data only, without MS2 fragmentation spectra — this skill requires tandem MS data.
  • Data from untargeted analyses where spectral parsing is not the bottleneck and generic import functions suffice.

Inputs

  • Raw MS2 spectra file (mzML, mzXML, msp, MGF, or JSON format)
  • Sample metadata (precursor m/z, retention time, ionization mode, collision energy, polarity)

Outputs

  • Parsed and normalized Spectrum objects with metadata and peak lists
  • Extracted m/z peaks per spectrum
  • Computed neutral losses (precursor m/z − peak m/z) for each peak
  • Validated spectral data ready for fingerprinting or similarity scoring

How to apply

Load MS2 spectra from input sample files using matchms parsers that support mzML, mzXML, msp, MGF, and JSON formats. Apply matchms normalization functions to standardize metadata (precursor m/z, charge state, collision energy, ionization mode) and clean peak lists by removing artifacts and low-intensity noise. Extract all m/z peaks from each parsed MS2 spectrum and compute neutral losses by subtracting each peak m/z from the precursor m/z value. Validate that precursor masses and peak m/z values are within expected instrumental ranges and that no peaks exceed the precursor m/z. Serialize normalized spectra with their metadata and peak/neutral loss lists into structured formats (JSON or internal spectral objects) for downstream fingerprinting or comparison workflows.

Related tools

  • matchms (Primary parser and normalizer for MS2 spectra; handles multiple file formats (mzML, mzXML, msp, MGM, JSON) and standardizes metadata and peak lists) — https://github.com/matchms/matchms
  • Python (Programming environment for script development and data manipulation during parsing workflow)
  • numpy (Vectorized computation of neutral losses and peak statistics during spectrum processing)

Examples

from matchms.importing_utils import load_from_msp; spectra = load_from_msp('sample.msp'); [print(s.precursor_mz, len(s.peaks)) for s in spectra[:5]]

Evaluation signals

  • All spectra have valid precursor m/z values and non-null peak lists after parsing.
  • Neutral loss values (precursor m/z − peak m/z) are all non-negative and ≤ precursor m/z.
  • Metadata fields (retention time, ionization mode, collision energy, charge state) are populated and consistent across all spectra.
  • Output spectral objects can be serialized to JSON or CSV without errors and round-trip correctly.
  • Peak m/z values are sorted in ascending order within each spectrum and match original raw spectra (within instrument precision).

Limitations

  • Parsing accuracy depends on correctness of the input file format and compliance with format specification; corrupted or non-standard files may fail to parse completely.
  • Metadata cleaning and normalization heuristics in matchms may not handle all edge cases (e.g., missing precursor m/z, unrealistic charge states), potentially requiring manual curation.
  • Very large spectra (thousands of peaks) may introduce computational overhead during neutral loss calculation; sparse peak filtering may be needed upstream.
  • Different MS vendors and data acquisition softwares may produce non-standard metadata fields or peak representations that require vendor-specific preprocessing.

Evidence

  • [other] Load MS2 spectra from the input sample file using matchms to parse and normalize fragmentation data.: "Load MS2 spectra from the input sample file using matchms to parse and normalize fragmentation data."
  • [readme] matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data (MS/MS).: "Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data (MS/MS)."
  • [other] Extract all m/z peaks from each MS2 spectrum and compute neutral losses by subtracting each peak m/z from the precursor m/z.: "Extract all m/z peaks from each MS2 spectrum and compute neutral losses by subtracting each peak m/z from the precursor m/z."
  • [readme] The software supports a range of popular spectral data formats, including mzML, mzXML, msp, metabolomics-USI, MGF, and JSON.: "The software supports a range of popular spectral data formats, including mzML, mzXML, msp, metabolomics-USI, MGF, and JSON."
  • [readme] Matchms offers an array of tools for metadata cleaning and validation, alongside basic peak filtering, to ensure data accuracy and integrity.: "Matchms offers an array of tools for metadata cleaning and validation, alongside basic peak filtering, to ensure data accuracy and integrity."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.