[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EC3WV9ERBZY3AC90RVCECZ":3,"skill-same:01M6EC3WV9ERBZY3AC90RVCECZ":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M6EC3WV9ERBZY3AC90RVCECZ","cobrapy",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",66,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FK-Dense-AI\u002Fclaude-scientific-skills\u002Fcobrapy\u002FSKILL.md",[],[5],"2026-11-10 10:12:30",false,"# COBRApy - Constraint-Based Reconstruction and Analysis\n\n## Overview\n\nCOBRApy is a Python library for constraint-based reconstruction and analysis (COBRA) of metabolic models, essential for systems biology research. Work with genome-scale metabolic models, perform computational simulations of cellular metabolism, conduct metabolic engineering analyses, and predict phenotypic behaviors.\n\n## Core Capabilities\n\nCOBRApy provides comprehensive tools organized into several key areas:\n\n### 1. Model Management\n\nLoad existing models from repositories or files:\n```python\nfrom cobra.io import load_model\n\n# Load bundled test models\nmodel = load_model(\"textbook\")  # E. coli core model\nmodel = load_model(\"ecoli\")     # Full E. coli model\nmodel = load_model(\"salmonella\")\n\n# Load from files\nfrom cobra.io import read_sbml_model, load_json_model, load_yaml_model\nmodel = read_sbml_model(\"path\u002Fto\u002Fmodel.xml\")\nmodel = load_json_model(\"path\u002Fto\u002Fmodel.json\")\nmodel = load_yaml_model(\"path\u002Fto\u002Fmodel.yml\")\n```\n\nSave models in various formats:\n```python\nfrom cobra.io import write_sbml_model, save_json_model, save_yaml_model\nwrite_sbml_model(model, \"output.xml\")  # Preferred format\nsave_json_model(model, \"output.json\")  # For Escher compatibility\nsave_yaml_model(model, \"output.yml\")   # Human-readable\n```\n\n### 2. Model Structure and Components\n\nAccess and inspect model components:\n```python\n# Access components\nmodel.reactions      # DictList of all reactions\nmodel.metabolites    # DictList of all metabolites\nmodel.genes          # DictList of all genes\n\n# Get specific items by ID or index\nreaction = model.reactions.get_by_id(\"PFK\")\nmetabolite = model.metabolites[0]\n\n# Inspect properties\nprint(reaction.reaction)        # Stoichiometric equation\nprint(reaction.bounds)          # Flux constraints\nprint(reaction.gene_reaction_rule)  # GPR logic\nprint(metabolite.formula)       # Chemical formula\nprint(metabolite.compartment)   # Cellular location\n```\n\n### 3. Flux Balance Analysis (FBA)\n\nPerform standard FBA simulation:\n```python\n# Basic optimization\nsolution = model.optimize()\nprint(f\"Objective value: {solution.objective_value}\")\nprint(f\"Status: {solution.status}\")\n\n# Access fluxes\nprint(solution.fluxes[\"PFK\"])\nprint(solution.fluxes.head())\n\n# Fast optimization (objective value only)\nobjective_value = model.slim_optimize()\n\n# Change objective\nmodel.objective = \"ATPM\"\nsolution = model.optimize()\n```\n\nParsimonious FBA (minimize total flux):\n```python\nfrom cobra.flux_analysis import pfba\nsolution = pfba(model)\n```\n\nGeometric FBA (find central solution):\n```python\nfrom cobra.flux_analysis import geometric_fba\nsolution = geometric_fba(model)\n```\n\n### 4. Flux Variability Analysis (FVA)\n\nDetermine flux ranges for all reactions:\n```python\nfrom cobra.flux_analysis import flux_variability_analysis\n\n# Standard FVA\nfva_result = flux_variability_analysis(model)\n\n# FVA at 90% optimality\nfva_result = flux_variability_analysis(model, fraction_of_optimum=0.9)\n\n# Loopless FVA (eliminates thermodynamically infeasible loops)\nfva_result = flux_variability_analysis(model, loopless=True)\n\n# FVA for specific reactions\nfva_result = flux_variability_analysis(\n    model,\n    reaction_list=[\"PFK\", \"FBA\", \"PGI\"]\n)\n```\n\n### 5. Gene and Reaction Deletion Studies\n\nPerform knockout analyses:\n```python\nfrom cobra.flux_analysis import (\n    single_gene_deletion,\n    single_reaction_deletion,\n    double_gene_deletion,\n    double_reaction_deletion\n)\n\n# Single deletions\ngene_results = single_gene_deletion(model)\nreaction_results = single_reaction_deletion(model)\n\n# Double deletions (uses multiprocessing)\ndouble_gene_results = double_gene_deletion(\n    model,\n    processes=4  # Number of CPU cores\n)\n\n# Manual knockout using context manager\nwith model:\n    model.genes.get_by_id(\"b0008\").knock_out()\n    solution = model.optimize()\n    print(f\"Growth after knockout: {solution.objective_value}\")\n# Model automatically reverts after context exit\n```\n\n### 6. Growth Media and Minimal Media\n\nManage growth medium:\n```python\n# View current medium\nprint(model.medium)\n\n# Modify medium (must reassign entire dict)\nmedium = model.medium\nmedium[\"EX_glc__D_e\"] = 10.0  # Set glucose uptake\nmedium[\"EX_o2_e\"] = 0.0       # Anaerobic conditions\nmodel.medium = medium\n\n# Calculate minimal media\nfrom cobra.medium import minimal_medium\n\n# Minimize total import flux\nmin_medium = minimal_medium(model, minimize_components=False)\n\n# Minimize number of components (uses MILP, slower)\nmin_medium = minimal_medium(\n    model,\n    minimize_components=True,\n    open_exchanges=True\n)\n```\n\n### 7. Flux Sampling\n\nSample the feasible flux space:\n```python\nfrom cobra.sampling import sample\n\n# Sample using OptGP (default, supports parallel processing)\nsamples = sample(model, n=1000, method=\"optgp\", processes=4)\n\n# Sample using ACHR\nsamples = sample(model, n=1000, method=\"achr\")\n\n# Validate samples\nfrom cobra.sampling import OptGPSampler\nsampler = OptGPSampler(model, processes=4)\nsampler.sample(1000)\nvalidation = sampler.validate(sampler.samples)\nprint(validation.value_counts())  # Should be all 'v' for valid\n```\n\n### 8. Production Envelopes\n\nCalculate phenotype phase planes:\n```python\nfrom cobra.flux_analysis import production_envelope\n\n# Standard production envelope\nenvelope = production_envelope(\n    model,\n    reactions=[\"EX_glc__D_e\", \"EX_o2_e\"],\n    objective=\"EX_ac_e\"  # Acetate production\n)\n\n# With carbon yield\nenvelope = production_envelope(\n    model,\n    reactions=[\"EX_glc__D_e\", \"EX_o2_e\"],\n    carbon_sources=\"EX_glc__D_e\"\n)\n\n# Visualize (use matplotlib or pandas plotting)\nimport matplotlib.pyplot as plt\nenvelope.plot(x=\"EX_glc__D_e\", y=\"EX_o2_e\", kind=\"scatter\")\nplt.show()\n```\n\n### 9. Gapfilling\n\nAdd reactions to make models feasible:\n```python\nfrom cobra.flux_analysis import gapfill\n\n# Prepare universal model with candidate reactions\nuniversal = load_model(\"universal\")\n\n# Perform gapfilling\nwith model:\n    # Remove reactions to create gaps for demonstration\n    model.remove_reactions([model.reactions.PGI])\n\n    # Find reactions needed\n    solution = gapfill(model, universal)\n    print(f\"Reactions to add: {solution}\")\n```\n\n### 10. Model Building\n\nBuild models from scratch:\n```python\nfrom cobra import Model, Reaction, Metabolite\n\n# Create model\nmodel = Model(\"my_model\")\n\n# Create metabolites\natp_c = Metabolite(\"atp_c\", formula=\"C10H12N5O13P3\",\n                   name=\"ATP\", compartment=\"c\")\nadp_c = Metabolite(\"adp_c\", formula=\"C10H12N5O10P2\",\n                   name=\"ADP\", compartment=\"c\")\npi_c = Metabolite(\"pi_c\", formula=\"HO4P\",\n                  name=\"Phosphate\", compartment=\"c\")\n\n# Create reaction\nreaction = Reaction(\"ATPASE\")\nreaction.name = \"ATP hydrolysis\"\nreaction.subsystem = \"Energy\"\nreaction.lower_bound = 0.0\nreaction.upper_bound = 1000.0\n\n# Add metabolites with stoichiometry\nreaction.add_metabolites({\n    atp_c: -1.0,\n    adp_c: 1.0,\n    pi_c: 1.0\n})\n\n# Add gene-reaction rule\nreaction.gene_reaction_rule = \"(gene1 and gene2) or gene3\"\n\n# Add to model\nmodel.add_reactions([reaction])\n\n# Add boundary reactions\nmodel.add_boundary(atp_c, type=\"exchange\")\nmodel.add_boundary(adp_c, type=\"demand\")\n\n# Set objective\nmodel.objective = \"ATPASE\"\n```\n\n## Common Workflows\n\n### Workflow 1: Load Model and Predict Growth\n\n```python\nfrom cobra.io import load_model\n\n# Load model\nmodel = load_model(\"ecoli\")\n\n# Run FBA\nsolution = model.optimize()\nprint(f\"Growth rate: {solution.objective_value:.3f} \u002Fh\")\n\n# Show active pathways\nprint(solution.fluxes[solution.fluxes.abs() > 1e-6])\n```\n\n### Workflow 2: Gene Knockout Screen\n\n```python\nfrom cobra.io import load_model\nfrom cobra.flux_analysis import single_gene_deletion\n\n# Load model\nmodel = load_model(\"ecoli\")\n\n# Perform single gene deletions\nresults = single_gene_deletion(model)\n\n# Find essential genes (growth \u003C threshold)\nessential_genes = results[results[\"growth\"] \u003C 0.01]\nprint(f\"Found {len(essential_genes)} essential genes\")\n\n# Find genes with minimal impact\nneutral_genes = results[results[\"growth\"] > 0.9 * solution.objective_value]\n```\n\n### Workflow 3: Media Optimization\n\n```python\nfrom cobra.io import load_model\nfrom cobra.medium import minimal_medium\n\n# Load model\nmodel = load_model(\"ecoli\")\n\n# Calculate minimal medium for 50% of max growth\ntarget_growth = model.slim_optimize() * 0.5\nmin_medium = minimal_medium(\n    model,\n    target_growth,\n    minimize_components=True\n)\n\nprint(f\"Minimal medium components: {len(min_medium)}\")\nprint(min_medium)\n```\n\n### Workflow 4: Flux Uncertainty Analysis\n\n```python\nfrom cobra.io import load_model\nfrom cobra.flux_analysis import flux_variability_analysis\nfrom cobra.sampling import sample\n\n# Load model\nmodel = load_model(\"ecoli\")\n\n# First check flux ranges at optimality\nfva = flux_variability_analysis(model, fraction_of_optimum=1.0)\n\n# For reactions with large ranges, sample to understand distribution\nsamples = sample(model, n=1000)\n\n# Analyze specific reaction\nreaction_id = \"PFK\"\nimport matplotlib.pyplot as plt\nsamples[reaction_id].hist(bins=50)\nplt.xlabel(f\"Flux through {reaction_id}\")\nplt.ylabel(\"Frequency\")\nplt.show()\n```\n\n### Workflow 5: Context Manager for Temporary Changes\n\nUse context managers to make temporary modifications:\n```python\n# Model remains unchanged outside context\nwith model:\n    # Temporarily change objective\n    model.objective = \"ATPM\"\n\n    # Temporarily modify bounds\n    model.reactions.EX_glc__D_e.lower_bound = -5.0\n\n    # Temporarily knock out genes\n    model.genes.b0008.knock_out()\n\n    # Optimize with changes\n    solution = model.optimize()\n    print(f\"Modified growth: {solution.objective_value}\")\n\n# All changes automatically reverted\nsolution = model.optimize()\nprint(f\"Original growth: {solution.objective_value}\")\n```\n\n## Key Concepts\n\n### DictList Objects\nModels use `DictList` objects for reactions, metabolites, and genes - behaving like both lists and dictionaries:\n```python\n# Access by index\nfirst_reaction = model.reactions[0]\n\n# Access by ID\npfk = model.reactions.get_by_id(\"PFK\")\n\n# Query methods\natp_reactions = model.reactions.query(\"atp\")\n```\n\n### Flux Constraints\nReaction bounds define feasible flux ranges:\n- **Irreversible**: `lower_bound = 0, upper_bound > 0`\n- **Reversible**: `lower_bound \u003C 0, upper_bound > 0`\n- Set both bounds simultaneously with `.bounds` to avoid inconsistencies\n\n### Gene-Reaction Rules (GPR)\nBoolean logic linking genes to reactions:\n```python\n# AND logic (both required)\nreaction.gene_reaction_rule = \"gene1 and gene2\"\n\n# OR logic (either sufficient)\nreaction.gene_reaction_rule = \"gene1 or gene2\"\n\n# Complex logic\nreaction.gene_reaction_rule = \"(gene1 and gene2) or (gene3 and gene4)\"\n```\n\n### Exchange Reactions\nSpecial reactions representing metabolite import\u002Fexport:\n- Named with prefix `EX_` by convention\n- Positive flux = secretion, negative flux = uptake\n- Managed through `model.medium` dictionary\n\n## Best Practices\n\n1. **Use context managers** for temporary modifications to avoid state management issues\n2. **Validate models** before analysis using `model.slim_optimize()` to ensure feasibility\n3. **Check solution status** after optimization - `optimal` indicates successful solve\n4. **Use loopless FVA** when thermodynamic feasibility matters\n5. **Set fraction_of_optimum** appropriately in FVA to explore suboptimal space\n6. **Parallelize** computationally expensive operations (sampling, double deletions)\n7. **Prefer SBML format** for model exchange and long-term storage\n8. **Use slim_optimize()** when only objective value needed for performance\n9. **Validate flux samples** to ensure numerical stability\n\n## Troubleshooting\n\n**Infeasible solutions**: Check medium constraints, reaction bounds, and model consistency\n**Slow optimization**: Try different solvers (GLPK, CPLEX, Gurobi) via `model.solver`\n**Unbounded solutions**: Verify exchange reactions have appropriate upper bounds\n**Import errors**: Ensure correct file format and valid SBML identifiers\n\n## References\n\nFor detailed workflows and API patterns, refer to:\n- `references\u002Fworkflows.md` - Comprehensive step-by-step workflow examples\n- `references\u002Fapi_quick_reference.md` - Common function signatures and patterns\n\nOfficial documentation: https:\u002F\u002Fcobrapy.readthedocs.io\u002Fen\u002Flatest\u002F\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FK-Dense-AI\u002Fclaude-scientific-skills\u002Fcobrapy",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill cobrapy",{"tool":37,"command":38},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill cobrapy",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill cobrapy","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FK-Dense-AI\u002Fclaude-scientific-skills\u002Fcobrapy\u002FSKILL.md",true,[],[46,60,70,79,85,92],{"skillNo":47,"name":48,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":56,"publishedAt":18},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[51],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[57,58,59],"model","model hierarchy","model hierarchy skill",{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":66,"publishedAt":18},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[65],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[67,68,69],"MCP","zoom","zoom mcp",{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[76,77,78,68],"sdk","zoom apps sdk","apps",{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[81],{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":91,"publishedAt":18},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[90],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[87],{"skillNo":93,"name":94,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[94]]