API
复核基因列表
把基因列表提交做首轮复核,再把被标记的基因交给科学家核查
本配方把一份基因列表交给 BioAgent 做首轮复核,并把被标记的基因整理成供科学家使用的清单。清单会链接回该任务,科学家可以在 BioAgent 中打开它并继续对话。
示例列表是 A375 黑色素瘤细胞中针对维莫非尼(vemurafenib)耐药性的全基因组 CRISPR 敲除筛选得到的 15 个命中基因。对每个基因,智能体会检查:符号是否为当前名称、是否在黑色素瘤细胞系中表达、是否有已发表证据把其缺失与 MAPK 抑制剂耐药联系起来,以及它是否可能是筛选伪影。它为每个基因返回 plausible 或 flag 的结论,并附理由与来源。
前置条件
- 一个 API 密钥
- Python 3.10 或更高版本,并安装
requests包 - 来自构建 Python 客户端 的
bioagent_client.py,保存在脚本旁边
安装 requests,然后设置 API 密钥:
python -m pip install requests
export BIOAGENT_API_KEY="<your-api-key>"
脚本使用 https://bioagent.cloud/api/v1。若要改用其他部署,请把 BIOAGENT_BASE_URL 环境变量设置为该部署的 API 基础 URL。
默认情况下,脚本会创建一个名为 “API demo” 的项目。若要改用已有项目,请把 BIOAGENT_PROJECT_ID 设置为其 ID。
工作方式
main() 以 auto_mode=True 创建复核任务,等待其完成并下载 review.json。随后它把每个被标记的基因,连同智能体给出的理由与来源,写入 scientist_checklist.md。
def main():
bioagent = BioAgentClient()
project_id = (
os.getenv("BIOAGENT_PROJECT_ID")
or bioagent.create_project(title="API demo")["id"]
)
task = bioagent.create_task(
project_id=project_id,
title="Gene list review: vemurafenib resistance screen",
initial_messages=[
{"role": "user", "content": REVIEW_PROMPT.format(genes=", ".join(GENES))}
],
auto_mode=True,
)
print(f"Review task: {task['id']}")
bioagent.wait_for_task(task["id"], poll_interval_seconds=60)
results_dir = bioagent.download_results(task["id"], Path("gene-review") / task["id"])
review = json.loads((results_dir / "review.json").read_text())
flagged = [entry for entry in review if entry["verdict"] == "flag"]
task_url = f"{WEB_BASE}/projects/{project_id}/tasks/{task['id']}"
checklist = results_dir / "scientist_checklist.md"
write_checklist(checklist, task_url, flagged)
print(f"{len(flagged)} of {len(review)} genes flagged for a scientist to check.")
print(f"Checklist: {checklist}")
print(f"Task: {task_url}")
write_checklist() 把被标记的基因转换为一个 Markdown 清单,并附上任务链接:
def write_checklist(path, task_url, flagged):
lines = [
"# Gene list review: genes to check",
"",
f"BioAgent's first-pass review: {task_url}",
"Reply in that task to ask BioAgent follow-up questions about any gene.",
"",
]
for entry in flagged:
lines.append(f"- [ ] **{entry['gene']}**: {entry['reason']}")
lines.extend(f" - {source}" for source in entry["evidence"])
path.write_text("\n".join(lines) + "\n")
链接使用 https://bioagent.cloud。若要改用其他部署,请把 WEB_BASE 设置为该部署的 URL。
开启 Auto 模式后,任务不会停下来等人。BioAgent 会自行回答自己的澄清问题并批准自己的计划,并在任务中标注这两点。

复核任务中的 Auto 模式:澄清问题被自动回答,计划被自动批准。
python gene_list_review.py
运行脚本
把完整脚本保存为 gene_list_review.py,与 bioagent_client.py 放在同一目录,然后运行:
脚本会打印被标记基因的数量,以及清单与任务的路径。结果保存在 gene-review/<task-id>/ 下。
示例结果
复核认为 10 个基因可信(NF1、MED12、NF2、CUL3、TADA2B、TADA1、CIC、KEAP1、PTEN、DUSP4),并标记了 5 个:
| 基因 | 被标记的原因 |
|---|---|
| SEPT2 | 符号已过时:guide 库必须把它映射到 SEPTIN2。 |
| MARCH5 | 符号已过时,且对耐药性的影响方向尚无定论。 |
| OR4F5 | 在 A375 或其他黑色素瘤细胞系中不表达;guide 还可能命中相关的嗅觉受体。 |
| TTN | 在 A375 中仅痕量表达,且在测过的所有黑色素瘤细胞系中低于 1 TPM。 |
| LINC00473 | 非编码 RNA:没有可敲除的蛋白编码读框。 |

完成的复核:10 个基因可信、5 个被标记,保存为 review.json。
每项清单条目都包含智能体的完整推理与来源:
# Gene list review: genes to check
BioAgent's first-pass review: https://bioagent.cloud/projects/<project-id>/tasks/<task-id>
Reply in that task to ask BioAgent follow-up questions about any gene.
- [ ] **SEPT2**: Not the current approved symbol: SEPT2 is a previous symbol of SEPTIN2 (HGNC:7729); ...
为你的基因列表改编本配方
- 把
GENES换为你的列表,并修改REVIEW_PROMPT以描述你的筛选与想做的检查。 - 保留固定的结论字段,例如
plausible或flag,这样你的代码无需阅读智能体的自然语言即可路由结果。
完整脚本
"""Gene list review: send a gene list for a first-pass review, then hand what
it flags to a scientist to check."""
import json
import os
from pathlib import Path
from bioagent_client import BioAgentClient
WEB_BASE = "https://bioagent.cloud"
# Top positively selected genes from a genome-wide CRISPR knockout screen for
# vemurafenib resistance in A375 melanoma cells.
GENES = [
"NF1", "MED12", "NF2", "CUL3", "TADA2B", "TADA1", "CIC", "KEAP1",
"SEPT2", "MARCH5", "OR4F5", "TTN", "PTEN", "DUSP4", "LINC00473",
]
REVIEW_PROMPT = """
These genes are the top hits from a genome-wide CRISPR knockout screen for
vemurafenib resistance in A375 BRAF V600E melanoma cells:
{genes}
Do a first-pass review of each gene before we spend bench time on it:
- Is the symbol current HGNC, and is it a protein-coding gene a CRISPR knockout
can hit?
- Is it expressed in A375 or melanoma lines (DepMap/CCLE)?
- Is there published evidence linking its loss to BRAF or MAPK inhibitor
resistance?
- Could it be a screen artifact (not expressed, very long gene, copy-number
effect)?
Save raw JSON (no code fence) at /mnt/results/review.json, one entry per gene:
[{{"gene": "NF1", "verdict": "plausible" or "flag", "reason": "...",
"evidence": ["PMID or source", "..."]}}]
""".strip()
def write_checklist(path, task_url, flagged):
lines = [
"# Gene list review: genes to check",
"",
f"BioAgent's first-pass review: {task_url}",
"Reply in that task to ask BioAgent follow-up questions about any gene.",
"",
]
for entry in flagged:
lines.append(f"- [ ] **{entry['gene']}**: {entry['reason']}")
lines.extend(f" - {source}" for source in entry["evidence"])
path.write_text("\n".join(lines) + "\n")
def main():
bioagent = BioAgentClient()
project_id = (
os.getenv("BIOAGENT_PROJECT_ID")
or bioagent.create_project(title="API demo")["id"]
)
task = bioagent.create_task(
project_id=project_id,
title="Gene list review: vemurafenib resistance screen",
initial_messages=[
{"role": "user", "content": REVIEW_PROMPT.format(genes=", ".join(GENES))}
],
auto_mode=True,
)
print(f"Review task: {task['id']}")
bioagent.wait_for_task(task["id"], poll_interval_seconds=60)
results_dir = bioagent.download_results(task["id"], Path("gene-review") / task["id"])
review = json.loads((results_dir / "review.json").read_text())
flagged = [entry for entry in review if entry["verdict"] == "flag"]
task_url = f"{WEB_BASE}/projects/{project_id}/tasks/{task['id']}"
checklist = results_dir / "scientist_checklist.md"
write_checklist(checklist, task_url, flagged)
print(f"{len(flagged)} of {len(review)} genes flagged for a scientist to check.")
print(f"Checklist: {checklist}")
print(f"Task: {task_url}")
if __name__ == "__main__":
main()