File size: 10,826 Bytes
d1ce356 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | # HypoBioOS
Step-by-step guide for setting up Biomni and running the generic paper reproduction workflow in this repository.
This repository is developed based on the open-source Biomni codebase from [snap-stanford/biomni](https://github.com/snap-stanford/biomni). We extend the original Biomni agent framework with MCP server generation, graph-guided tool retrieval, dynamic MCP routing, and benchmark-oriented experiment runners.
## 1. Goal
This document explains how to:
- set up the Biomni runtime environment,
- configure the LLM endpoint used by the reproduction script,
- verify MCP servers are discoverable,
- run the generic reproduction runner,
- reproduce the built-in FOXJ1 example,
- run the same workflow on a different paper.
The main script covered here is:
```text
/225040511/project/Biomni/reproduce_foxj1_paper.py
```
Although the filename still contains `foxj1`, the script is now a generic runner.
## 2. Prerequisites
Before you start, make sure you have:
- access to this Biomni repository,
- Conda installed,
- a working Python environment compatible with Biomni,
- an API key for a model endpoint,
- generated MCP server directories under `biomni_web/backend/data/mcp_generated/`.
## 3. Enter The Repository
```bash
cd /225040511/project/Biomni
```
## 4. Build The Biomni Environment
Follow the environment setup instructions in:
```text
biomni_env/README.md
```
After the environment is created, activate it:
```bash
conda activate biomni_e1
```
If you are running Biomni from source, install the current repository into the environment:
```bash
pip install -e .
```
If you prefer the upstream GitHub version instead:
```bash
pip install git+https://github.com/snap-stanford/Biomni.git@main
```
## 5. Configure The Model Endpoint
The current `reproduce_foxj1_paper.py` script creates the agent with:
```python
source="Custom"
```
This means the script is using an OpenAI-compatible HTTP endpoint through Biomni's custom backend path.
The current code reads credentials in this order:
1. `DEEPSEEK_API_KEY`
2. `OPENAI_API_KEY`
3. fallback to `"EMPTY"`
The current code also reads:
- `DEEPSEEK_BASE_URL`
- `DEEPSEEK_MODEL_NAME`
So if you want to use OpenAI, you should not only set `OPENAI_API_KEY`, but also point `DEEPSEEK_BASE_URL` to the OpenAI API endpoint and set `DEEPSEEK_MODEL_NAME` to an OpenAI model name.
### Option A. Use DeepSeek
Set these environment variables:
```bash
export DEEPSEEK_API_KEY="your_api_key"
export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1"
export DEEPSEEK_MODEL_NAME="deepseek-chat"
```
### Option B. Use OpenAI API Key
Use the OpenAI key as the authentication source, but still set the endpoint and model through the same runtime variables used by the script:
```bash
export OPENAI_API_KEY="your_openai_api_key"
export DEEPSEEK_BASE_URL="https://api.openai.com/v1"
export DEEPSEEK_MODEL_NAME="gpt-4.1-mini"
```
You can replace `gpt-4.1-mini` with another OpenAI model that your account can access, for example:
```bash
export DEEPSEEK_MODEL_NAME="gpt-4.1"
```
### Option C. Use Another OpenAI-Compatible Endpoint
If you use another OpenAI-compatible endpoint, point the same variables to your own service:
```bash
export OPENAI_API_KEY="your_custom_endpoint_key"
export DEEPSEEK_BASE_URL="http://your-endpoint/v1"
export DEEPSEEK_MODEL_NAME="your-model-name"
```
### Quick Check
After exporting the variables, you can confirm they are set:
```bash
echo "$DEEPSEEK_BASE_URL"
echo "$DEEPSEEK_MODEL_NAME"
```
If you are using OpenAI:
```bash
echo "$OPENAI_API_KEY"
```
You do not need to print the full key in shared logs. It is enough to verify that the variable is non-empty.
Optional but recommended:
```bash
export BIOMNI_MCP_PYTHON="$(which python)"
```
This ensures the generated MCP config uses the Python interpreter from your active Biomni environment.
## 6. Verify MCP Servers Exist
The script discovers MCP servers from:
```text
biomni_web/backend/data/mcp_generated/
```
Each server is expected to look like:
```text
mcp_<server_name>/app/*_shim_server.py
```
or:
```text
mcp_<server_name>/app/*_server.py
```
You can inspect what the script currently finds:
```bash
python reproduce_foxj1_paper.py --list-servers
```
If the list is empty or missing expected servers, check whether the corresponding generated directories exist under:
```text
/225040511/project/Biomni/biomni_web/backend/data/mcp_generated/
```
## 7. Understand What The Script Does
The script performs these high-level steps:
1. parses your paper title, context, query, input files, and requested MCP servers,
2. discovers available MCP server directories,
3. builds an MCP config YAML file for the selected servers,
4. creates a run directory under `paper_reproduction_runs/`,
5. writes prompt, query, and plan files,
6. initializes `A1`,
7. loads the MCP config,
8. asks Biomni to plan the reproduction steps from your query,
9. lets Biomni select suitable MCP tools during execution,
10. saves logs, final answer, and report files.
## 8. Do A Dry Run First
Before running the full workflow, do a preparation-only run:
```bash
python reproduce_foxj1_paper.py \
--dataset-profile foxj1 \
--prepare-only
```
This does not call the model. It only prepares:
- the run directory,
- the MCP config,
- the query file,
- the prompt file,
- the execution plan file.
The output will be written under:
```text
paper_reproduction_runs/
```
## 9. Run The Built-In FOXJ1 Example
Use the built-in dataset profile if you want to reproduce the FOXJ1 example workflow.
Command:
```bash
python reproduce_foxj1_paper.py \
--dataset-profile foxj1 \
--query "Firstly, whether FOXJ1 and GMNC were up-regulated in LuCaP35CR, then whether ABCB1 was up-regulated in LuCaP70CR, and finally the enrichment analysis of pathways related to cilia/microtubules was performed"
```
What this does:
1. loads the built-in FOXJ1 profile,
2. downloads the associated GEO processed files if needed,
3. selects the preferred MCP server set for that profile,
4. builds the execution prompt from your natural-language query,
5. runs Biomni with MCP enabled,
6. writes logs and outputs into the run directory.
## 10. Run A Different Paper
If you want to run another paper, provide your own paper metadata and inputs.
Minimal example:
```bash
python reproduce_foxj1_paper.py \
--paper-title "Your Paper Title" \
--context-file /path/to/paper_summary.md \
--input-file /path/to/data1.csv \
--input-file /path/to/data2.tsv \
--query "Reproduce the main findings, choose suitable MCP tools, run the feasible analyses, and summarize what is supported by the provided data." \
--server jq \
--server bioconductor-clusterprofiler \
--server gseapy
```
You can also pass entire directories:
```bash
python reproduce_foxj1_paper.py \
--paper-title "Another Paper" \
--paper-context "Short summary of the paper and the results you want to reproduce." \
--input-dir /path/to/input_folder \
--query "Check differential patterns and enrichment results." \
--server all
```
## 11. Important Command Options
Common options supported by the script:
- `--paper-title`: title of the paper for this run.
- `--paper-context`: short context text passed directly on the command line.
- `--context-file`: markdown or text file containing paper context.
- `--query`: natural-language reproduction request.
- `--input-file`: input file to include, can be used multiple times.
- `--input-dir`: input directory to include, can be used multiple times.
- `--dataset-profile foxj1`: use the built-in FOXJ1 example profile.
- `--server`: choose MCP servers explicitly.
- `--server all`: register all discovered MCP servers.
- `--prepare-only`: generate files without running the model.
- `--list-servers`: print discovered MCP servers and exit.
## 12. What Files You Should Expect
For each run, the script creates a folder like:
```text
paper_reproduction_runs/<run_name>/
```
Inside it, you should see files such as:
```text
mcp_config.yaml
paper_context.md
reproduction_query.txt
execution_plan.md
reproduction_prompt.txt
results/biomni_execution_log_*.txt
results/biomni_execution_log_*.json
results/biomni_final_answer_*.txt
results/biomni_run_metadata_*.json
results/biomni_conversation_*.md
results/reproduction_report.md
```
## 13. Recommended First-Time Workflow
If this is your first time running the script, use this exact order:
1. `cd /225040511/project/Biomni`
2. `conda activate biomni_e1`
3. `pip install -e .`
4. export `DEEPSEEK_API_KEY`
5. export `DEEPSEEK_BASE_URL`
6. export `DEEPSEEK_MODEL_NAME`
7. optionally export `BIOMNI_MCP_PYTHON="$(which python)"`
8. run `python reproduce_foxj1_paper.py --list-servers`
9. run `python reproduce_foxj1_paper.py --dataset-profile foxj1 --prepare-only`
10. run the full FOXJ1 example command
## 14. Troubleshooting
If the script does not run, check these items one by one.
### Environment Problems
- Make sure the Conda environment is activated.
- Make sure `pip install -e .` completed successfully.
- Make sure the same Python is used by both Biomni and MCP config generation.
### Model Problems
- Make sure `DEEPSEEK_API_KEY` is set.
- Make sure `DEEPSEEK_BASE_URL` points to a reachable OpenAI-compatible endpoint.
- Make sure `DEEPSEEK_MODEL_NAME` matches a model served by that endpoint.
### MCP Problems
- Run `python reproduce_foxj1_paper.py --list-servers`.
- Confirm the required `mcp_<name>` directories exist.
- Confirm each selected MCP server has an `app/` directory with a `*_shim_server.py` or `*_server.py` file.
### Input Problems
- Confirm all `--input-file` paths exist.
- Confirm all `--input-dir` paths exist.
- If using the `foxj1` profile, let the script finish downloading the GEO processed files.
### Dry Run Problems
- If a full run fails, first retry with `--prepare-only`.
- Check whether the prompt and MCP config are generated correctly before debugging model execution.
## 15. One-Line Reference Commands
List MCP servers:
```bash
python reproduce_foxj1_paper.py --list-servers
```
Prepare only:
```bash
python reproduce_foxj1_paper.py --dataset-profile foxj1 --prepare-only
```
Run FOXJ1:
```bash
python reproduce_foxj1_paper.py --dataset-profile foxj1 --query "Firstly, whether FOXJ1 and GMNC were up-regulated in LuCaP35CR, then whether ABCB1 was up-regulated in LuCaP70CR, and finally the enrichment analysis of pathways related to cilia/microtubules was performed"
```
## 16. Acknowledgements
This work builds on the open-source Biomni project by the Stanford SNAP group: [snap-stanford/biomni](https://github.com/snap-stanford/biomni). We gratefully acknowledge the Biomni authors and contributors for releasing their codebase and biomedical agent framework, which provided the foundation for this development.
|