LeoYeAI/agent-master-skills / skills/13c-metabolic-flux
13c-metabolic-flux
VerifiedEstimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps, mfapy isotope simulation, constrained multistart fitting, and flux-profile diagnostics. Use for 13C-MFA, carbon tracing, mass isotopomer distributions (MDVs/MIDs), positional isotopomers, parallel tracer experiments, and determining whether labeling data constrain a pathway flux. Distinguishes measured-label inference from COBRA flux balance analysis and flags experiments requiring nonstationary MFA.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.4 KB |
| assets/branch-fluxes.json | config | 69 B |
| assets/branch-identifiable.json | config | 823 B |
| assets/branch-model.json | config | 2.1 KB |
| assets/branch-unresolved.json | config | 978 B |
| assets/mfapy-license.txt | markdown | 1.0 KB |
| assets/requirements.txt | manifest | 136 B |
| assets/tca-fluxes.json | config | 114 B |
| assets/tca-model.json | config | 4.1 KB |
| assets/tca-reference-mdv.json | config | 2.4 KB |
| assets/tca-tracer.json | config | 570 B |
| references/inference.md | markdown | 9.9 KB |
| references/input-contract.md | markdown | 8.0 KB |
| scripts/_mfa_fit.py | script | 13.3 KB |
| scripts/_mfa_model.py | script | 20.5 KB |
| scripts/mfa.py | script | 4.3 KB |
scripts/mfa.py
View on GitHub#!/usr/bin/env python3
"""Check, simulate, fit, and profile steady-state 13C metabolic flux models."""
from __future__ import annotations
import argparse
import hashlib
import importlib.metadata
import json
from pathlib import Path
import sys
sys.dont_write_bytecode = True
def main():
parser = argparse.ArgumentParser(description=__doc__)
sub = parser.add_subparsers(dest="command", required=True)
for name in ("check", "simulate", "fit"):
p = sub.add_parser(name)
p.add_argument("--model", type=Path, required=True)
p.add_argument("--data", type=Path, required=True, help="Experiment/measurement JSON")
p.add_argument("--output", type=Path, help="JSON output; defaults to stdout")
if name == "simulate":
p.add_argument("--fluxes", type=Path, required=True, help="JSON mapping of reaction IDs to fluxes")
if name == "fit":
p.add_argument("--starts", type=int, default=8)
p.add_argument("--seed", type=int, default=2026)
p.add_argument("--maxiter", type=int, default=1000)
p.add_argument("--profile", action="append", default=[], help="Reaction to profile; repeat for multiple reactions")
p.add_argument("--profile-points", type=int, default=21)
p.add_argument("--profile-starts", type=int, default=4)
p.add_argument("--confidence", type=float, default=.95)
args = parser.parse_args()
from _mfa_model import InputError, Network, Observations, read_json, require
from _mfa_fit import FluxSpace, diagnostics, fit, profile
import numpy as np
try:
inputs = [args.model, args.data]
if args.command == "simulate":
inputs.append(args.fluxes)
require(args.output is None or all(args.output.resolve() != path.resolve() for path in inputs),
"Output must not overwrite an input file")
network = Network(read_json(args.model))
observations = Observations(read_json(args.data), network)
space = FluxSpace(network)
versions = {}
for package in ("mfapy", "numpy", "scipy"):
try:
versions[package] = importlib.metadata.version(package)
except importlib.metadata.PackageNotFoundError:
versions[package] = "not installed"
result = dict(command=args.command, model=network.spec["name"], versions=versions,
input_sha256={str(path): hashlib.sha256(path.read_bytes()).hexdigest() for path in inputs})
if args.command == "check":
result.update(status="input_contract_valid", free_flux_dimensions=space.dimension,
independent_measurements=observations.size, warnings=observations.warnings,
note="Checks declared mapping consistency and feasibility, not biological correctness or isotope steady state")
elif args.command == "simulate":
vector = network.check_flux(read_json(args.fluxes))
result["predictions"] = {exp["id"]: {key: value.tolist() for key, value in network.predict(vector, exp).items()}
for exp in observations.spec["experiments"]}
else:
fitted = fit(observations, args.starts, args.seed, args.maxiter)
result.update(diagnostics(observations, fitted))
result["settings"] = dict(starts=args.starts, seed=args.seed, maxiter=args.maxiter,
profile_points=args.profile_points, profile_starts=args.profile_starts,
confidence=args.confidence)
result["profiles"] = [profile(observations, fitted, rid, args.profile_points,
args.profile_starts, args.seed, args.maxiter, args.confidence)
for rid in dict.fromkeys(args.profile)]
text = json.dumps(result, indent=2, allow_nan=False) + "\n"
if args.output:
args.output.write_text(text, encoding="utf-8")
else:
print(text, end="")
return 0
except (InputError, ValueError, TypeError, KeyError, OSError, np.linalg.LinAlgError,
FloatingPointError, ZeroDivisionError) as exc:
print(f"mfa: {exc}", file=sys.stderr)
return 2
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |