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/theoretical_spectrum.py

View on GitHub
#!/usr/bin/env python3
"""
Theoretical Fragment Spectrum Generator

Generate a theoretical fragment-ion spectrum (b/y, optionally a/c/x/z and
losses) for a peptide using TheoreticalSpectrumGenerator. Prints annotated
fragment ions and optionally writes the spectrum to mzML and/or a CSV peak list.

Usage:
    python theoretical_spectrum.py DFPIANGER
    python theoretical_spectrum.py PEPTIDEK --charge 2 --ions b y a --losses
    python theoretical_spectrum.py DFPIANGER --out-mzml theo.mzML --out-csv peaks.csv
"""

import argparse
import sys

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


def main():
    parser = argparse.ArgumentParser(description="Generate a theoretical peptide spectrum.")
    parser.add_argument("peptide", help="Amino-acid sequence (OpenMS mod syntax allowed)")
    parser.add_argument("--charge", type=int, default=1, help="Max fragment charge (default 1)")
    parser.add_argument("--ions", nargs="+", default=["b", "y"],
                        choices=["a", "b", "c", "x", "y", "z"], help="Ion series (default b y)")
    parser.add_argument("--losses", action="store_true", help="Include neutral losses")
    parser.add_argument("--precursor", action="store_true", help="Include precursor peaks")
    parser.add_argument("--out-mzml", help="Write spectrum to mzML")
    parser.add_argument("--out-csv", help="Write annotated peak list to CSV")
    args = parser.parse_args()
    if args.charge < 1:
        parser.error("--charge must be positive")

    seq = ms.AASequence.fromString(args.peptide)
    tsg = ms.TheoreticalSpectrumGenerator()
    p = tsg.getParameters()
    for ion in ["a", "b", "c", "x", "y", "z"]:
        p.setValue(f"add_{ion}_ions", "true" if ion in args.ions else "false")
    p.setValue("add_losses", "true" if args.losses else "false")
    p.setValue("add_precursor_peaks", "true" if args.precursor else "false")
    p.setValue("add_metainfo", "true")
    tsg.setParameters(p)

    spec = ms.MSSpectrum()
    spec.setMSLevel(2)
    spec.setType(ms.SpectrumSettings.SpectrumType.CENTROID)
    tsg.getSpectrum(spec, seq, 1, args.charge)
    print(f"Peptide: {seq.toString()}  ({len(spec)} fragment peaks)")

    mz, inten = spec.get_peaks()
    annotations = spec.getStringDataArrays()
    names = []
    for i in range(len(mz)):
        label = annotations[0][i] if annotations else ""
        names.append(label.decode("utf-8") if isinstance(label, bytes) else str(label))
    rows = sorted(zip(mz, inten, names), key=lambda r: r[0])
    for m, _, name in rows:
        print(f"  {name:12s} m/z {m:.4f}")

    if args.out_mzml:
        exp = ms.MSExperiment()
        exp.addSpectrum(spec)
        ms.MzMLFile().store(args.out_mzml, exp)
        print(f"Wrote {args.out_mzml}")

    if args.out_csv:
        import csv
        with open(args.out_csv, "w", newline="") as fh:
            w = csv.writer(fh)
            w.writerow(["ion", "mz", "intensity"])
            for m, it, name in rows:
                w.writerow([name, f"{m:.5f}", f"{it:.3f}"])
        print(f"Wrote {args.out_csv}")


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