罗塞塔KIC MCP
使用Rosetta KIC和GeneralizedKIC协议进行环肽计算分析的MCP工具
目录
概述
该MCP使用Rosetta的运动学闭合(KIC)和GeneralizedKIC协议为环肽建模提供了计算工具。它通过独立脚本和MCP服务器界面实现了环肽的3D结构预测、肽环化、环建模和构象分析。
特性
- 环肽闭合 使用广义KIC算法
- 三维结构预测 从氨基酸序列
- 灵活的回路建模 蒙特卡洛抽样
- 批量处理 用于虚拟筛选工作流程
- 结构验证 质量评估
- 作业管理 用于长时间运行的计算
安装
快速设置
运行自动安装脚本:
./quick_setup.sh这将创建环境并自动安装所有依赖项。
手动设置(高级)
对于手动安装或自定义,请执行以下步骤。
先决条件
- Conda或Mamba(建议使用曼巴以加快安装速度)
- Python 3.10+
- RDKit(自动安装)
- 可选:PyRosetta实现完整的Rosetta功能
创建环境
根据环境设置 reports/step3_environment.md:
# Navigate to the MCP directory
cd /home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/rosetta_kic_mcp
# Create conda environment (use mamba if available)
mamba create -p ./env python=3.12 pip numpy pandas -y
# or: conda create -p ./env python=3.12 pip numpy pandas -y
# Activate environment
mamba activate ./env
# or: conda activate ./env
# Install core scientific packages
mamba install -p ./env -c conda-forge rdkit -y
mamba install -p ./env -c conda-forge biopython -y
# Install Python utilities
mamba run -p ./env pip install loguru click tqdm
# Install MCP framework
mamba run -p ./env pip install fastmcp
# Install PyRosetta
pip install pyrosetta --find-links https://west.rosettacommons.org/pyrosetta/quarterly/release______________________________________________________________________
本地使用(脚本)
您可以在没有MCP的情况下直接使用脚本进行本地处理。
可用脚本
| 脚本 | 描述 | 示例 |
|---|---|---|
scripts/cyclic_peptide_closure.py | 使用GeneralizedKIC将线性肽闭合成环状结构 | 见下文 |
scripts/structure_prediction.py | 从氨基酸序列预测3D结构 | 见下文 |
scripts/loop_modeling.py | 使用运动学闭合对柔性环进行建模 | 见下文 |
脚本示例
环肽闭合
# Activate environment
mamba activate ./env
# Run peptide closure
mamba run -p ./env python scripts/cyclic_peptide_closure.py \
--input examples/data/structures/linear_peptide_sample.pdb \
--length 6 \
--nstruct 5 \
--output results/closed_peptides参数:
--input, -i:输入含有线性肽的PDB文件(必填)--length, -l:闭合的最大循环长度(默认值:6)--nstruct, -n:要生成的循环结构的数量(默认值:5)--resn, -r:用于扩展的残留物类型(默认值:GLY)--output, -o:输出目录(默认:results/)
结构预测
mamba run -p ./env python scripts/structure_prediction.py \
--sequence "GRGDSP" \
--output_dir results/structures \
--nstruct 10 \
--runtime 900参数:
--sequence, -s:氨基酸序列(一个字母代码,必填)--output_dir, -o:输出目录(默认:results/)--nstruct:要生成的结构数量(默认值:10)--runtime:最大运行时间(秒)(默认值:900)
回路建模
mamba run -p ./env python scripts/loop_modeling.py \
--input examples/data/structures/test_in.pdb \
--loop_start 10 \
--loop_end 20 \
--output results/loop_models参数:
--input, -i:输入PDB结构文件(必填)--loop_start:起始残渣编号(必填)--loop_end:结束残留物编号(必填)--loop_cut:闭合切割点(可选)--outer_cycles:蒙特卡洛外循环(默认值:10)--inner_cycles:蒙特卡洛内部循环(默认值:30)
______________________________________________________________________
MCP服务器安装
选项1:使用fastmcp(推荐)
# Install MCP server for Claude Code
fastmcp install src/server.py --name rosetta-kic-mcp选项2:Claude代码的手动安装
# Add MCP server to Claude Code
claude mcp add rosetta-kic-mcp -- $(pwd)/env/bin/python $(pwd)/src/server.py
# Verify installation
claude mcp list选项3:在settings.json中配置
添加到 ~/.claude/settings.json:
{
"mcpServers": {
"rosetta-kic-mcp": {
"command": "/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/rosetta_kic_mcp/env/bin/python",
"args": ["/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/rosetta_kic_mcp/src/server.py"]
}
}
}______________________________________________________________________
使用Claude代码
安装MCP服务器后,您可以直接在Claude Code中使用它。
快速开始
# Start Claude Code
claude示例提示
工具发现
What tools are available from rosetta-kic-mcp?结构验证(快速)
Validate this peptide structure file: @examples/data/structures/linear_peptide_sample.pdb结构预测(提交API)
Submit a 3D structure prediction job for the sequence GRGDSP with 10 structures and 15 minute runtime肽封闭(提交API)
Close this linear peptide into a cyclic structure: @examples/data/structures/linear_peptide_sample.pdb
Use 5 structures and GLY residues for closure检查作业状态
Check the status of job abc12345批处理
Submit batch structure prediction for these sequences from @examples/data/sequences/sample_cyclic_peptide.txt:
- Generate 5 structures per sequence
- Set runtime to 10 minutes per sequence使用@引用
在克劳德代码中,使用 @ 引用文件和目录:
| 参考 | 说明 |
|---|---|
@examples/data/sequences/sample_cyclic_peptide.txt | 引用序列文件 |
@examples/data/structures/linear_peptide_sample.pdb | 引用结构文件 |
@configs/default_config.json | 引用配置文件 |
@results/ | 参考输出目录 |
______________________________________________________________________
与Gemini CLI一起使用
配置
添加到 ~/.gemini/settings.json:
{
"mcpServers": {
"rosetta-kic-mcp": {
"command": "/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/rosetta_kic_mcp/env/bin/python",
"args": ["/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/rosetta_kic_mcp/src/server.py"]
}
}
}示例提示
# Start Gemini CLI
gemini
# Example prompts (same as Claude Code)
> What tools are available?
> Validate peptide sequence GRGDSP
> Submit structure prediction for cyclic peptide CRGDSC______________________________________________________________________
可用工具
快速操作(同步API)
这些工具会立即返回结果(\10分钟):
| 工具 | 说明 | 参数 |
|---|---|---|
submit_cyclic_peptide_closure | 将线性肽闭合成循环 | input_file, length, nstruct, residue_type, job_name |
submit_structure_prediction | 从序列预测三维结构 | sequence, nstruct, runtime, use_mpi, job_name |
submit_loop_modeling | 使用KIC对柔性回路进行建模 | input_file, loop_start, loop_end, loop_cut, outer_cycles, inner_cycles, fast_mode, job_name |
submit_batch_cyclic_closure | 批量肽封闭 | input_files, length, nstruct, residue_type, job_name |
submit_batch_structure_prediction | 批量结构预测 | sequences, nstruct, runtime, job_name |
作业管理工具
| 工具 | 说明 |
|---|---|
get_job_status | 检查作业进度和状态 |
get_job_result | 完成后获取结果 |
get_job_log | 查看执行日志 |
cancel_job | 取消正在运行的作业 |
list_jobs | 列出所有具有筛选功能的作业 |
cleanup_old_jobs | 清理已完成的旧工作 |
______________________________________________________________________
例子
示例1:快速结构验证
目标: 在昂贵的计算之前验证肽结构
使用脚本:
# Check structure file format
mamba run -p ./env python scripts/cyclic_peptide_closure.py \
--input examples/data/structures/linear_peptide_sample.pdb \
--validate_only使用MCP(克劳德代码):
Validate this peptide structure: @examples/data/structures/linear_peptide_sample.pdb预期产量:
- 结构验证结果
- 链信息、残留物计数
- 基本几何检查
实施例2:环肽闭合
目标: 将线性肽闭合成环状结构
使用脚本:
mamba run -p ./env python scripts/cyclic_peptide_closure.py \
--input examples/data/structures/linear_peptide_sample.pdb \
--length 6 \
--nstruct 5 \
--output results/closure_test使用MCP(克劳德代码):
Close this linear peptide into a cyclic structure: @examples/data/structures/linear_peptide_sample.pdb
Use these parameters:
- Maximum loop length: 6
- Number of structures: 5
- Residue type for closure: GLY
- Job name: "closure_demo"
Check the job status and show me the results when complete.示例3:基于序列的结构预测
目标: 为环肽序列生成3D构象
使用脚本:
mamba run -p ./env python scripts/structure_prediction.py \
--sequence "GRGDSP" \
--nstruct 10 \
--runtime 900 \
--output_dir results/grgdsp_prediction使用MCP(克劳德代码):
Predict 3D structures for the cyclic peptide sequence GRGDSP:
- Generate 10 structures
- Set runtime limit to 15 minutes
- Name the job "grgdsp_prediction"
Monitor the progress and analyze the results when finished.示例4:批量虚拟筛选
目标: 筛选多个环肽序列进行结构分析
使用MCP(克劳德代码):
I want to screen these cyclic peptide sequences for structural diversity:
Read the sequences from @examples/data/sequences/sample_cyclic_peptide.txt and the other sequence files in that directory.
For each sequence:
1. First validate the sequence format
2. Submit structure prediction with 5 conformers each
3. Set runtime to 10 minutes per sequence
4. Name the batch job "diversity_screen"
Track all jobs and summarize the results when complete.______________________________________________________________________
演示数据
这 examples/data/ 目录包含用于测试的示例数据:
序列
| 文件 | 描述 | 内容 |
|---|---|---|
sequences/sample_cyclic_peptide.txt | 碱性环肽 | |
sequences/sample_cyclic_hexapeptide.txt | 半胱氨酸环化肽 | |
sequences/sample_longer_peptide.txt | 10残基肽 | GRGDSPKGAC |
结构
| 文件 | 描述 | 与一起使用 |
|---|---|---|
structures/linear_peptide_sample.pdb | 线性五肽GRGDS | submit_cyclic_peptide_closure |
structures/cyclic_pep_with_link.pdb | 具有声明键的环肽 | 验证工具 |
structures/test_in.pdb | 测试蛋白质结构 | submit_loop_modeling |
structures/2cpl_min.pdb | 最小化环肽 | 验证工具 |
structures/demo_peptide.pdb | 演示结构 | 所有工具 |
______________________________________________________________________
配置文件
这 configs/ 目录包含配置模板:
| 配置 | 描述 | 参数 |
|---|---|---|
default_config.json | 共享默认设置 | 常规、验证、性能 |
cyclic_peptide_closure_config.json | 肽闭合参数 | KIC设置,采样 |
structure_prediction_config.json | 结构预测设置 | 一致性、优化 |
loop_modeling_config.json | 回路建模参数 | MC循环,采样 |
配置示例
自 configs/default_config.json:
{
"general": {
"output_format": "auto",
"verbose": true,
"create_backups": false
},
"validation": {
"sequence_min_length": 3,
"sequence_max_length": 50,
"validate_inputs": true
},
"performance": {
"max_memory_gb": 8,
"timeout_seconds": 3600,
"checkpoint_interval": 100
}
}______________________________________________________________________
故障排除
环境问题
问题: 未找到环境
# Recreate environment
mamba create -p ./env python=3.12 pip numpy pandas -y
mamba activate ./env
mamba install -p ./env -c conda-forge rdkit biopython -y
mamba run -p ./env pip install loguru click tqdm fastmcp问题: RDKit导入错误
# Install RDKit from conda-forge
mamba install -p ./env -c conda-forge rdkit -y问题: 导入错误
# Verify installation
mamba run -p ./env python -c "import rdkit; print('RDKit:', rdkit.__version__)"
mamba run -p ./env python -c "import fastmcp; print('FastMCP working')"
mamba run -p ./env python -c "from src.server import mcp; print('Server imports working')"MCP问题
问题: 在Claude代码中找不到服务器
# Check MCP registration
claude mcp list
# Re-add if needed
claude mcp remove rosetta-kic-mcp
fastmcp install src/server.py --name rosetta-kic-mcp问题: 无效序列错误
Ensure your amino acid sequence uses standard single-letter codes (ACDEFGHIKLMNPQRSTVWY).
For cyclic peptides, the sequence represents the linear order before cyclization.问题: 工具不工作
# Test server directly
mamba run -p ./env python src/server.py工作问题
问题: 作业挂起
# Check job directory
ls -la jobs/
# View job logs through MCP
# Use get_job_log tool with job_id问题: 任务失败
Use get_job_log with job_id and tail 100 to see error details.
Common causes:
- Invalid input file paths
- Insufficient disk space
- Memory limitations
- Missing PyRosetta installation问题: PyRosetta不可用
Scripts run in demo mode when PyRosetta is not available.
For full functionality, install PyRosetta from Rosetta Commons.
Demo mode generates realistic example outputs for testing.结构问题
问题: PDB验证失败
Check that your PDB file:
- Uses standard PDB format
- Contains valid amino acid residues
- Has proper chain identifiers
- Is readable and not corrupted问题: 关闭失败
For peptide closure:
- Ensure termini are properly positioned
- Check for reasonable loop length (3-20 residues)
- Verify input peptide is linear (not already cyclic)
- Consider adjusting closure parameters调试工具
validate_peptide_structure():预验证PDB文件validate_peptide_sequence():预验证序列get_job_log():使用tail参数查看执行日志get_job_status():检查运行时间和进度信息get_server_info():验证服务器功能
______________________________________________________________________
发展
运行测试
# Activate environment
mamba activate ./env
# Run basic tests
mamba run -p ./env python test_simple.py
# Run MCP tests
mamba run -p ./env python test_mcp.py正在启动开发服务器
# Run MCP server in dev mode
mamba run -p ./env fastmcp dev src/server.py
# Or run directly
mamba run -p ./env python src/server.py添加新工具
要添加新的计算工具,请执行以下操作:
- 将脚本添加到
scripts/目录 - 在中创建submit\_\*工具
src/server.py - 遵循既定的作业管理模式
- 如果需要,添加验证功能
- 更新文档
______________________________________________________________________
业绩说明
运行时间估计
| 操作 | 典型运行时间 | 因素 | |
|---|---|---|---|
| 结构验证 | \15 AA) | >500 MB | >100 MB |
优化提示
- 使用
validate_*在昂贵的计算之前使用工具 - 从小处着手
nstruct测试值 - 监控作业日志以获取进度更新
- 定期清理旧工作
cleanup_old_jobs - 考虑对多个类似任务进行批处理
______________________________________________________________________
科学应用
用例
- 环肽设计
- 将线性设计封闭为稳定的循环 - 优化主干结构 - 验证环化可行性
- 虚拟筛选
- 分批处理肽库 - 比较结构预测 - 按构象灵活性过滤
- 回路工程
- 模型柔性绑定区域 - 优化回路结构 - 研究构象动力学
输出分析
- 能量分析:罗塞塔能源组件和总分
- 几何验证:粘合长度、角度和碰撞
- RMSD指标:结构相似性度量
- 构象采样:多样性和覆盖范围分析
______________________________________________________________________
许可证
基于Rosetta分子建模软件。请参阅原始Rosetta许可条款,了解学术和商业使用限制。
学分
基于 罗塞塔 RosettaCommons的分子建模软件。
从以下位置实现计算协议:
- 用于肽闭合的通用KIC
- simple_cycpep_结构预测指令
- 回路建模的运动学闭合
