# Mzml Spectral Parsing

> Use when when beginning a metabolomics annotation workflow with raw MS2 spectral data in .mzML format. This step is necessary when you have vendor-converted or standard .

- Skill: `holobiomicslab/mzml-spectral-parsing` (Agent Skill)
- Install (CLI): `npx skillmds@latest add holobiomicslab/mzml-spectral-parsing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/holobiomicslab/mzml-spectral-parsing/raw
- Safety review: PASS (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- License: CC-BY-4.0
- Author: HolobiomicsLab (https://skillmd.com/u/holobiomicslab)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/holobiomicslab/mzml-spectral-parsing

---


# mzML spectral parsing

## Summary

Load and parse MS2 .mzML format mass spectrometry spectral data into memory using the Spectra R package, preparing it for downstream spectral database dereplication and compound annotation. This is the entry point for the MAW metabolomics annotation workflow.

## When to use

When beginning a metabolomics annotation workflow with raw MS2 spectral data in .mzML format. This step is necessary when you have vendor-converted or standard .mzML files and need to extract spectrum objects (precursor m/z, retention time, fragmentation patterns) for querying against spectral or compound databases.

## When NOT to use

- Input data is already in a parsed R Spectra object or equivalent in-memory format; re-parsing would be redundant.
- Data is in vendor-specific binary format (e.g., raw .raw Thermo files) without prior conversion to .mzML; use vendor conversion tools or MSConvert first.
- Performing only computational annotation without access to raw spectral data (e.g., using pre-computed spectral libraries or metadata tables).

## Inputs

- MS2 .mzML format spectral data files
- File path to .mzML file

## Outputs

- Spectra R object containing parsed MS2 spectra with precursor m/z, retention time, fragmentation m/z, and intensity arrays
- In-memory spectrum collection ready for dereplication and annotation

## How to apply

Use the R Spectra package to import .mzML files into R memory as spectrum objects. The Spectra package handles the binary encoding, metadata parsing, and spectrum extraction from the mzML XML structure. Load the data early in the workflow, before any filtering or database dispatch. Verify that all spectra are imported with complete precursor m/z, MS level, and fragmentation intensity arrays intact. This parsed object is then passed to subsequent dereplication steps (spectral matching via GNPS/HMDB/MassBank or compound prediction via SIRIUS/MetFrag).

## Related tools

- **Spectra** (R package for parsing and managing MS2 spectral data from .mzML files into structured Spectra objects) — https://rformassspectrometry.github.io/Spectra/
- **R** (Host language and runtime for executing Spectra-based spectral parsing workflows)

## Examples

```
# In R, after installing Spectra package:
library(Spectra)
spectra_obj <- Spectra("your_file_name.mzML")
# spectra_obj now contains parsed MS2 spectra ready for dereplication
```

## Evaluation signals

- All MS2 spectra from the .mzML file are successfully imported with no missing precursor m/z or fragmentation data.
- Spectra object contains correct metadata: precursor m/z, retention time, MS level (=2), collision energy where available.
- Number of spectra in the Spectra object matches the expected count from the original .mzML file.
- Fragmentation intensity arrays are non-empty and span the expected m/z range (e.g., above precursor m/z for fragment ions).
- Spectra object can be passed without error to downstream dereplication functions (GNPS/HMDB/MassBank matching or SIRIUS/MetFrag dispatch).

## Limitations

- Spectra package requires .mzML format; other formats (netCDF, mzXML, vendor raw) must be pre-converted.
- Large .mzML files (>10 GB) may require significant RAM for in-memory storage; batch processing or HPC recommended per README.
- Metadata completeness depends on .mzML source; some vendors omit collision energy or retention time, which may affect downstream annotation confidence.
- The parsed Spectra object is stored in R memory and is session-dependent; results must be exported before session closure.

## Evidence

- [intro] The workflow takes MS2 .mzML format data files as an input in R: "workflow takes MS2 .mzML format data files as an input in R"
- [intro] Spectral database dereplication is performed using the R Package Spectra: "performs spectral database dereplication using R Package Spectra"
- [other] Load MS2 .mzML spectral data in R using the Spectra package: "Load MS2 .mzML spectral data in R using the Spectra package"

