agentsclimarketplace

Unit test development for spectral loaders

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/ms-generic/skills/unit-test-development-for-spectral-loaders

Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill unit-test-development-for-spectral-loaders

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

  • 14 stars14 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 author says it does

Copied from the file, not written here

Use when when you have implemented parser functions for one or more mass spectrometry file formats and need to verify that metadata and peak lists are correctly extracted and converted into matchms Spectrum objects before committing to a feature branch.

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

6.2 KB, as published. Nobody here has run it

unit-test-development-for-spectral-loaders

Summary

Write and validate pytest unit tests for mass spectrometry spectral file format parsers (mzML, mzXML, msp, MGF, JSON, metabolomics-USI) to ensure correct metadata extraction and Spectrum object construction. This skill ensures parser correctness and prevents regression during development.

When to use

When you have implemented parser functions for one or more mass spectrometry file formats and need to verify that metadata and peak lists are correctly extracted and converted into matchms Spectrum objects before committing to a feature branch.

When NOT to use

  • You have not yet implemented the parser functions themselves — test development follows implementation.
  • Your file format is not among the six supported formats (mzML, mzXML, msp, MGF, JSON, metabolomics-USI) — use integration testing instead.
  • You are testing similarity scoring or spectral comparison logic — use separate similarity measure tests, not file parser tests.

Inputs

  • Parser function implementations for mzML, mzXML, msp, MGF, JSON, metabolomics-USI formats
  • Representative sample spectra files in each supported file format
  • Spectrum object schema definition

Outputs

  • pytest test suite validating parser correctness
  • Test results confirming all parsing tests pass
  • Verified Spectrum object instances with correctly extracted metadata and peak lists

How to apply

Design test cases using pytest that cover representative samples from each supported file format (mzML, mzXML, msp, MGF, JSON, metabolomics-USI). For each parser, create unit tests that validate: (1) correct extraction of spectral metadata fields, (2) accurate peak list parsing into the Spectrum object schema, and (3) absence of data corruption or loss during import. Run pytest to confirm all parsing tests pass and that existing tests remain unbroken. Use assertion statements to verify that imported spectra match expected values for key fields (metadata, peak m/z values, intensities). This ensures the parser module is production-ready before code review.

Related tools

  • pytest (Framework for writing and executing unit tests to validate parser functions and Spectrum object construction)
  • Python (Language for implementing parser functions and test code that manipulate Spectrum objects)
  • matchms (Source package providing Spectrum object schema and parser module under test) — https://github.com/matchms/matchms

Examples

pytest tests/test_spectral_parsers.py -v

Evaluation signals

  • All pytest tests pass with zero failures or errors when run on the parser module.
  • Existing test suite continues to pass (no regression) after new parser tests are added.
  • Assertions in each test confirm that metadata fields (e.g., precursor m/z, collision energy, compound name) are extracted with exact or expected-range values.
  • Peak list assertions verify that m/z and intensity arrays in Spectrum objects match the source file values within acceptable numerical precision.
  • Test coverage includes at least one representative sample file from each of the six supported formats (mzML, mzXML, msp, MGF, JSON, metabolomics-USI).

Limitations

  • Tests validate individual parsers in isolation; cross-format equivalence (e.g., identical spectra loaded from mzML vs. msp) requires integration tests.
  • Unit tests do not capture downstream effects of parsing errors on similarity scoring or spectral comparison workflows.
  • Numerical precision assertions must account for floating-point representation in each file format; tests may require tolerance thresholds (e.g., ±0.01 m/z).
  • Tests assume sample spectra files are available and representative; malformed or edge-case files may not be caught by basic unit tests.

Evidence

  • [other] Implement individual parser functions that extract metadata and peak lists from each format and construct matchms Spectrum objects.: "Implement individual parser functions that extract metadata and peak lists from each format and construct matchms Spectrum objects"
  • [other] Write unit tests using pytest to validate correct parsing and Spectrum object construction for representative samples in each format.: "Write unit tests using pytest to validate correct parsing and Spectrum object construction for representative samples in each format"
  • [other] Run pytest to ensure all parsing tests pass and existing tests remain unbroken.: "Run pytest to ensure all parsing tests pass and existing tests remain unbroken"
  • [other] Matchms supports loading mass spectrometry spectra from six file formats: mzML, mzXML, msp, metabolomics-USI, MGF, and JSON.: "Matchms supports loading mass spectrometry spectra from six file formats: mzML, mzXML, msp, metabolomics-USI, MGF, and JSON"
  • [other] make sure the existing tests still work by running pytest: "make sure the existing tests still work by running pytest"

Keep looking

Skills are one crate of 328,083. 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.