mass-spectrometry-data-import
Summary
Load raw mass spectrometry spectral data from standard file formats (mzML, mzXML, msp, MGF, JSON) into matchms Spectrum objects for downstream processing and analysis. This is the foundational step that transforms heterogeneous file formats into a uniform, in-memory representation suitable for cleaning, filtering, and similarity comparisons.
When to use
When beginning a new mass spectrometry analysis workflow with raw spectral data files in mzML, mzXML, msp, MGF, or JSON format. Use this skill whenever you need to load spectra from public databases or instrument-generated files before applying metadata validation, peak filtering, or similarity scoring.
When NOT to use
- If spectral data is already loaded in memory as Spectrum objects from a prior workflow step.
- If the input file is in an unsupported format not listed in matchms documentation (e.g., raw vendor binary formats without prior conversion).
- If the task requires only metadata inspection without needing the full peak intensity data (consider metadata-only parsing if available).
Inputs
- Spectral data file in mzML format
- Spectral data file in mzXML format
- Spectral data file in msp format
- Spectral data file in MGF format
- Spectral data file in JSON format
- File path or URI to spectral data
Outputs
- Spectrum collection (Python object list or iterable)
- Array of Spectrum objects with parsed peaks and metadata
How to apply
Use matchms import functions (e.g., import_spectra() or format-specific loaders) to read the spectral data file and parse it into a collection of Spectrum objects. The import operation automatically handles format-specific parsing rules and metadata extraction. After import, verify that the spectrum collection contains the expected number of spectra and that critical metadata fields (precursor m/z, instrument type, retention time) are populated. The imported spectra are then passed directly to subsequent cleaning, filtering, or comparison steps in the workflow.
Related tools
- matchms (Core library providing spectral data import functions and Spectrum object representation) — https://github.com/matchms/matchms
- Python (Programming language and runtime for executing matchms import operations)
Examples
from matchms.importing_utils import load_from_mgf
spectra = load_from_mgf('library.mgf')
print(f'Loaded {len(spectra)} spectra')
Evaluation signals
- Spectrum collection size matches the expected number of spectra in the input file (or summary reported by the import function).
- All Spectrum objects contain valid peaks (m/z and intensity pairs) with m/z values in expected range (e.g., 0–2000 m/z).
- Critical metadata fields (precursor_mz, instrument_type, spectrum_id) are non-null for all or most spectra (compare against file statistics).
- No exceptions or warnings raised during import; import completes in expected time (< seconds for typical libraries).
- Exported spectrum collection (to MGF or JSON) maintains equivalent peak and metadata content as original file.
Limitations
- Matchms supports only the listed formats (mzML, mzXML, msp, MGF, JSON); other vendor-proprietary formats require prior conversion.
- Import does not validate or clean metadata; metadata errors in the source file are preserved in the imported Spectrum objects.
- Large spectral libraries (hundreds of thousands of spectra) may require significant memory; sparse or streaming import is not covered in this step.
- Metabolomics-USI format is mentioned as supported in the README but not detailed in the workflow cards; compatibility depends on the specific USI variant.
Evidence
- [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"
- [other] Load spectral data from a file (MGF, MSP, or mzML format) using matchms import functions: "Load spectral data from a file (MGF, MSP, or mzML format) using matchms import functions"
- [readme] It facilitates the implementation of straightforward, reproducible workflows, transforming raw data from common mass spectra file formats into pre- and post-processed spectral data: "It facilitates the implementation of straightforward, reproducible workflows, transforming raw data from common mass spectra file formats into pre- and post-processed spectral data"
- [readme] Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data: "Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data"
1---2name: mass-spectrometry-data-import-33description: Use when when beginning a new mass spectrometry analysis workflow with raw spectral data files in mzML, mzXML, msp, MGF, or JSON format.4license: CC-BY-4.05metadata:6 edam_operation: http://edamontology.org/operation_37637 edam_topics:8 - http://edamontology.org/topic_35209 - http://edamontology.org/topic_012110 tools:11 - matchms12 - pytest13 - Python14 - R15 - R GUI16 - SMART17 techniques:18 - mass-spectrometry19derived_from:20- doi: 10.1186/s13321-024-00878-121 title: matchms22- doi: 10.1021/acs.analchem.5c0322523 title: ''24evidence_spans:25- Matchms offers an array of tools for metadata cleaning and validation26- Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data27- make sure the existing tests still work by running ``pytest``28- SMART written in R and R GUI has been developed as user-friendly software29claims: []30provenance:31 collection: https://w3id.org/holobiomicslab/asb-skill/collection/metabolomics/v232 assembled_by: scripts/collect_metabolomics_collection.py33 sources:34 - build: coll_fbmn_stats_cq35 doi: 10.1038/s41596-024-01046-336 title: FBMN-STATS37 - build: coll_matchms38 doi: 10.1186/s13321-024-00878-139 title: matchms40 - build: coll_smart_2_0_cq41 doi: 10.1021/acs.analchem.5c0322542 title: SMART 2.043 dedup_kept_from: coll_matchms44schema_version: 0.2.045attribution:46 generator: AgenticScienceBuilder47 original_doi: 10.1186/s13321-024-00878-148 all_source_dois:49 - 10.1186/s13321-024-00878-150 - 10.1021/acs.analchem.5c0322551 zenodo_doi: 10.5281/zenodo.2079402752 curators: []53 promoter: Louis-Félix Nothias54 sponsor: CNRS & Université Côte d'Azur55---5657# mass-spectrometry-data-import5859## Summary6061Load raw mass spectrometry spectral data from standard file formats (mzML, mzXML, msp, MGF, JSON) into matchms Spectrum objects for downstream processing and analysis. This is the foundational step that transforms heterogeneous file formats into a uniform, in-memory representation suitable for cleaning, filtering, and similarity comparisons.6263## When to use6465When beginning a new mass spectrometry analysis workflow with raw spectral data files in mzML, mzXML, msp, MGF, or JSON format. Use this skill whenever you need to load spectra from public databases or instrument-generated files before applying metadata validation, peak filtering, or similarity scoring.6667## When NOT to use6869- If spectral data is already loaded in memory as Spectrum objects from a prior workflow step.70- If the input file is in an unsupported format not listed in matchms documentation (e.g., raw vendor binary formats without prior conversion).71- If the task requires only metadata inspection without needing the full peak intensity data (consider metadata-only parsing if available).7273## Inputs7475- Spectral data file in mzML format76- Spectral data file in mzXML format77- Spectral data file in msp format78- Spectral data file in MGF format79- Spectral data file in JSON format80- File path or URI to spectral data8182## Outputs8384- Spectrum collection (Python object list or iterable)85- Array of Spectrum objects with parsed peaks and metadata8687## How to apply8889Use matchms import functions (e.g., `import_spectra()` or format-specific loaders) to read the spectral data file and parse it into a collection of Spectrum objects. The import operation automatically handles format-specific parsing rules and metadata extraction. After import, verify that the spectrum collection contains the expected number of spectra and that critical metadata fields (precursor m/z, instrument type, retention time) are populated. The imported spectra are then passed directly to subsequent cleaning, filtering, or comparison steps in the workflow.9091## Related tools9293- **matchms** (Core library providing spectral data import functions and Spectrum object representation) — https://github.com/matchms/matchms94- **Python** (Programming language and runtime for executing matchms import operations)9596## Examples9798```99from matchms.importing_utils import load_from_mgf100spectra = load_from_mgf('library.mgf')101print(f'Loaded {len(spectra)} spectra')102```103104## Evaluation signals105106- Spectrum collection size matches the expected number of spectra in the input file (or summary reported by the import function).107- All Spectrum objects contain valid peaks (m/z and intensity pairs) with m/z values in expected range (e.g., 0–2000 m/z).108- Critical metadata fields (precursor_mz, instrument_type, spectrum_id) are non-null for all or most spectra (compare against file statistics).109- No exceptions or warnings raised during import; import completes in expected time (< seconds for typical libraries).110- Exported spectrum collection (to MGF or JSON) maintains equivalent peak and metadata content as original file.111112## Limitations113114- Matchms supports only the listed formats (mzML, mzXML, msp, MGF, JSON); other vendor-proprietary formats require prior conversion.115- Import does not validate or clean metadata; metadata errors in the source file are preserved in the imported Spectrum objects.116- Large spectral libraries (hundreds of thousands of spectra) may require significant memory; sparse or streaming import is not covered in this step.117- Metabolomics-USI format is mentioned as supported in the README but not detailed in the workflow cards; compatibility depends on the specific USI variant.118119## Evidence120121- [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"122- [other] Load spectral data from a file (MGF, MSP, or mzML format) using matchms import functions: "Load spectral data from a file (MGF, MSP, or mzML format) using matchms import functions"123- [readme] It facilitates the implementation of straightforward, reproducible workflows, transforming raw data from common mass spectra file formats into pre- and post-processed spectral data: "It facilitates the implementation of straightforward, reproducible workflows, transforming raw data from common mass spectra file formats into pre- and post-processed spectral data"124- [readme] Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data: "Matchms is a versatile open-source Python package developed for importing, processing, cleaning, and comparing mass spectrometry data"