K-Dense-AI/scientific-agent-skills / skills/pyopenms
pyopenms
VerifiedProcesses 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.2 KB |
| references/data_structures.md | markdown | 5.3 KB |
| references/feature_detection.md | markdown | 5.9 KB |
| references/file_io.md | markdown | 3.9 KB |
| references/identification.md | markdown | 5.4 KB |
| references/metabolomics.md | markdown | 6.0 KB |
| references/signal_processing.md | markdown | 5.7 KB |
| scripts/_common.py | script | 1.0 KB |
| scripts/accurate_mass_search.py | script | 3.7 KB |
| scripts/align_link_quantify.py | script | 5.9 KB |
| scripts/consensus_to_matrix.py | script | 2.7 KB |
| scripts/convert_format.py | script | 3.3 KB |
| scripts/detect_adducts.py | script | 3.9 KB |
| scripts/detect_features_centroided.py | script | 3.3 KB |
| scripts/detect_features_metabo.py | script | 4.3 KB |
| scripts/digest_protein.py | script | 3.6 KB |
| scripts/export_gnps_sirius.py | script | 4.2 KB |
| scripts/extract_chromatograms.py | script | 3.9 KB |
| scripts/inspect_ms_data.py | script | 5.8 KB |
| scripts/mass_calculator.py | script | 3.5 KB |
| scripts/plot_ms_data.py | script | 3.9 KB |
| scripts/process_identifications.py | script | 6.4 KB |
| scripts/process_spectra.py | script | 4.8 KB |
| scripts/theoretical_spectrum.py | script | 3.1 KB |
scripts/accurate_mass_search.py
View on GitHub#!/usr/bin/env python3
"""
Accurate Mass Search (Metabolite Annotation)
Annotate detected features with putative metabolite identities by matching
accurate masses against the bundled HMDB databases using AccurateMassSearchEngine.
Outputs an annotated mzTab and a flat CSV of hits. By default uses the HMDB
mapping/structure files shipped with pyOpenMS.
Usage:
python accurate_mass_search.py features.featureXML --out-mztab hits.mzTab
python accurate_mass_search.py features.featureXML --negative --ppm 5 --csv hits.csv
"""
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 main():
parser = argparse.ArgumentParser(description="Accurate-mass metabolite annotation.")
parser.add_argument("input", help="Input featureXML (or consensusXML)")
parser.add_argument("--out-mztab", help="Output mzTab file")
parser.add_argument("--csv", help="Output CSV of annotation hits")
parser.add_argument("--negative", action="store_true", help="Negative ionization mode")
parser.add_argument("--ppm", type=float, default=5.0, help="Mass error tolerance in ppm (default 5)")
parser.add_argument("--db-mapping", help="Custom HMDB mapping TSV (default: bundled)")
parser.add_argument("--db-struct", help="Custom HMDB structure TSV (default: bundled)")
args = parser.parse_args()
if not os.path.exists(args.input):
print(f"Error: file not found: {args.input}")
sys.exit(1)
is_consensus = args.input.lower().endswith(".consensusxml")
if is_consensus:
fmap = ms.ConsensusMap()
ms.ConsensusXMLFile().load(args.input, fmap)
else:
fmap = ms.FeatureMap()
ms.FeatureXMLFile().load(args.input, fmap)
print(f"Loaded {fmap.size()} features")
if args.ppm <= 0:
parser.error("--ppm must be positive")
for supplied in (args.db_mapping, args.db_struct):
if supplied and not os.path.isfile(supplied):
parser.error(f"database file not found: {supplied}")
engine = ms.AccurateMassSearchEngine()
p = engine.getDefaults()
p.setValue("mass_error_value", args.ppm)
p.setValue("mass_error_unit", "ppm")
p.setValue("ionization_mode", "negative" if args.negative else "positive")
if args.db_mapping:
p.setValue("db:mapping", [os.path.abspath(args.db_mapping)])
if args.db_struct:
p.setValue("db:struct", [os.path.abspath(args.db_struct)])
engine.setParameters(p)
engine.init()
mztab = ms.MzTab()
if is_consensus:
engine.run(fmap, mztab)
else:
engine.run(fmap, mztab)
out_mztab = args.out_mztab or os.path.splitext(args.input)[0] + ".mzTab"
ms.MzTabFile().store(out_mztab, mztab)
print(f"Wrote {out_mztab}")
if args.csv:
# mzTab small-molecule section -> CSV via pandas
import pandas as pd
try:
sm = mztab.getSmallMoleculeSectionRows()
print(f"Small-molecule annotation rows: {len(sm)}")
except Exception:
pass
# Re-read the mzTab text for a robust flat dump of the SML table
rows = []
with open(out_mztab) as fh:
header = None
for line in fh:
if line.startswith("SMH"):
header = line.rstrip("\n").split("\t")
elif line.startswith("SML") and header:
rows.append(dict(zip(header, line.rstrip("\n").split("\t"))))
if rows:
pd.DataFrame(rows).to_csv(args.csv, index=False)
print(f"Wrote {args.csv} ({len(rows)} annotation rows)")
else:
print("No small-molecule annotations to write.")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |