Agent skill

Cobrapy

by aipoch in aipoch/medical-research-skills

Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from…

MITAuto-check passedData & Analytics

Install Cobrapy

skills CLI
$ npx skills add aipoch/medical-research-skills --skill cobrapy -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install aipoch/medical-research-skills cobrapy --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/aipoch/medical-research-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/'scientific-skills/Data Analysis/cobrapy' .claude/skills/cobrapy && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cobrapy
GitHub stars
2k
Token cost
~3k tokens
SKILL.md length
1,202 words
Files
4 (incl. references)
Skills in repo
567
Repo updated
First seen
Licence
MIT

At a glance

Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from…

  • Works in 5 steps: When to Use → Key Features → Dependencies → …
  • You need to simulate growth/production
  • SKILL.md covers When to Use, Key Features, Dependencies and Example Usage, plus 16 more sections
  • Calls python

What it does

Cobrapy is an agent skill from aipoch/medical-research-skills. Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from SBML/JSON/YAML models.

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `cobrapy_audit_result_v2.json`, `references/api_quick_reference.md` and `references/workflows.md`).

It sits in Data & Analytics. The repository describes itself as: Hundreds of agent skills for medical research, including protocol design, data analysis, evidence insights, and academic writing. The licence is MIT.

When your agent uses it

  • You need to simulate growth/production
  • Analyze flux ranges
  • Run knockout and medium studies from SBML/JSON/YAML models

Example prompts

  • “/cobrapy”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. When to Use
  2. Key Features
  3. Dependencies
  4. Example Usage
  5. Implementation Details

What it can do on your machine

Read from SKILL.md and the folder at commit 686e09d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cobrapy loads about 3k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 54 tokens; SKILL.md has 1,202 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from aipoch/medical-research-skills at commit 686e09d, republished under its MIT licence (© aipoch). 1,202 words, ~3,008 tokens.

Download SKILL.mdSave it as .claude/skills/cobrapy/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
cobrapy
description
Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from SBML/JSON/YAML models.
license
MIT
author
AIPOCH

Source: https://github.com/aipoch/medical-research-skills

COBRApy (COBRA: Constraint-Based Reconstruction and Analysis)

When to Use

  • Use this skill when the request matches its documented task boundary.
  • Use it when the user can provide the required inputs and expects a structured deliverable.
  • Prefer this skill for repeatable, checklist-driven execution rather than open-ended brainstorming.

Key Features

  • Scope-focused workflow aligned to: Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from SBML/JSON/YAML models.
  • Documentation-first workflow with no packaged script requirement.
  • Reference material available in references/ for task-specific guidance.
  • Structured execution path designed to keep outputs consistent and reviewable.

Dependencies

  • Python: 3.10+. Repository baseline for current packaged skills.
  • Third-party packages: not explicitly version-pinned in this skill package. Add pinned versions if this skill needs stricter environment control.

Example Usage

text
Skill directory: 20260316/scientific-skills/Data Analytics/cobrapy
No packaged executable script was detected.
Use the documented workflow in SKILL.md together with the references/assets in this folder.

Example run plan:

  1. Read the skill instructions and collect the required inputs.
  2. Follow the documented workflow exactly.
  3. Use packaged references/assets from this folder when the task needs templates or rules.
  4. Return a structured result tied to the requested deliverable.

Implementation Details

  • Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.
  • Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.
  • Primary implementation surface: instruction-only workflow in SKILL.md.
  • Reference guidance: references/ contains supporting rules, prompts, or checklists.
  • Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.
  • Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.

1. When to Use

Use this skill when you need to perform constraint-based analysis on metabolic networks, especially for:

  1. Predicting growth or production under specific media and objectives using Flux Balance Analysis (FBA).
  2. Quantifying flux uncertainty and alternative optima using Flux Variability Analysis (FVA) and flux sampling.
  3. Identifying essential genes/reactions via single/double knockout (deletion) studies.
  4. Designing or optimizing media (e.g., minimal medium) to support a target growth rate.
  5. Repairing infeasible models by gapfilling against a universal reaction database/model.

2. Key Features

  • Model I/O and management: load/save models in SBML (preferred), JSON, and YAML; access reactions/metabolites/genes.
  • FBA variants: standard FBA, parsimonious FBA (pFBA), geometric FBA.
  • FVA: compute min/max feasible fluxes; supports fraction-of-optimum and loopless FVA.
  • Knockout analysis: single/double gene and reaction deletions; temporary edits via context managers.
  • Medium handling: inspect and modify model.medium; compute minimal media (optionally MILP-based).
  • Flux sampling: sample feasible flux space (OptGP/ACHR) and validate samples.
  • Production envelopes: phenotypic phase planes / production envelopes for trade-off exploration.
  • Gapfilling: propose reaction additions to restore feasibility.
  • Model construction: build models from scratch (metabolites, reactions, GPR rules, boundaries, objectives).

3. Dependencies

  • cobra (COBRApy) — version varies by environment (commonly >=0.20)
  • A supported LP/MILP solver (one of):
    • glpk / swiglpk (often default)
    • cplex (optional)
    • gurobi (optional)
  • Optional (for plotting/analysis in examples):
    • pandas
    • matplotlib

4. Example Usage

The following script is a complete, runnable example that loads a built-in model, runs FBA, performs FVA, runs a gene knockout, adjusts medium, and samples fluxes.

python

# cobrapy_example.py
from cobra.io import load_model
from cobra.flux_analysis import flux_variability_analysis, single_gene_deletion, pfba
from cobra.sampling import sample

def main():
    # 1) Load a model (built-in test model)
    model = load_model("textbook")  # E. coli core model

    # 2) Run standard FBA
    sol = model.optimize()
    print("=== FBA ===")
    print("Status:", sol.status)
    print("Objective (growth):", sol.objective_value)

    # 3) Run pFBA (minimize total flux at optimal growth)
    pfba_sol = pfba(model)
    print("\n=== pFBA ===")
    print("Objective (growth):", pfba_sol.objective_value)

    # 4) Flux Variability Analysis at 90% of optimum
    print("\n=== FVA (90% optimum) ===")
    fva = flux_variability_analysis(model, fraction_of_optimum=0.9)
    print(fva.head())

    # 5) Single gene deletion screen (may take time on large models)
    print("\n=== Single Gene Deletion (first 5 rows) ===")
    del_res = single_gene_deletion(model)
    print(del_res.head())

    # 6) Medium modification (must re-assign the full dict)
    print("\n=== Medium ===")
    medium = model.medium
    # Example: limit glucose uptake (exchange IDs depend on the model)
    if "EX_glc__D_e" in medium:
        medium["EX_glc__D_e"] = 5.0
        model.medium = medium
        sol2 = model.optimize()
        print("Growth after limiting glucose:", sol2.objective_value)
    else:
        print("Model has no EX_glc__D_e in medium; skipping medium edit.")

    # 7) Flux sampling (small n for quick demo)
    print("\n=== Flux Sampling ===")
    samples = sample(model, n=200, method="optgp")
    print(samples.head())

if __name__ == "__main__":
    main()

Run:

bash
python cobrapy_example.py

5. Implementation Details

5.1 Core optimization model (FBA)
  • COBRApy formulates a linear program (LP):
    • Mass balance (steady state): ( S \cdot v = 0 )
    • Bounds: ( l \le v \le u )
    • Objective: maximize (or minimize) a linear function ( c^\top v ) (e.g., biomass reaction flux)
  • model.optimize() solves the LP and returns a Solution with:
    • solution.status (e.g., optimal)
    • solution.objective_value
    • solution.fluxes (pandas Series of reaction fluxes)
5.2 Reaction directionality and bounds
  • Irreversible reactions typically use lower_bound = 0.
  • Reversible reactions allow negative flux: lower_bound < 0.
  • Use reaction.bounds = (lb, ub) to set both consistently.
5.3 Gene-Protein-Reaction (GPR) rules
  • reaction.gene_reaction_rule encodes Boolean logic:
    • "gene1 and gene2" means both genes required.
    • "gene1 or gene2" means either gene sufficient.
  • Knockouts propagate through GPR logic to constrain affected reactions.
5.4 FVA parameters
  • flux_variability_analysis(model, fraction_of_optimum=x) constrains the objective to be at least x * optimum before computing per-reaction min/max.
  • loopless=True attempts to remove thermodynamically infeasible loops (typically more expensive).
5.5 Context manager for temporary edits
  • with model: creates a reversible sandbox:
    • changes to objectives, bounds, knockouts, and reaction sets revert automatically on exit.
  • This prevents accidental state carryover across analyses.
5.6 Flux sampling
  • Sampling explores the feasible polytope defined by constraints.
  • sample(..., method="optgp") uses OptGP (often parallelizable); method="achr" uses ACHR.
  • For numerical stability, validate samples when needed (e.g., via OptGPSampler.validate).
5.7 Medium handling
  • model.medium is a dictionary mapping exchange reaction IDs to allowed uptake rates.
  • You must re-assign the full dictionary after edits: model.medium = medium.
Show full SKILL.md (473 more words)Show less
5.8 Gapfilling
  • gapfill(model, universal) searches for a minimal set of reactions from universal that restores feasibility (commonly formulated as MILP/optimization with penalties).
  • Use with model: when testing removals/additions to avoid permanently mutating the model.

When Not to Use

  • Do not use this skill when the required source data, identifiers, files, or credentials are missing.
  • Do not use this skill when the user asks for fabricated results, unsupported claims, or out-of-scope conclusions.
  • Do not use this skill when a simpler direct answer is more appropriate than the documented workflow.

Required Inputs

  • A clearly specified task goal aligned with the documented scope.
  • All required files, identifiers, parameters, or environment variables before execution.
  • Any domain constraints, formatting requirements, and expected output destination if applicable.
  1. Validate the request against the skill boundary and confirm all required inputs are present.
  2. Select the documented execution path and prefer the simplest supported command or procedure.
  3. Produce the expected output using the documented file format, schema, or narrative structure.
  4. Run a final validation pass for completeness, consistency, and safety before returning the result.

Deterministic Output Rules

  • Use the same section order for every supported request of this skill.
  • Keep output field names stable and do not rename documented keys across examples.
  • If a value is unavailable, emit an explicit placeholder instead of omitting the field.

Output Contract

  • Return a structured deliverable that is directly usable without reformatting.
  • If a file is produced, prefer a deterministic output name such as cobrapy_result.md unless the skill documentation defines a better convention.
  • Include a short validation summary describing what was checked, what assumptions were made, and any remaining limitations.

Validation and Safety Rules

  • Validate required inputs before execution and stop early when mandatory fields or files are missing.
  • Do not fabricate measurements, references, findings, or conclusions that are not supported by the provided source material.
  • Emit a clear warning when credentials, privacy constraints, safety boundaries, or unsupported requests affect the result.
  • Keep the output safe, reproducible, and within the documented scope at all times.

Failure Handling

  • If validation fails, explain the exact missing field, file, or parameter and show the minimum fix required.
  • If an external dependency or script fails, surface the command path, likely cause, and the next recovery step.
  • If partial output is returned, label it clearly and identify which checks could not be completed.

Completion Checklist

  • Confirm all required inputs were present and valid.
  • Confirm the supported execution path completed without unresolved errors.
  • Confirm the final deliverable matches the documented format exactly.
  • Confirm assumptions, limitations, and warnings are surfaced explicitly.

Quick Validation

Run this minimal verification path before full execution when possible:

text
No local script validation step is required for this skill.

Expected output format:

text
Result file: cobrapy_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any

Scope Reminder

  • Core purpose: Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from SBML/JSON/YAML models.

© aipoch, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in scientific-skills/Data Analysis/cobrapy of aipoch/medical-research-skills.

  • SKILL.md
  • cobrapy_audit_result_v2.json
  • references/api_quick_reference.md
  • references/workflows.md

Open the folder on GitHubat commit 686e09d

Compare with similar skills

Cobrapy next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cobrapy compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cobrapy this skillaipoch/medical-research-skills2k—~3kAutomated safety check: PassMIT
Exploratory Data Analysisspacering-net/codeg3.8k15 repos~3.6kAutomated safety check: PassMIT
MatplotlibzLanqing/codex-claude-academic-skills4.6k18 repos~2.9kAutomated safety check: PassMIT
Scikit LearnzLanqing/codex-claude-academic-skills4.6k17 repos~3.9kAutomated safety check: PassBSD-3-Clause
Chart Visualizationbytedance/deer-flow83k2 repos~840Automated safety check: PassMIT
TimesFM Forecastinggoogle-research/timesfm34k—~4.7kAutomated safety check: PassApache-2.0

Similar skills

  • Exploratory Data Analysis

    spacering-net/codeg

    Perform comprehensive exploratory data analysis on scientific data files across 200+ file formats.

    3.8k GitHub starsUsed in 15 repos~3.6k tokens
    Data & AnalyticsAuto-check passed
  • Matplotlib

    zLanqing/codex-claude-academic-skills

    Low-level plotting library for full customization. An agent skill from zLanqing/codex-claude-academic-skills.

    4.6k GitHub starsUsed in 18 repos~2.9k tokens
    Data & AnalyticsAuto-check passed
  • Scikit Learn

    zLanqing/codex-claude-academic-skills

    Machine learning in Python with scikit-learn. An agent skill from zLanqing/codex-claude-academic-skills.

    4.6k GitHub starsUsed in 17 repos~3.9k tokens
    Data & AnalyticsAuto-check passed
  • Chart Visualization

    bytedance/deer-flow

    Picks a suitable chart type from 26 options for your data, maps the data to that chart's parameters and generates a chart image through a JavaScript script.

    83k GitHub starsUsed in 2 repos~840 tokens
    Data & AnalyticsAuto-check passed
  • TimesFM Forecasting

    google-research/timesfm

    Forecasts any univariate time series zero-shot with Google's TimesFM model, returning point forecasts and calibrated prediction intervals without training.

    34k GitHub stars~4.7k tokensUpdated 9 days ago
    Data & AnalyticsAuto-check passed
  • Sandbox Bench

    vercel/next.js

    Official

    Benchmark React or Next.js changes on Vercel Sandbox VMs with paired A/B statistics: react PR/commit vs base, or Next.js PR/commit vs base, measured end-to-end through the bench/render-pipeline app…

    143k GitHub stars~4.1k tokensUpdated today
    Data & AnalyticsAuto-check passed

More from aipoch/medical-research-skills

All 567 skills in this repo
  • Academic Poster Generator

    aipoch/medical-research-skills

    Complete workflow for generating academic research posters from PDF literature; use when you need to extract paper content from PDFs and produce a LaTeX-based poster…

    2k GitHub stars~2.2k tokensUpdated 21 days ago
    Auto-check passed
  • Diagnostic Study Quality Assessment Quadas

    aipoch/medical-research-skills

    Analyzes clinical diagnostic accuracy studies for bias using the QUADAS-2 tool.

    2k GitHub stars~1.4k tokensUpdated 21 days ago
    Auto-check passed
  • Exploratory Data Analysis

    aipoch/medical-research-skills

    Perform comprehensive exploratory data analysis on scientific data files across 200+ file formats.

    2k GitHub stars~3.7k tokensUpdated 21 days ago
    Auto-check passed
  • Iso Certification

    aipoch/medical-research-skills

    A toolkit for preparing ISO 13485:2016 certification documentation for medical device QMS.

    2k GitHub stars~1.8k tokensUpdated 21 days ago
    Auto-check passed
  • Journal Skills

    aipoch/medical-research-skills

    Recommends target journals for manuscript submission by analyzing the paper topic/abstract and the journal distribution of similar PubMed literature; use when users ask for journal…

    2k GitHub stars~1.7k tokensUpdated 21 days ago
    Auto-check passed
  • Latex Posters

    aipoch/medical-research-skills

    Creates academic-poster writing packages for LaTeX using beamerposter, tikzposter, or baposter.

    2k GitHub stars~1.3k tokensUpdated 21 days ago
    Auto-check passed

Questions about Cobrapy

What does Cobrapy do?

Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from…. Cobrapy is an agent skill from aipoch/medical-research-skills. Constraint-based reconstruction and analysis (COBRA) for metabolic models; use when you need to simulate growth/production, analyze flux ranges, or run knockout and medium studies from SBML/JSON/YAML models.

When should I use Cobrapy?

Cobrapy fits situations like: you need to simulate growth/production; analyze flux ranges; run knockout and medium studies from SBML/JSON/YAML models.

How do I install Cobrapy in Claude Code?

Run `npx skills add aipoch/medical-research-skills --skill cobrapy -a claude-code`. Or copy the skill folder (scientific-skills/Data Analysis/cobrapy in aipoch/medical-research-skills) into .claude/skills/cobrapy in your project. Claude Code loads it when a task matches its description.

How do I install Cobrapy in Codex?

Run `npx skills add aipoch/medical-research-skills --skill cobrapy -a codex`. Or copy the skill folder (scientific-skills/Data Analysis/cobrapy in aipoch/medical-research-skills) into .agents/skills/cobrapy in your project. Codex loads it when a task matches its description.

Can I use Cobrapy in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add aipoch/medical-research-skills --skill cobrapy -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cobrapy, .gemini/skills/cobrapy, .github/skills/cobrapy and .opencode/skills/cobrapy in your project.

What does Cobrapy need to run?

Going by SKILL.md and its folder, Cobrapy needs the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Cobrapy access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cobrapy safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cobrapy use?

Cobrapy is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cobrapy use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 9.9k tokens, read only when the agent opens those files.

What are the alternatives to Cobrapy?

Skills that share tags, products or a category with Cobrapy: Exploratory Data Analysis (spacering-net/codeg, 3.8k stars), Matplotlib (zLanqing/codex-claude-academic-skills, 4.6k stars), Scikit Learn (zLanqing/codex-claude-academic-skills, 4.6k stars) and Chart Visualization (bytedance/deer-flow, 83k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cobrapy?

aipoch (a GitHub organization) maintains it in aipoch/medical-research-skills, which has 1,974 GitHub stars. The repository holds 567 skills in this directory. The repository was last updated on September 17, 2026.

Source: aipoch/medical-research-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.