Matchms count spectra

From XuShuwenn/RedAct · View interactive version

Matchms count spectra is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Parse MSP mass spectrometry files using matchms library to count spectra and find spectrum with most peaks.

How to use this skill

Skill file

Mass Spectrometry Peak Counting

When to Use

Input

Output

To /root/output.txt:

Total spectra: N
Spectrum with most peaks: NAME (K peaks)
Total peaks across all spectra: M

Using matchms

from matchms.importing import load_msp_file
spectra = load_msp_file("input.msp")

Calculations

  1. Count total spectra in file
  2. For each spectrum, count peaks (len(spectrum.peaks))
  3. Find spectrum with most peaks
  4. Sum all peaks across all spectra

Edge Cases

If file is empty/unparseable:

Total spectra: 0
Spectrum with most peaks: N/A (0 peaks)
Total peaks across all spectra: 0

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.