Chuyển đến nội dung
Skillpedia
Học máy51k · #3442

cobrapy

Skill này làm gì

Công cụ này phân tích cách hệ thống sinh học hoạt động bằng cách mô phỏng các phản ứng hóa học bên trong tế bào. Bạn có thể thử xem điều gì xảy ra nếu loại bỏ một gen, hoặc “chế độ ăn” nào tốt nhất để tế bào phát triển.

Khi nào nên dùng

  • ✓Khi bạn muốn hiểu tế bào hoạt động ở cấp độ phân tử.
  • ✓Khi bạn muốn dự đoán kết quả thí nghiệm, chẳng hạn khi loại bỏ một gen.
  • ✓Khi bạn muốn tìm các chất dinh dưỡng mà tế bào cần để phát triển.

Liên kết skill

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/cobrapy/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/cobrapy/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Mô phỏng việc loại bỏ gen PFK và xem nó ảnh hưởng thế nào đến sự phát triển của tế bào.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng một mô hình toán học của tế bào để dự đoán dòng phản ứng. Nó có thể tính mức tăng trưởng tối đa hoặc khoảng dòng chảy có thể có của từng phản ứng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

COBRApy - Constraint-Based Reconstruction and Analysis

When to use

Use for loading/building metabolic networks, optimizing their steady-state fluxes, knockout screens, medium design, feasible-space sampling, and gap-filling hypotheses. FBA is a constraint-based prediction; it does not infer kinetic rates or establish experimental growth, thermodynamic feasibility, or flux identifiability.

Setup and reproducibility

Targets cobra 0.32.1 (import cobra), checked against its released source and current documentation.

uv pip install "cobra==0.32.1"
# Optional SciPy support for MATLAB I/O and array operations:
uv pip install "cobra[array]==0.32.1"

Plotting examples additionally require matplotlib, pandas, and seaborn. The cobra[chrr] extra supplies hopsy for the new CHRR sampler; that optional backend was documentation-reviewed, not executed in this refresh. In 0.32.1, sample() defaults to method="auto" (CHRR when hopsy is installed, otherwise OptGP). Choose the method explicitly to avoid environment-dependent changes.

Record model source/version/checksum, cobra and solver versions, objective, medium, bounds, tolerances, and any random seed with each analysis. GLPK handles the examples below; inspect cobra.util.solver.solvers before choosing an optional solver. Use "hybrid" for its HiGHS/OSQP interface when installed; the legacy "osqp" alias is deprecated. QP methods require a suitable backend. Start with processes=1; scripts using multiprocessing need a guarded entry point.

Workflow

1. Load, inspect, and validate a model

from cobra.io import load_model

# These names are bundled: textbook, iJO1366, salmonella.
model = load_model("textbook")  # model.id is e_coli_core; 95 reactions
model.solver = "glpk"
print(model.id, len(model.reactions), len(model.metabolites), len(model.genes))
print(model.reactions.get_by_id("PFK").reaction)
print(model.reactions.PFK.gene_reaction_rule)
print(model.medium)

solution = model.optimize(raise_error=True)
assert solution.status == "optimal"
print(solution.objective_value, solution.fluxes["PFK"])
# error_value=None raises on a failed solve; the default instead returns NaN.
baseline = model.slim_optimize(error_value=None)
assert baseline > 0

e_coli_core is a remote BiGG identifier, not a bundled alias for textbook. The released remote adapters encounter redirects on current BiGG/BioModels URLs; see model I/O for verified download routes and local SBML loading. Do not assume load_model caches: its 0.32.1 implementation accepts cache but does not use it. Save source files for reproducibility.

Check chemical formulas/charges and boundary annotations separately from solver feasibility. Review excluded biomass/pseudo reactions and missing chemistry; an empty imbalance dictionary alone cannot establish a chemically valid model. The validation workflow distinguishes those cases.

2. Compare FBA, pFBA, and FVA under stated constraints

from cobra.flux_analysis import pfba, geometric_fba, flux_variability_analysis

biomass_id = "Biomass_Ecoli_core"  # inspect IDs/objective for each new model
parsimonious = pfba(model)
print(parsimonious.fluxes[biomass_id])
# parsimonious.objective_value is the minimized total flux, not biomass growth.
centered = geometric_fba(model, processes=1)

fva = flux_variability_analysis(
    model, reaction_list=["PFK", "FBA", "PGI"],
    fraction_of_optimum=0.9, processes=1,
)
loopless_fva = flux_variability_analysis(
    model, reaction_list=["PFK", "FBA", "PGI"],
    fraction_of_optimum=0.9, loopless="fastSNP", processes=1,
)
print(fva)  # index: reaction ID; columns: minimum, maximum

FVA extrema are optimized separately and need not be jointly achievable. loopless="fastSNP" computes loopless bounds; "cycleFreeFlux" is an alternative that need not find the optimal bounds. Boolean loopless arguments are deprecated. Loop removal does not impose measured Gibbs energies or metabolite concentrations. Fractional objective thresholds here assume a positive biomass maximization objective; use an explicit constraint for other objective signs/directions.

3. Knockouts and media

from cobra.flux_analysis import single_gene_deletion
from cobra.medium import minimal_medium

results = single_gene_deletion(model, processes=1)

…
Câu hỏi thường gặp

FBA là gì?

FBA (Flux Balance Analysis) là kỹ thuật tính toán dòng phản ứng trong một mô hình chuyển hóa với những điều kiện nhất định.

“Gene knockout” là gì?

Đó là mô phỏng trong đó một gen cụ thể bị “tắt” để xem nó ảnh hưởng thế nào đến quá trình chuyển hóa của tế bào.

“Môi trường tối thiểu” là gì?

Đó là tập hợp chất dinh dưỡng tối thiểu mà tế bào cần để phát triển với một tốc độ nhất định.

Chi tiết

Mô tả gốc của tác giả

Performs constraint-based metabolic modeling with COBRApy, including FBA, pFBA, FVA, gene knockouts, flux sampling, growth media, production envelopes, gap filling, and SBML model validation for systems biology and metabolic engineering.

repo: K-Dense-AI/scientific-agent-skills

Độ phổ biến

Sao GitHub
51k
Vị trí xếp hạng
#3442
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự