Files
PlantAI-dev/skills/annotation/IMPLEMENTATION_SUMMARY.md
2026-08-03 18:42:47 +08:00

124 lines
3.1 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# eggNOG-mapper Annotation Skill - 实现总结
## 完成情况 ✅
已完成为 bbav20311 添加 eggNOG-mapper 调用功能,自动生成 `.emapper.annotations` 文件。
## 创建的文件
```
skills/annotation/
├── config.yaml # 技能配置(参数、依赖)
├── run.py # 主程序(~400行)
├── SKILL.md # 技能文档
├── example_usage.py # 集成示例
├── tests/
│ └── test_annotation.py # 单元测试
└── IMPLEMENTATION_SUMMARY.md # 本文件
```
## 功能特性
### 核心功能
- 调用本地 `emapper.py` 进行功能注释
- 自动生成 `.emapper.annotations` 文件
- 同时生成 `.emapper.seed_orthologs` 和 `.emapper.pfam`
- 支持 diamond/mmseqs/hmmer 三种搜索模式
### 配置参数
| 参数 | 默认值 | 说明 |
|------|--------|------|
| mode | diamond | 搜索模式 |
| evalue | 0.001 | E-value阈值 |
| score | 60 | 最小bit score |
| query_cover | 20 | query覆盖度(%) |
| subject_cover | 20 | subject覆盖度(%) |
| tax_scope | auto | 分类范围 |
| cpu | 8 | CPU线程数 |
### 输出文件
| 文件 | 描述 |
|------|------|
| `*.emapper.annotations` | 主注释结果(TSV) |
| `*.emapper.seed_orthologs` | 种子直系同源 |
| `*.emapper.pfam` | Pfam注释 |
| `report.md` | 分析报告(含GO/KEGG/COG/Pfam统计) |
| `commands.sh` | 可复现命令 |
| `environment.yml` | Conda环境配置 |
| `checksums.sha256` | 文件校验 |
## 使用方法
### 命令行
```bash
# 基本用法
python run.py --input protein.fa --output ./annotation
# 指定参数
python run.py --input protein.fa --output ./annotation \
--prefix mygene --cpu 16 --mode diamond --evalue 0.0001
# Demo模式
python run.py --demo --output ./annotation_demo
```
### Python API
```python
from run import AnnotationSkill
skill = AnnotationSkill()
result = skill.run(
protein_fasta=Path("protein.fa"),
output_dir=Path("./annotation"),
prefix="gene_family"
)
# result["annotations"] -> Path to .emapper.annotations
# result["stats"] -> Dict with GO/KEGG/COG/Pfam counts
```
## 集成到 Registry
已在 `gfa_core/mas/tools/registry.py` 中添加:
- `TOOL_PATHS["emapper"]` 路径配置
- `ToolMetadata` 注册(category="annotation")
## 测试状态
```
$ python3 tests/test_annotation.py -v
test_find_emapper ... ok
test_parse_annotations ... ok
test_demo_mode ... ok
test_config_loading ... ok
----------------------------------------------------------------------
Ran 4 tests in 0.005s
OK
```
## 依赖要求
```bash
conda install -c bioconda eggnog-mapper diamond
```
或:
```bash
conda env create -f config.yaml # 使用技能自带配置
```
## 注意事项
1. **数据库**: 首次运行会自动下载 eggNOG 数据库到 `~/.eggnog-mapper/`
2. **内存**: 大基因组建议调整 `--block-size` 参数
3. **路径**: 自动检测常见 conda 环境中的 emapper.py
## 下一步建议
1. 在 pipeline backend 中集成此技能
2. 添加 GO enrichment 分析(基于生成的 annotations)
3. 可视化 COG 分类分布图
4. 与现有 domain-analysis 技能结果合并展示