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/detect_adducts.py
View on GitHub#!/usr/bin/env python3
"""
Adduct Detection / Feature Decharging
Group features that are different ionization forms (adducts/charge variants) of
the same neutral compound using MetaboliteFeatureDeconvolution. Annotates each
feature with its inferred adduct and neutral mass, and writes the decharged
feature map plus a consensus map of grouped adduct families.
Adducts use OpenMS deconvolution syntax 'Elements:Charge:Probability', where
the charge is given as '+'/'-' signs (e.g. 'Ca:++:0.5' is +2) and losses are
written like 'H-2O-1'. Example: 'H:+:0.4'. This differs from the bracket
notation (e.g. [M+H]+) used elsewhere.
Usage:
python detect_adducts.py features.featureXML --out-features decharged.featureXML
python detect_adducts.py features.featureXML --negative
python detect_adducts.py features.featureXML --adducts "H:+:0.6,Na:+:0.2,K:+:0.2"
"""
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)
# 'Elements:Charge:Probability' (OpenMS deconvolution syntax)
DEFAULT_POS = "H:+:0.4,Na:+:0.25,NH4:+:0.25,K:+:0.1,H-2O-1:0:0.05"
DEFAULT_NEG = "H-1:-:0.6,Cl:-:0.2,H-3O-1:-:0.1,CH2O2H-1:-:0.1"
def main():
parser = argparse.ArgumentParser(description="Detect adducts / decharge a feature map.")
parser.add_argument("input", help="Input featureXML")
parser.add_argument("--out-features", help="Output decharged featureXML (default: <input>_decharged.featureXML)")
parser.add_argument("--out-consensus", help="Optional consensusXML of adduct groups")
parser.add_argument("--negative", action="store_true", help="Negative ionization mode")
parser.add_argument("--adducts", help="Comma-separated potential adducts (overrides defaults)")
parser.add_argument("--charge-min", type=int, default=1, help="Minimum charge magnitude (positive integer)")
parser.add_argument("--charge-max", type=int, default=1, help="Maximum charge magnitude (positive integer)")
parser.add_argument("--mass-max-diff", type=float, default=0.05, help="Max mass difference (Da)")
parser.add_argument("--rt-max-diff", type=float, default=10.0, help="Max RT difference (s)")
args = parser.parse_args()
if not 1 <= args.charge_min <= args.charge_max:
parser.error("charge magnitudes must satisfy 1 <= min <= max")
if not os.path.exists(args.input):
print(f"Error: file not found: {args.input}")
sys.exit(1)
fm = ms.FeatureMap()
ms.FeatureXMLFile().load(args.input, fm)
print(f"Loaded {fm.size()} features")
adducts = args.adducts
if adducts is None:
adducts = DEFAULT_NEG if args.negative else DEFAULT_POS
mfd = ms.MetaboliteFeatureDeconvolution()
p = mfd.getDefaults()
p.setValue("potential_adducts", [a.strip().encode() for a in adducts.split(",")])
p.setValue("charge_min", -args.charge_max if args.negative else args.charge_min)
p.setValue("charge_max", -args.charge_min if args.negative else args.charge_max)
p.setValue("mass_max_diff", args.mass_max_diff)
p.setValue("retention_max_diff", args.rt_max_diff)
p.setValue("negative_mode", "true" if args.negative else "false")
mfd.setParameters(p)
fm_out = ms.FeatureMap()
groups = ms.ConsensusMap()
edges = ms.ConsensusMap()
mfd.compute(fm, fm_out, groups, edges)
annotated = sum(1 for f in fm_out if f.metaValueExists("dc_charge_adducts"))
print(f"Decharged feature map: {fm_out.size()} features ({annotated} adduct-annotated)")
print(f"Adduct groups: {groups.size()}")
out_features = args.out_features or os.path.splitext(args.input)[0] + "_decharged.featureXML"
ms.FeatureXMLFile().store(out_features, fm_out)
print(f"Wrote {out_features}")
if args.out_consensus:
ms.ConsensusXMLFile().store(args.out_consensus, groups)
print(f"Wrote {args.out_consensus}")
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 |