MCP名称
使用RNAMotif工具搜索和分析RNA二级结构基序的模型上下文协议服务器
目录
概述
rnamotif MCP通过直接脚本使用和模型上下文协议(MCP)集成提供对RNA二级结构搜索和分析工具的访问。它能够在RNA序列中搜索特定的RNA基序,如tRNA三叶草、铁反应元件(IRE)、假结和发夹。
特性
- tRNA搜索:查找转移RNA三叶叶二级结构模式
- IRE搜索:搜索带有评分的铁反应元素茎环图案
- 伪结搜索:检测具有交叉碱基对的假结结构
- 发夹搜索:查找具有茎和环区域的发夹结构
- 结果格式:使用rmfmt、rmprune、rm2ct处理和格式化搜索结果
- 批处理:处理多个文件和全面的分析工作流程
- MCP集成:与Claude Code、Gemini CLI和其他MCP客户端一起使用
目录结构
./
├── README.md # This file
├── env/ # Conda environment (Python 3.10)
├── src/
│ └── server.py # MCP server with 15 tools
├── scripts/
│ ├── trna_search.py # tRNA motif search
│ ├── ire_search.py # IRE motif search with scoring
│ ├── pseudoknot_search.py# Pseudoknot structure search
│ ├── hairpin_search.py # Hairpin structure search
│ ├── format_results.py # Results formatting and processing
│ ├── comprehensive_search.py # Combined analysis workflows
│ └── lib/ # Shared utilities
├── examples/
│ └── data/ # Demo RNA sequences and descriptors
├── configs/ # Configuration files
├── repo/ # Original RNAMotif repository
└── reports/ # Step reports and documentation______________________________________________________________________
安装
先决条件
- Conda或Mamba(建议使用曼巴以加快安装速度)
- Python 3.10+
- GCC编译器(用于构建RNAMotif C工具)
创建环境
# Navigate to the MCP directory
cd /home/xux/Desktop/NucleicMCP/NucleicMCP/tool-mcps/rnamotif_mcp
# Create conda environment (use mamba if available)
mamba create -p ./env python=3.10 -y
# or: conda create -p ./env python=3.10 -y
# Activate environment
mamba activate ./env
# or: conda activate ./env安装依赖项
# Install MCP dependencies
pip install fastmcp loguru click pandas numpy tqdm
# Build RNAMotif C tools (if not already built)
cd repo/rnamotif
make
cd ../..______________________________________________________________________
本地使用(脚本)
您可以在没有MCP的情况下直接使用脚本进行本地处理。
可用脚本
| 脚本 | 描述 | 示例 |
|---|---|---|
scripts/trna_search.py | 搜索tRNA苜蓿叶状结构 | 见下文 |
scripts/ire_search.py | 搜索带有评分的IRE图案 | 见下文 |
scripts/pseudoknot_search.py | 搜索伪结结构 | 见下文 |
scripts/hairpin_search.py | 搜索发夹结构 | 见下文 |
scripts/format_results.py | 格式化和处理搜索结果 | 见下文 |
scripts/comprehensive_search.py | 组合分析工作流程 | 见下文 |
脚本示例
tRNA搜索
# Activate environment
mamba activate ./env
# Basic tRNA search
python scripts/trna_search.py \
--input examples/data/ecoli_test.fastn \
--output results/trna_output.txt \
--verbose
# Using alternative descriptor for better matches
python scripts/trna_search.py \
--input examples/data/ecoli_test.fastn \
--descriptor trna.general.descr \
--output results/trna_general.txt参数:
--input, -i:输入带有RNA序列的FASTA文件(必填)--output, -o:结果输出文件(默认:打印到stdout)--descriptor:描述符文件名(默认值:trna.descr)--strict:使用严格搜索模式--verbose, -v:启用详细输出
IRE搜索
# IRE search with scoring
python scripts/ire_search.py \
--input examples/data/ecoli_test.fastn \
--min-score 0.5 \
--max-results 10 \
--output results/ire_scored.txt \
--verbose参数:
--input, -i:输入FASTA文件(必填)--min-score:最低分数阈值0.0-1.0(默认值:0.0)--max-results:最大结果数(默认值:无限制)--output, -o:结果输出文件--verbose, -v:启用详细输出
格式化结果
# Format results for viewing
python scripts/format_results.py rmfmt results.txt \
--format view \
--output formatted_view.txt \
--verbose
# Prune redundant results
python scripts/format_results.py rmprune results.txt \
--output pruned_results.txt
# Convert to CT format
python scripts/format_results.py rm2ct results.txt \
--output structures.ct参数:
tool:工具名称(rmfmt、rmprune、rm2ct)(必填)input_file:要处理的RNAMotif输出文件(必需)--format:rmfmt的格式类型(视图、对齐、两者)--sort-max:用于排序的最大内存(MB)--output, -o:结果输出文件--verbose, -v:启用详细输出
______________________________________________________________________
MCP服务器安装
选项1:使用fastmcp(推荐)
# Install MCP server for Claude Code
fastmcp install src/server.py --name rnamotif选项2:Claude代码的手动安装
# Add MCP server to Claude Code
claude mcp add rnamotif -- $(pwd)/env/bin/python $(pwd)/src/server.py
# Verify installation
claude mcp list选项3:在settings.json中配置
增添 ~/.claude/settings.json:
{
"mcpServers": {
"rnamotif": {
"command": "/home/xux/Desktop/NucleicMCP/NucleicMCP/tool-mcps/rnamotif_mcp/env/bin/python",
"args": ["/home/xux/Desktop/NucleicMCP/NucleicMCP/tool-mcps/rnamotif_mcp/src/server.py"]
}
}
}______________________________________________________________________
使用Claude代码
安装MCP服务器后,您可以直接在Claude Code中使用它。
快速开始
# Start Claude Code
claude示例提示
工具发现
What tools are available from rnamotif?基本用法
Use search_trna_motifs with input_file @examples/data/ecoli_test.fastn and descriptor "trna.general.descr"与评分
Use search_ire_motifs on @examples/data/ecoli_test.fastn with min_score 0.5 and max_results 10格式化结果
Use format_search_results with tool "rmfmt", input_file @results/trna_output.txt, and format_type "view"长期运行任务(提交API)
Submit comprehensive motif search for @examples/data/ecoli_large.fastn
Then check the job status批处理
Process these files in batch for tRNA motifs:
- @examples/data/ecoli_test.fastn
- @examples/data/ecoli_small.fastn
- @examples/data/test_sequences.fastn使用@引用
在克劳德代码中,使用 @ 引用文件和目录:
| 参考 | 说明 |
|---|---|
@examples/data/ecoli_test.fastn | 参考特定的FASTA文件 |
@configs/trna_search_config.json | 引用配置文件 |
@results/ | 参考输出目录 |
______________________________________________________________________
与Gemini CLI一起使用
配置
增添 ~/.gemini/settings.json:
{
"mcpServers": {
"rnamotif": {
"command": "/home/xux/Desktop/NucleicMCP/NucleicMCP/tool-mcps/rnamotif_mcp/env/bin/python",
"args": ["/home/xux/Desktop/NucleicMCP/NucleicMCP/tool-mcps/rnamotif_mcp/src/server.py"]
}
}
}示例提示
# Start Gemini CLI
gemini
# Example prompts (same as Claude Code)
> What tools are available?
> Use search_trna_motifs with file examples/data/ecoli_test.fastn______________________________________________________________________
可用工具
快速操作(同步API)
这些工具会立即返回结果(\10分钟或批处理):
| 工具 | 说明 | 参数 |
|---|---|---|
submit_batch_trna_search | 批量tRNA搜索多个文件 | input_files, descriptor, output_dir, job_name |
submit_batch_ire_search | 批量IRE搜索多个文件 | input_files, min_score, max_results, output_dir, job_name |
submit_batch_pseudoknot_search | 批量伪结搜索 | input_files, pk_type, output_dir, job_name |
submit_batch_hairpin_search | 批量发夹搜索 | input_files, hairpin_type, output_dir, job_name |
submit_comprehensive_motif_search | 在一个文件上运行所有搜索类型 | input_file, search_types, output_dir, job_name |
作业管理工具
| 工具 | 说明 |
|---|---|
get_job_status | 检查作业进度和状态 |
get_job_result | 完成后获取结果 |
get_job_log | 查看执行日志 |
cancel_job | 取消正在运行的作业 |
list_jobs | 列出所有具有可选筛选的作业 |
______________________________________________________________________
例子
示例1:tRNA分析
目标: 在大肠杆菌序列中发现tRNA苜蓿叶状结构
使用脚本:
python scripts/trna_search.py \
--input examples/data/ecoli_test.fastn \
--descriptor trna.general.descr \
--output results/ecoli_trna/ \
--verbose使用MCP(克劳德代码):
Use search_trna_motifs to process @examples/data/ecoli_test.fastn with descriptor "trna.general.descr" and save results to results/ecoli_trna/预期产量:
- tRNA与结构注释匹配
- 三叶草次生结构模式
- 匹配位置和信心得分
示例2:IRE主题发现
目标: 查找得分较高的铁反应元素
使用脚本:
python scripts/ire_search.py \
--input examples/data/ecoli_test.fastn \
--min-score 0.5 \
--max-results 20 \
--output results/ire_analysis.txt \
--verbose使用MCP(克劳德代码):
Run search_ire_motifs on @examples/data/ecoli_test.fastn with min_score 0.5 and max_results 20预期产量:
- 具有质量分数的IRE茎环结构
- 筛选结果高于最小阈值
- 分数分布统计
示例3:综合主题分析
目标: 在序列集上运行所有搜索类型
使用脚本:
python scripts/comprehensive_search.py \
--input examples/data/test_sequences.fastn \
--search-types trna ire pseudoknot hairpin \
--output results/comprehensive/使用MCP(克劳德代码):
Submit comprehensive motif search for @examples/data/test_sequences.fastn with all search types预期产量:
- 所有主题搜索算法的结果
- 不同母题类型的比较分析
- 摘要统计和可视化
示例4:批处理
目标: 一次处理多个文件
使用脚本:
for f in examples/data/*.fastn; do
python scripts/trna_search.py --input "$f" --output results/batch/
done使用MCP(克劳德代码):
Submit batch tRNA search for all FASTA files in @examples/data/预期产量:
- 每个输入文件的结果
- 所有文件的聚合统计信息
- 作业跟踪和进度监控
工作流示例
快速分析(同步API)
1. Use search_trna_motifs with input_file "examples/data/ecoli_test.fastn"
→ Returns: {"status": "success", "result": {...}, "metadata": {...}}
2. Use format_search_results with tool "rmfmt" and input_file from step 1
→ Returns: Formatted view of tRNA matches长期运行批处理作业(提交API)
1. Submit: Use submit_batch_trna_search with input_files ["file1.fastn", "file2.fastn", "file3.fastn"]
→ Returns: {"job_id": "abc123", "status": "submitted"}
2. Check: Use get_job_status with job_id "abc123"
→ Returns: {"status": "running", "job_id": "abc123", ...}
3. Monitor: Use get_job_log with job_id "abc123"
→ Returns: {"log_lines": ["Processing file1.fastn...", ...]}
4. Result: Use get_job_result with job_id "abc123"
→ Returns: {"status": "success", "result": {...}} when completed综合分析
1. Submit: Use submit_comprehensive_motif_search with input_file "large_genome.fastn"
→ Returns: {"job_id": "xyz789", "status": "submitted"}
2. Monitor: Use get_job_status with job_id "xyz789" (check periodically)
→ Returns: Status updates as each search completes
3. Result: Use get_job_result with job_id "xyz789"
→ Returns: Complete analysis with all motif types found______________________________________________________________________
演示数据
这 examples/data/ 目录包含用于测试的示例数据:
| 文件 | 描述 | 使用 | 大小 |
|---|---|---|---|
ecoli_test.fastn | 用于快速检测的小型大肠杆菌序列 | 所有搜索工具 | ~50KB |
ecoli_small.fastn | 中等大小的大肠杆菌序列 | 批量测试 | ~3MB |
ecoli_large.fastn | 大型大肠杆菌序列集 | 提交API检测 | ~5.6MB |
ecoli_genome.fastn | 完整的大肠杆菌基因组序列 | 综合分析 | ~5.6MB |
test_sequences.fastn | 一般测试序列 | 快速验证 | ~1KB |
sample_sequences.fastn | GenBank RNA序列 | 常规检测 | ~2.6MB |
*.descr | 主题定义的描述符文件 | 搜索配置 | 各种 |
______________________________________________________________________
配置文件
这 configs/ 目录包含配置模板:
| 配置 | 描述 | 参数 |
|---|---|---|
default_config.json | 所有脚本的基本设置 | 常见超时、路径、验证 |
trna_search_config.json | tRNA特定设置 | 描述符选项、性能说明 |
ire_search_config.json | IRE特定设置 | 评分参数、过滤选项 |
pseudoknot_search_config.json | 伪结设置 | 类型映射,复杂性注释 |
hairpin_search_config.json | 发夹设置 | 类型描述、评分变体 |
format_results_config.json | 格式化工具设置 | 工具参数、工作流建议 |
配置示例
{
"timeout": 300,
"max_filesize_mb": 100,
"descriptor_search_paths": [
"examples/data/",
"repo/rnamotif/test/",
"repo/rnamotif/descr/",
"repo/rnamotif/Ecoli.trna.example/"
],
"output_format": "text",
"verbose": false
}______________________________________________________________________
故障排除
环境问题
问题: 未找到环境
# Recreate environment
mamba create -p ./env python=3.10 -y
mamba activate ./env
pip install fastmcp loguru click pandas numpy tqdm问题: 导入错误
# Verify installation
python -c "from src.server import mcp"问题: 未找到RNAMotif工具
# Rebuild C tools
cd repo/rnamotif
make clean && make
cd ../..MCP问题
问题: 在Claude代码中找不到服务器
# Check MCP registration
claude mcp list
# Re-add if needed
claude mcp remove rnamotif
claude mcp add rnamotif -- $(pwd)/env/bin/python $(pwd)/src/server.py问题: 工具不工作
# Test server directly
mamba run -p ./env python -c "
from src.server import mcp
print('Server loaded successfully')
"工作问题
问题: 作业挂起
# Check job directory
ls -la jobs/
# View job log
Use get_job_log with job_id "" to see details问题: 作业失败
# Check logs for error details
Use get_job_log with job_id "" and tail 100 to see error details常见错误消息
“找不到文件”:检查输入文件路径是否正确以及文件是否存在 “描述符无效”:确保描述符文件存在于搜索路径中 “超时”:大型文件可能需要提交API,而不是同步API “FASTA格式无效”:验证输入文件是否包含有效的RNA/DNA序列
______________________________________________________________________
发展
运行测试
# Activate environment
mamba activate ./env
# Test individual scripts
python scripts/trna_search.py --help
python scripts/trna_search.py --input examples/data/ecoli_test.fastn --verbose
# Test MCP server
mamba run -p ./env fastmcp dev src/server.py正在启动开发服务器
# Run MCP server in development mode
fastmcp dev src/server.py使用Claude代码进行测试
# Add development server
claude mcp add rnamotif-dev -- $(pwd)/env/bin/python $(pwd)/src/server.py
# Test tools
claude
# Then: "What tools are available from rnamotif?"______________________________________________________________________
业绩说明
预期执行时间
- 小文件 (\1000个序列):使用submit API进行后台处理
内存使用
- 典型用法:每次搜索40-50MB
- 大型数据集:高达200MB
- 环境:总计约1.2GB
优化提示
- 使用特定的描述符(例如“trna.general.descr”)以获得更好的性能
- 为IRE搜索设置合理的min_score值以减少结果
- 对多个文件使用批处理操作以利用并行化
- 监控作业日志,了解长时间运行的任务的进度更新
______________________________________________________________________
许可证
基于 Rnamotif David A.Case等人。
学分
- Rnamotif:原始的基于C的RNA二级结构搜索工具
- FastMCP:用于工具集成的模型上下文协议框架
- NucleicMCP:核酸序列分析工具的综合套件
