File size: 3,105 Bytes
4140be3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Bioconda Tool Crawler (Tiered)

该目录提供一个分层抓取脚本:`bioconda_crawler.py`,用于从 Bioconda 抓取工具元数据并按 `T0 / T1 / T2` 输出。

## 输出字段

每条记录至少包含:

- `software_name`
- `package_name`
- `latest_version`
- `dependencies`
- `maintainers`
- `description`
- `summary`
- `license`
- `home_url`
- `doc_url`
- `dev_url`

## 分层策略

- `T0`(核心层):按下载量自动选取
  - 各领域(单细胞/空间转录组/蛋白组/代谢组)按下载量取 Top-K
  - 全部包再按下载量取整体 Top-K
  - 合并去重后作为 T0 结果,不再硬编码固定名单
- `T1`(扩展层):按关键词覆盖单细胞、空间转录组、蛋白组、代谢组工具
- `T2`(长尾层):按需输入工具名动态抓取

## 快速开始

在项目根目录运行:

```bash
python agent_system/toolbase/bioconda_crawler.py \
  --tiers ALL T0 T1 T2 \
  --subdirs linux-64 noarch \
  --downloads-source channel_api \
  --t0-k-per-domain 5 \
  --t0-k-overall 20 \
  --t1-max-per-domain 200 \
  --t1-target-total 600 \
  --t2-tools cellranger scanpy \
  --output-dir agent_system/toolbase/output
```

说明:

- `ALL`:导出全量包索引(依赖来自 repodata,维护者默认空)
- `T0`:按累计下载量自动排序和筛选(结果包含 `downloads` 字段)
- `T0/T1/T2`:会进一步访问 Anaconda 包 API 补充维护者和描述等字段
- `--t1-max-per-domain`:控制 T1 每个领域抓取上限(默认 200)
- `--t1-target-total`:控制 T1 总目标数量(默认 600,不足会从全局高下载包回填)
- `--downloads-source`  - `channel_api`:优先使用频道级包列表接口抓下载量(默认)
  - `package_api`:逐包查询下载量(可配合 `--package-api-max` 限制数量)

## 结果文件

- `bioconda_all_packages_index.json`
- `bioconda_t0_core_tools.json`
- `bioconda_t1_domain_tools.json`
- `bioconda_t2_on_demand_tools.json`

## 转换为 Converter 输入

使用 `prepare_converter_inputs.py``T0/T1/T2` 三份 JSON 转成 `tool2mcp.py` 可直接处理的格式,并可选生成每个工具的 help 文档:

```bash
python agent_system/toolbase/prepare_converter_inputs.py \
  --input-dir agent_system/toolbase/output \
  --output-dir agent_system/toolbase/output \
  --conda-env bioinfomcp-env
```

常用输出:

- `converter_input_t0.json` / `converter_input_t1.json` / `converter_input_t2.json`
- `converter_input_all.json`(可用于 `tool2mcp.py --tools_json`- `converter_jobs.json`(每个工具含 `manual``run_help_command`,可用于 `tool2mcp.py --jobs_json`- `help_index.json``help_docs/*.help.txt`
- `help_docs/*.manual_bundle.txt`(多源文档聚合:CLI help + URL 文档 + conda search --info)

如果只做格式转换,不执行安装:

```bash
python agent_system/toolbase/prepare_converter_inputs.py --skip-install
```

多元回退策略(自动):

1. `<tool> --help`
2. `python -m <module> --help`
3. 抓取 `doc_url/home_url/dev_url` 网页文本
4. `conda search --info` 元信息