scientific-skills/Data Analysis/cobrapy/SKILL.md
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.
npx skillsauth add aipoch/medical-research-skills cobrapyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
references/ for task-specific guidance.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.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:
SKILL.md.references/ contains supporting rules, prompts, or checklists.Use this skill when you need to perform constraint-based analysis on metabolic networks, especially for:
model.medium; compute minimal media (optionally MILP-based).cobra (COBRApy) — version varies by environment (commonly >=0.20)glpk / swiglpk (often default)cplex (optional)gurobi (optional)pandasmatplotlibThe 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.
# 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:
python cobrapy_example.py
model.optimize() solves the LP and returns a Solution with:
solution.status (e.g., optimal)solution.objective_valuesolution.fluxes (pandas Series of reaction fluxes)lower_bound = 0.lower_bound < 0.reaction.bounds = (lb, ub) to set both consistently.reaction.gene_reaction_rule encodes Boolean logic:
"gene1 and gene2" means both genes required."gene1 or gene2" means either gene sufficient.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).with model: creates a reversible sandbox:
sample(..., method="optgp") uses OptGP (often parallelizable); method="achr" uses ACHR.OptGPSampler.validate).model.medium is a dictionary mapping exchange reaction IDs to allowed uptake rates.model.medium = medium.gapfill(model, universal) searches for a minimal set of reactions from universal that restores feasibility (commonly formulated as MILP/optimization with penalties).with model: when testing removals/additions to avoid permanently mutating the model.cobrapy_result.md unless the skill documentation defines a better convention.Run this minimal verification path before full execution when possible:
No local script validation step is required for this skill.
Expected output format:
Result file: cobrapy_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any
tools
Generates complete conventional oncology bulk-transcriptome biomarker and hub-gene research designs from a user-provided cancer type and study direction. Always use this skill whenever a user wants to design, plan, or build a tumor bioinformatics study centered on differential expression, prognostic filtering or risk modeling, PPI-based hub-gene prioritization, diagnostic/prognostic evaluation, clinical association, immune infiltration context, methylation context, and optional tissue or cell validation. Covers five study patterns (signature-first prognostic workflow, hub-gene-first biomarker workflow, hybrid signature-to-hub workflow, immune-context biomarker workflow, translational validation workflow) and always outputs four workload configs (Lite / Standard / Advanced / Publication+) with recommended primary plan, step-by-step workflow, figure plan, validation strategy, minimal executable version, publication upgrade path...
development
Generates complete conventional non-oncology bioinformatics research designs from a user-provided disease context, process-related gene family or biological theme, and validation direction. Use when a study centers on multi-dataset bulk transcriptome integration, DEG analysis, process-gene intersection, enrichment analysis, GSEA, PPI hub-gene prioritization, TF/miRNA regulatory networks, ROC-based biomarker evaluation, and immune infiltration analysis. Covers five study patterns (process-DEG discovery, enrichment/GSEA interpretation, hub-gene prioritization, regulatory-network and immune interpretation, multi-layer public validation) and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.
tools
Plans confounder control, variable adjustment logic, and bias mitigation strategies at the protocol stage for clinical, epidemiologic, translational, observational, and biomarker studies. Always use this skill when a user needs to identify major confounders, decide which variables should or should not be adjusted for, compare matching/stratification/weighting approaches, anticipate selection or measurement bias, or pressure-test a study design before execution. Focus on bias sensing, causal structure awareness, variable-role classification, and critical design review rather than generic statistical advice.
testing
Generates complete comparative network-toxicology research designs from a user-provided exposure pair, shared toxic phenotype, and validation direction. Use when a study centers on two related exposures under one outcome and needs target collection, shared-vs-specific target decomposition, enrichment, PPI hub prioritization, docking, optional transcriptomic cross-checks, and conservative mechanistic synthesis. Covers five study patterns and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.