83 lines
2.1 KiB
Markdown
Executable File
83 lines
2.1 KiB
Markdown
Executable File
# Annotation Skill - 功能注释技能
|
|
|
|
提供两种模式的功能注释:
|
|
|
|
## 模式对比
|
|
|
|
| 特性 | API 模式 (`run_api.py`) | 本地模式 (`run.py`) |
|
|
|------|------------------------|---------------------|
|
|
| **速度** | 慢 (~1秒/基因) | 快 (批量处理) |
|
|
| **数据库** | 不需要 | 需要 (~20GB) |
|
|
| **网络** | 需要联网 | 不需要 |
|
|
| **适用数据量** | < 1000 基因 | 任意规模 |
|
|
| **输出格式** | gene2go.txt | .emapper.annotations |
|
|
| **注释内容** | 仅 GO | GO + KEGG + COG + Pfam |
|
|
|
|
## 快速开始
|
|
|
|
### API 模式(推荐小数据集)
|
|
|
|
```bash
|
|
# 基本用法
|
|
python run_api.py --input protein.fa --output ./annotation
|
|
|
|
# 调整请求间隔(避免被限流)
|
|
python run_api.py --input protein.fa --output ./annotation --delay 1.5
|
|
```
|
|
|
|
### 本地模式(推荐大数据集)
|
|
|
|
```bash
|
|
# 1. 先下载数据库(只需一次)
|
|
bash download_db.sh
|
|
|
|
# 2. 运行注释
|
|
python run.py --input protein.fa --output ./annotation --cpu 8
|
|
```
|
|
|
|
## 输出文件
|
|
|
|
### API 模式
|
|
- `*.gene2go.txt` - 基因-GO对应表
|
|
- `report.md` - 统计报告
|
|
|
|
### 本地模式
|
|
- `*.emapper.annotations` - 完整注释结果
|
|
- `*.emapper.seed_orthologs` - 种子直系同源
|
|
- `*.emapper.pfam` - Pfam结构域
|
|
- `report.md` - 统计报告
|
|
- `commands.sh` - 可复现命令
|
|
|
|
## 测试
|
|
|
|
```bash
|
|
# 测试 API 模式
|
|
python run_api.py --demo --output ./test_api
|
|
|
|
# 测试本地模式
|
|
python run.py --demo --output ./test_local
|
|
|
|
# 运行单元测试
|
|
python tests/test_annotation.py
|
|
```
|
|
|
|
## 集成到 Pipeline
|
|
|
|
```python
|
|
# 小数据集用 API
|
|
from skills.annotation.run_api import AnnotationAPISkill
|
|
skill = AnnotationAPISkill()
|
|
result = skill.run(protein_fasta, output_dir)
|
|
|
|
# 大数据集用本地
|
|
from skills.annotation.run import AnnotationSkill
|
|
skill = AnnotationSkill()
|
|
result = skill.run(protein_fasta, output_dir)
|
|
```
|
|
|
|
## 注意事项
|
|
|
|
1. **API 模式**:eggNOG 服务器可能有请求限制,建议 `--delay 1.0` 以上
|
|
2. **本地模式**:首次需下载 20GB 数据库,使用 `download_db.sh` 脚本
|
|
3. **基因数量**:API 模式超过 1000 基因会非常慢,建议改用本地模式
|