Msp file parsing
Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/gc-ms/skills/msp-file-parsing
Use when you have a Mass Spectrum Point (MSP) file containing electron ionization mass spectral records with header fields and peak intensity pairs, and you need to load it into an R data structure for library searching, format validation, or round-trip conversion.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill msp-file-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
6.1 KB, 898 tokens by cl100k_base, as published. Nobody here has run it
msp-file-parsing
Summary
Parse and validate electron ionization mass spectral library files in MSP format, extracting spectral records with their metadata annotations, peak lists, and precursor m/z values for downstream library search or format conversion workflows. This skill is essential for enabling reproducible mass spectral database operations in R environments.
When to use
You have a Mass Spectrum Point (MSP) file containing electron ionization mass spectral records with header fields and peak intensity pairs, and you need to load it into an R data structure for library searching, format validation, or round-trip conversion. Apply this skill when input is an MSP-formatted spectral library file and your goal is to extract individual spectrum objects with their associated metadata for programmatic access.
When NOT to use
- Input is already a parsed spectrum object or R data structure in memory — parsing is unnecessary.
- Input file format is not MSP (e.g., JSON, NetCDF, mzML) — use format-specific parsers instead.
- Spectral library is only needed for metadata lookup without full record extraction — a lightweight indexing strategy may be more efficient.
Inputs
- MSP spectral library file (text format with header fields and peak intensity pairs)
- Spectral metadata annotations (compound identifiers, chemical names, CAS numbers)
Outputs
- In-memory R data structure (list or data frame) of parsed spectrum objects
- Extracted spectral fields (precursor m/z, peak m/z and intensity pairs, metadata)
- Validated MSP output file (optionally written for verification)
How to apply
Use the mssearchr package's MSP parser to load the spectral library file into an in-memory R data structure (list or data frame of spectrum objects). Extract and validate key spectral fields from each record, including precursor m/z, peak lists (m/z and intensity pairs), and metadata annotations such as compound name and CAS number. Ensure compliance with MSP specification conventions for header field formatting, peak list delimiters, and record boundaries. For quality assurance, verify the parsed output by writing the spectrum objects back to a new MSP file using mssearchr's MSP writer, then read the output file and compare parsed fields against the original input records to confirm lossless round-trip conversion.
Related tools
- mssearchr (Provides MSP file parsing and writing functionality, as well as spectral field extraction and format validation) — https://github.com/AndreySamokhin/mssearchr
- R (Host environment for executing mssearchr MSP parsing and data structure operations)
Evaluation signals
- Round-trip validation: Parsed spectrum objects written back to MSP and re-parsed yield identical spectral fields (m/z, intensities, metadata) as the original records.
- Schema compliance: All required header fields (precursor m/z, compound name) are extracted and non-null for each spectrum object.
- Field consistency: Extracted peak m/z and intensity pairs match the original file format and preserve numeric precision.
- Record count: Number of parsed spectrum objects equals the number of spectral records in the input MSP file.
- Delimiter detection: Peak list format and field separators conform to MSP specification (e.g., tab or space delimiters, correct line break handling).
Limitations
- MSP parser assumes well-formed input files adhering to MSP specification; malformed records or non-standard field names may be silently skipped or cause parsing errors.
- Large MSP files may consume significant memory when loaded entirely into R data structures; streaming or chunked parsing strategies are not mentioned in the article.
- Metadata field support depends on MSP file structure; optional or user-defined annotation fields may not be reliably extracted without schema specification.
Evidence
- [readme] Parse and validate MSP spectral library files into R data structures: "reading/writing msp files"
- [other] Extract precursor m/z, peaks, and metadata annotations from each MSP record: "Extract and validate key spectral fields from each record (precursor m/z, peaks, metadata annotations)"
- [other] Ensure MSP format compliance via round-trip conversion: "Write the parsed spectra back to a new MSP file using mssearchr's MSP writer, ensuring format compliance with MSP specification (header fields, peak list format, delimiter conventions)"
- [other] Verify parsing correctness by comparing input and output records: "Verify output file structure by reading it back and comparing parsed fields to the original input records"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.