ANARCI \ // Antibody Numbering and Antigen Receptor ClassIfication \ // || (c) Oxford Protein Informatics Group (OPIG). 2015-20 ||
本项目是ANARCI的Windows本地版本,方便在Windows环境下使用,无需pip安装。
Author: James Dunbar ([email protected]) Charlotte Deane ([email protected])
Contact: [email protected]
# 1. 安装Python依赖
pip install biopython
# 2. 直接运行(无需pip安装ANARCI)
python run_anarci.py -i input.fasta -o output.txt -s imgt
# 或使用批处理脚本
run_anarci.bat -i input.fasta -o output.txt -s imgt# 需要先设置PYTHONPATH环境变量
# Windows PowerShell:
$env:PYTHONPATH="d:\Python\ANARCI\lib\python;$env:PYTHONPATH"
# Windows CMD:
set PYTHONPATH=d:\Python\ANARCI\lib\python;%PYTHONPATH%
from anarci import anarci
sequences = [
("sequence_name", "EVQLQQSGAEVVRSGASVKLSCTASGFNIKDYYIHWVKQRPEKGLEWIGWIDPEIGDTEYVPKFQGKATMTADTSSNTAYLQLSSLTSEDTAVYYCNAGHDYDRGRFPYWGQGTLVTVSAAKTTPPSVYPLAP")
]
results = anarci(sequences, scheme="imgt", output=False)
numbering, alignment_details, hit_tables = resultsd:\Python\ANARCI\
├── bin/ # 可执行文件目录
│ ├── ANARCI # 原始ANARCI脚本
│ ├── *.exe # HMMER可执行文件(已包含)
│ ├── *.dll # HMMER依赖库(已包含)
│ ├── muscle # MUSCLE序列比对工具
│ └── muscle_macOS # macOS版本的MUSCLE
├── lib/python/anarci/ # ANARCI核心库
│ ├── __init__.py
│ ├── anarci.py # 主要功能模块
│ ├── schemes.py # 编号方案定义
│ ├── germlines.py # 种系基因数据(已包含)
│ └── dat/HMMs/ # HMM数据库文件(已包含)
│ ├── ALL.hmm
│ └── ALL.hmm.*
├── Example_scripts_and_sequences/ # 示例脚本和序列文件
│ ├── anarci_API_example.py # API使用示例
│ └── *.fasta # 示例序列文件
├── build_pipeline/ # 构建HMM数据库的脚本
├── run_anarci.py # Python启动脚本(推荐使用)
├── run_anarci.bat # 批处理启动脚本
└── README.md # 本文档
# 编号单个序列
python run_anarci.py -i EVQLQQSGAEVVRSGASVKLSCTASGFNIKDYYIHWVKQRPEKGLEWIGWIDPEIGDTEYVPKFQGKATMTADTSSNTAYLQLSSLTSEDTAVYYCNAGHDYDRGRFPYWGQGTLVTVSA
# 编号FASTA文件
python run_anarci.py -i myfile.fasta
# 使用不同编号方案
python run_anarci.py -i input.fasta -s kabat
# 输出到文件
python run_anarci.py -i input.fasta -o output.txt
# 输出CSV格式
python run_anarci.py -i input.fasta -o output.txt --csv
# 限制识别的链类型
python run_anarci.py -i input.fasta -r ig| 参数 | 简写 | 说明 | 默认值 |
|---|---|---|---|
--sequence, -i |
- | 输入序列或FASTA文件 | 必需 |
--outfile, -o |
- | 输出文件(默认stdout) | stdout |
--scheme, -s |
- | 编号方案 | imgt |
--restrict, -r |
- | 限制识别的链类型 | 全部 |
--csv |
- | 输出CSV格式 | False |
--outfile_hits, -ht |
- | 输出命中表文件 | 不输出 |
--hmmerpath, -hp |
- | HMMER工具路径 | 自动检测 |
--ncpu, -p |
- | 并行进程数 | 1 |
--assign_germline |
- | 分配种系基因 | False |
--use_species |
- | 指定物种 | human,mouse |
--bit_score_threshold |
- | 位分阈值 | 80 |
- IMGT (默认) - 128个位置,适用于所有抗原受体类型
- Chothia (仅抗体) - 重链和轻链编号不同
- Kabat (仅抗体) - 在特定位置插入,A->Z标记
- Martin / Enhanced Chothia (仅抗体) - Chothia的增强版本
- AHo - 149个位置,无需插入标记
- Wolfguy (仅抗体) - 使用数字范围,CDR上下方向编号
| 物种 | 重链 | Kappa链 | Lambda链 | Alpha链 | Beta链 |
|---|---|---|---|---|---|
| Human | ✅ | ✅ | ✅ | ✅ | ✅ |
| Mouse | ✅ | ✅ | ✅ | ✅ | ✅ |
| Rat | ✅ | ✅ | ✅ | ❌ | ❌ |
| Rabbit | ✅ | ✅ | ✅ | ❌ | ❌ |
| Pig | ✅ | ✅ | ✅ | ❌ | ❌ |
| Rhesus Monkey | ✅ | ✅ | ❌ | ❌ | ❌ |
# 1A14:H|PDBID|CHAIN|SEQUENCE
# ANARCI numbered
# Domain 1 of 1
# Most significant HMM hit
#|species|chain_type|e-value|score|seqstart_index|seqend_index|
#|mouse|H|8.6e-58|184.9|0|119|
# Scheme = imgt
H 1 Q
H 2 V
H 3 Q
...
字段说明:
species: 最显著HMM匹配的物种chain_type: 最显著HMM匹配的链类型e-value: 对齐的e值score: 对齐的位分seqstart_index: 序列中第一个编号残基的索引seqend_index: 序列中最后一个编号残基的索引Scheme: 使用的编号方案
使用--csv选项时,会为每种链类型生成单独的CSV文件:
output_H.csv- 重链output_L.csv- 轻链(Kappa和Lambda合并)output_A.csv- Alpha链output_B.csv- Beta链
包含所有HMM匹配的统计信息,即使序列未被编号:
NAME 1a14_H mol:protein length:120 NC10 FV (HEAVY CHAIN)
SEQUENCE QVQLQQSGAELVKPGASVRMSCKASGYTFTNYNMYWVKQSPGQGLEWIGIFYPGNGDTSYNQKFKDKATLT
SEQUENCE ADKSSNTAYMQLSSLTSEDSAVYYCARSGGSYRYDGGFDYWGQGTTVTV
id description evalue bitscore bias best_dom_evalue best_dom_bitscore best_dom_bias domain_exp_num domain_obs_num
mouse_H 1.1e-57 184.5 1.5 1.3e-57 184.4 1.5 1.0 1
human_H 7.8e-53 169.0 1.9 8.7e-53 168.8 1.9 1.0 1
//
本项目已配置为可跨机器运行,包含以下内容:
- HMMER工具:所有HMMER可执行文件和依赖库已包含在bin目录中
- Python代码:完整的ANARCI源代码和HMM数据库
- 启动脚本:run_anarci.py和run_anarci.bat已创建
- 无需pip安装:所有必需文件都已包含在项目中
# 1. 克隆或复制整个ANARCI项目文件夹到目标机器
git clone <repository-url> ANARCI
cd ANARCI
# 2. 在目标机器上安装Python 3.13+
# 3. 安装Biopython(唯一必需的依赖)
pip install biopython
# 4. 直接运行(无需其他配置)
python run_anarci.py -i input.fasta -o output.txt- ✅ 目标机器需要安装Python 3.13或更高版本
- ✅ 只需安装Biopython(
pip install biopython) - ✅ 无需安装ANARCI包(所有代码已包含)
- ✅ 无需安装HMMER(工具已包含在项目中)
- ✅ 启动脚本会自动处理PATH设置
- ✅ 所有HMM数据库文件已包含(无需重新构建)
- Python: 3.13+
- Biopython: 1.86+(通过
pip install biopython安装) - HMMER: 3.4+(已包含在项目中)
- 操作系统: Windows 10/11(推荐)
A: 使用--hmmerpath参数指定HMMER目录:
python run_anarci.py -i input.fasta --hmmerpath d:\Python\ANARCI\bin通常不需要,启动脚本会自动检测本地HMMER。
A: 使用--scheme参数:
python run_anarci.py -i input.fasta -s kabatA: 使用--csv参数并指定输出文件:
python run_anarci.py -i input.fasta -o output.txt --csvA: 可能的原因:
- 序列不是抗原受体(抗体或TCR)
- 序列质量太低或片段化
- 位分低于阈值(默认80) 可以尝试降低位分阈值:
python run_anarci.py -i input.fasta --bit_score_threshold 60A: 需要先设置PYTHONPATH:
import os
import sys
# 添加项目路径
sys.path.insert(0, 'd:\\Python\\ANARCI\\lib\\python')
# 导入ANARCI
from anarci import anarci
# 使用
results = anarci(sequences, scheme="imgt")项目测试已成功通过:
- ✅ Python环境检查(Python 3.13.12)
- ✅ Biopython安装检查(1.86)
- ✅ HMMER工具检查(3.4)
- ✅ 本地文件夹完整性检查(包含所有必需文件)
- ✅ ANARCI功能测试(示例脚本运行成功)
- ✅ 本地HMMER配置(可执行文件已复制)
- ✅ 独立运行测试(无需pip安装ANARCI)
# 检查Python版本
python --version
# 检查Biopython安装
python -c "import Bio; print(Bio.__version__)"
# 检查HMMER工具
python run_anarci.py -h# 方法1:使用Python启动脚本(推荐)
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta
# 方法2:使用批处理脚本
run_anarci.bat -i Example_scripts_and_sequences/12e8.fasta
# 方法3:使用Python API
python Example_scripts_and_sequences/anarci_API_example.pyimport sys
import os
# 添加项目路径
sys.path.insert(0, 'd:\\Python\\ANARCI\\lib\\python')
from anarci import anarci
# 测试单个序列
test_sequence = ("test_seq", "EVQLQQSGAEVVRSGASVKLSCTASGFNIKDYYIHWVKQRPEKGLEWIGWIDPEIGDTEYVPKFQGKATMTADTSSNTAYLQLSSLTSEDTAVYYCNAGHDYDRGRFPYWGQGTLVTVSA")
print("测试单个序列编号...")
results = anarci([test_sequence], scheme="imgt", output=False)
numbering, alignment_details, hit_tables = results
if numbering[0] is not None:
print("✅ 测试成功!")
print(f"识别为: {alignment_details[0]['species']} {alignment_details[0]['chain_type']}链")
else:
print("❌ 测试失败!")
# 测试多个序列
test_sequences = [
("seq1", "EVQLQQSGAEVVRSGASVKLSCTASGFNIKDYYIHWVKQRPEKGLEWIGWIDPEIGDTEYVPKFQGKATMTADTSSNTAYLQLSSLTSEDTAVYYCNAGHDYDRGRFPYWGQGTLVTVSA"),
("seq2", "DIVMTQSQKFMSTSVGDRVSITCKASQNVGTAVAWYQQKPGQSPKLMIYSASNRYTGVPDRFTGSGSGTDFTLTISNMQSEDLADYFCQQYSSYPLTFGAGTKLELKRADAAPTVSIFPPSSEQLTSGGASV")
]
print("\n测试多个序列编号...")
results = anarci(test_sequences, scheme="imgt", output=False)
numbering, alignment_details, hit_tables = results
success_count = sum(1 for n in numbering if n is not None)
print(f"✅ 成功编号 {success_count}/{len(test_sequences)} 个序列")# 测试不同编号方案
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -s kabat
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -s chothia
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -s martin
# 测试输出到文件
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -o test_output.txt
# 测试CSV输出
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -o test_output --csv
# 测试限制链类型
python run_anarci.py -i Example_scripts_and_sequences/12e8.fasta -r ig# 测试HMMER工具是否正常工作
d:\Python\ANARCI\bin\hmmscan.exe -h
# 测试HMMER版本
d:\Python\ANARCI\bin\hmmscan.exe --version如果需要更新IMGT数据并重新构建HMM数据库:
cd build_pipeline
# 1. 下载IMGT数据(自动)
python RipIMGT.py
# 2. 格式化比对
python FormatAlignments.py
# 3. 构建HMM模型
hmmbuild --hand HMMs/ALL.hmm curated_alignments/ALL.stockholm
# 4. 压缩HMM模型
hmmpress -f HMMs/ALL.hmm
# 5. 复制到项目目录
copy HMMs\ALL.hmm* ..\lib\python\anarci\dat\HMMs\
copy curated_alignments\germlines.py ..\lib\python\anarci\注意:这些文件(IMGT_sequence_files/, muscle_alignments/, curated_alignments/, HMMs/)已在.gitignore中,不会被提交到版本控制,因为可以随时重新生成。
BSD 3-Clause License
Copyright (C) 2017 Oxford Protein Informatics Group (OPIG) Freely distributed under the BSD 3-Clause Licence.
- 作者: James Dunbar ([email protected])
- 作者: Charlotte Deane ([email protected])
- 联系: [email protected]
- 网站: http://opig.stats.ox.ac.uk/webapps/ANARCI# ANARCI_Win