Skip to content

K-Dense-AI/scientific-agent-skills / skills/pyopenms

pyopenms

Verified

Processes mass spectrometry data with pyOpenMS. Supports proteomics and metabolomics workflows—feature detection, peptide/protein identification, label-free quantification, adduct/accurate-mass annotation, and complex LC-MS/MS pipelines. Supports extensive file formats and algorithms. For simple spectral comparison and small-molecule library matching use matchms.

scripts/convert_format.py

View on GitHub
#!/usr/bin/env python3
"""
Convert Between MS File Formats

Convert spectral data between mzML, mzXML, and MGF, with optional MS-level and
RT/intensity filtering. Uses FileHandler for transparent format detection on load.

Supported conversions (by output extension): .mzML, .mzXML, .mgf

Usage:
    python convert_format.py input.mzXML output.mzML
    python convert_format.py input.mzML peaks.mgf --ms-level 2
    python convert_format.py input.mzML out.mzML --rt-min 60 --rt-max 600 --min-intensity 500
"""

import argparse
import os
import sys

try:
    import pyopenms as ms
except ImportError:
    print("Error: pyopenms not installed. Install with: uv pip install pyopenms")
    sys.exit(1)


def load_experiment(path):
    exp = ms.MSExperiment()
    ms.FileHandler().loadExperiment(path, exp)
    return exp


def filter_experiment(exp, ms_level=None, rt_min=None, rt_max=None, min_intensity=None):
    out = ms.MSExperiment(exp)
    selected = []
    for spec in exp:
        if ms_level is not None and spec.getMSLevel() != ms_level:
            continue
        rt = spec.getRT()
        if rt_min is not None and rt < rt_min:
            continue
        if rt_max is not None and rt > rt_max:
            continue
        if min_intensity is not None:
            mz, inten = spec.get_peaks()
            keep = inten >= min_intensity
            spec.select(keep.nonzero()[0].tolist())
        selected.append(spec)
    out.setSpectra(selected)
    # These are spectrum filters; chromatograms remain unchanged unless an MS
    # level is selected, in which case they are omitted.
    if ms_level is not None:
        out.setChromatograms([])
    return out


def store_experiment(exp, path):
    ext = path.lower()
    if ext.endswith(".mzml"):
        ms.MzMLFile().store(path, exp)
    elif ext.endswith(".mzxml"):
        ms.MzXMLFile().store(path, exp)
    elif ext.endswith(".mgf"):
        ms.MascotGenericFile().store(path, exp)
    else:
        raise ValueError(f"Unsupported output extension: {path} (use .mzML, .mzXML, or .mgf)")


def main():
    parser = argparse.ArgumentParser(description="Convert/filter MS files between formats.")
    parser.add_argument("input", help="Input file (mzML/mzXML/...)")
    parser.add_argument("output", help="Output file (.mzML, .mzXML, or .mgf)")
    parser.add_argument("--ms-level", type=int, help="Keep only spectra at this MS level")
    parser.add_argument("--rt-min", type=float, help="Minimum retention time (s)")
    parser.add_argument("--rt-max", type=float, help="Maximum retention time (s)")
    parser.add_argument("--min-intensity", type=float, help="Drop peaks below this intensity")
    args = parser.parse_args()

    if not os.path.exists(args.input):
        print(f"Error: file not found: {args.input}")
        sys.exit(1)

    print(f"Loading {args.input}...")
    exp = load_experiment(args.input)
    print(f"  {exp.getNrSpectra()} spectra, {exp.getNrChromatograms()} chromatograms")

    if any(v is not None for v in (args.ms_level, args.rt_min, args.rt_max, args.min_intensity)):
        exp = filter_experiment(exp, args.ms_level, args.rt_min, args.rt_max, args.min_intensity)
        print(f"  after filtering: {exp.getNrSpectra()} spectra")

    print(f"Writing {args.output}...")
    store_experiment(exp, args.output)
    print("Done.")


if __name__ == "__main__":
    main()
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall