cobrapy
Constraints-Based Reconstruction and Analysis for Python. Used for modeling large-scale metabolic networks in microorganisms.
What this skill does
# COBRApy - Metabolic Modeling
Models the "metabolism" of a cell as a linear optimization problem. Used to predict bacterial growth under different conditions or design GMO strains.
## When to Use
- Predicting microbial growth rates under different nutrient conditions.
- Designing metabolic engineering strategies (knockouts, additions).
- Understanding metabolic flux distributions.
- Comparing metabolic capabilities across organisms.
- Identifying essential genes and reactions.
## Core Principles
### Flux Balance Analysis (FBA)
Optimizes metabolic fluxes to maximize biomass production (or other objectives) subject to stoichiometric constraints.
### Gene-Protein-Reaction (GPR)
Genes encode proteins (enzymes) that catalyze reactions. Knockouts affect reaction availability.
### Constraints
Reaction bounds (lower/upper limits) represent enzyme capacity or nutrient availability.
## Quick Reference
### Standard Imports
```python
import cobra
from cobra.io import load_model, save_model
```
### Basic Patterns
```python
# 1. Load model (e.g., E. coli)
model = cobra.io.load_model("iJO1366")
# Or: model = cobra.io.read_sbml_model("model.xml")
# 2. Run Flux Balance Analysis (FBA)
solution = model.optimize()
print(f"Growth rate: {solution.objective_value:.4f}")
print(f"Status: {solution.status}")
# 3. Knockout simulation (Gene essentiality)
with model:
model.genes.get_by_id("b0002").knock_out()
print(f"Growth after knockout: {model.optimize().objective_value:.4f}")
# 4. Change medium (nutrient availability)
model.medium = {
'EX_glc__D_e': 10.0, # Glucose uptake
'EX_o2_e': 1000.0 # Oxygen
}
solution = model.optimize()
```
## Critical Rules
### ✅ DO
- **Check solution status** - Ensure status is 'optimal' before using results.
- **Use context managers** - Wrap modifications in `with model:` to avoid permanent changes.
- **Set appropriate bounds** - Reaction bounds should reflect biological reality.
- **Validate model** - Use `model.validate()` to check for common issues.
### ❌ DON'T
- **Don't ignore infeasible solutions** - If optimization fails, check constraints and bounds.
- **Don't modify model in place** - Use context managers or copy the model first.
- **Don't assume all reactions are active** - Many reactions have zero flux in optimal solution.
## Advanced Patterns
### Flux Variability Analysis (FVA)
```python
from cobra.flux_analysis import flux_variability_analysis
# Find range of possible fluxes for each reaction
fva_result = flux_variability_analysis(model, model.reactions)
```
### Gene Essentiality Analysis
```python
# Test which genes are essential for growth
from cobra.flux_analysis import single_gene_deletion
deletion_results = single_gene_deletion(model)
essential_genes = deletion_results[deletion_results['growth'] < 0.01]
```
### Adding Custom Reactions
```python
# Add a new reaction to the model
new_reaction = cobra.Reaction("NEW_RXN")
new_reaction.add_metabolites({
model.metabolites.get_by_id("glc__D_c"): -1,
model.metabolites.get_by_id("atp_c"): -1,
model.metabolites.get_by_id("adp_c"): 1,
})
new_reaction.lower_bound = 0
new_reaction.upper_bound = 1000
model.add_reactions([new_reaction])
```
COBRApy transforms metabolic networks into computable models, enabling researchers to predict and engineer cellular behavior at the systems level.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.