agentsclimarketplace

Psm spectrum identifier regex extraction

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/psm-spectrum-identifier-regex-extraction

Use when when you have PSM identifications from a search engine (e.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill psm-spectrum-identifier-regex-extraction

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.3 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

PSM-spectrum identifier regex extraction

Summary

Extract common spectrum identifiers from PSM file spectrum_id fields and spectrum file titles using regex capture groups, then match them to link PSMs to their corresponding spectra. This is essential for MS²Rescore to correctly map peptide identifications to their experimental spectra before rescoring.

When to use

When you have PSM identifications from a search engine (e.g., MaxQuant, MSGFPlus, Mascot) and spectrum files (mzML or mgf format) that use different naming schemes or formats for their spectrum identifiers, and you need to establish a one-to-one mapping between PSMs and spectra before rescoring. Typical triggers: spectrum file titles contain scan numbers or indices in a format different from the PSM file's spectrum_id field, or both files use custom identifier patterns that must be extracted and normalized.

When NOT to use

  • PSM and spectrum identifiers already match directly by string equality without requiring regex extraction or normalization
  • Spectrum files are not available or are not in supported mzML/mgf formats
  • The PSM file has already been FDR-filtered or contains only a subset of identifications, as MS²Rescore requires all target and decoy PSMs

Inputs

  • PSM file from search engine (supported formats: MS Amanda .csv, Sage .sage.tsv, PeptideShaker .mzid, ProteomeDiscoverer .msf, MSGFPlus .mzid, Mascot .mzid, MaxQuant msms.txt, X!Tandem .xml, PEAKS .mzid)
  • Spectrum file in mzML or mgf format
  • Regex pattern for spectrum ID extraction (spectrum_id_pattern)
  • Regex pattern for PSM ID extraction (psm_id_pattern)

Outputs

  • PSM-to-spectrum mapping table (data structure linking each PSM to its matched spectrum)
  • List of unmatched PSMs (for error reporting)

How to apply

Define two regex patterns with at least one capturing group each: spectrum_id_pattern to extract identifiers from spectrum file titles (e.g., mzML spectrum IDs or MGF titles), and psm_id_pattern to extract identifiers from the PSM file's spectrum_id field. Load the PSM file and apply psm_id_pattern to each PSM's spectrum_id field, capturing the scan number or index. Load the spectrum file and apply spectrum_id_pattern to each spectrum's title or identifier field. Match the extracted identifiers using string equality to establish the PSM-to-spectrum mapping. Return a mapping table linking each PSM to its matched spectrum, and flag any unmatched PSMs for error reporting. Both regex patterns must match the entire identifier string and return the same extracted identifier for successful linking.

Related tools

  • MS²Rescore (Platform that performs PSM-spectrum mapping and rescoring; orchestrates the entire workflow including regex-based identifier linking) — https://github.com/compomics/ms2rescore
  • psm_utils (Library for parsing and manipulating PSM files from multiple search engines; provides standardized access to PSM data including spectrum_id fields) — https://github.com/compomics/psm_utils

Evaluation signals

  • All PSMs in the input file are successfully matched to exactly one spectrum (no duplicates or orphaned PSMs after mapping)
  • Unmatched PSMs are minimal and identifiable: only those with spectrum identifiers that do not exist in the spectrum file
  • The extracted identifiers from both patterns are identical in format and value for matched PSM-spectrum pairs (string equality check passes)
  • The regex patterns correctly handle edge cases such as multiple capture groups in the pattern; only the first capture group is used for matching
  • The generated mapping table contains no null or empty spectrum assignments for PSMs that should have been matched

Limitations

  • Regex patterns must be manually defined and validated for each combination of search engine output and spectrum file format; incorrect patterns result in no or partial matching
  • If PSM or spectrum files use inconsistent identifier formats (e.g., some scan numbers zero-padded, others not), the regex patterns must account for this normalization or matching will fail
  • Search engines that do not report spectrum identifiers in their output files, or spectrum files with corrupted or missing identifier fields, will produce unmatched PSMs
  • The mapping requires exact string equality after regex extraction; if spectrum identifiers are present but in a format not captured by the pattern, PSMs will be orphaned

Evidence

  • [other] MS²Rescore uses two regex patterns with single capture groups—spectrum_id_pattern to extract identifiers from spectrum file titles and psm_id_pattern to extract identifiers from PSM file spectrum_id fields—that must match the entire string and return the same identifier to link PSMs to spectra.: "MS²Rescore uses two regex patterns with single capture groups—spectrum_id_pattern to extract identifiers from spectrum file titles and psm_id_pattern to extract identifiers from PSM file"
  • [intro] Essential for MS²Rescore to function correctly is linking the search engine PSMs to the original spectra...two options are available to map PSMs to spectra: spectrum_id_pattern and: "Essential for MS²Rescore to function correctly is linking the search engine PSMs to the original spectra"
  • [intro] Both mzML and mgf formats are supported: "Both mzML and mgf formats are supported"
  • [other] 1. Load PSM file and extract spectrum identifiers using the psm_id_pattern regex with at least one capturing group to isolate the scan number or index. 2. Load spectrum file (mzML or MGF format) and extract spectrum identifiers from spectrum titles using the spectrum_id_pattern regex with at least one capturing group. 3. Match extracted PSM identifiers to spectrum identifiers using string equality to establish the PSM-to-spectrum mapping.: "Load PSM file and extract spectrum identifiers using the psm_id_pattern regex with at least one capturing group to isolate the scan number or index"
  • [intro] MS²Rescore always needs access to all target and decoy PSMs, without any FDR-filtering: "MS²Rescore always needs access to all target and decoy PSMs, without any FDR-filtering"

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.