Pharmapp MCP
环肽计算分析的MCP工具-渗透性预测和分子描述符计算
目录
概述
此MCP(模型上下文协议)服务器基于PharmApp框架为环肽分析提供计算工具。它为药物发现管道中常用的分子特性计算、渗透性预测和批量分析工作流提供同步和异步API。
特性
- 分子描述符计算 使用RDKit检测环肽
- 渗透率预测 使用5种PharmPapp模型(RRCK-C、PAMPA-C、Caco2-L/C/A)
- 批次分析 具有多模型比较和共识预测
- 作业管理 用于具有实时监控的长时间运行的计算
- 无缝LLM集成 通过标准化的MCP协议
目录结构
./
├── README.md # This file
├── env/ # Conda environment
├── src/
│ └── server.py # MCP server with 13 tools
├── scripts/
│ ├── calculate_descriptors.py # Molecular descriptor calculation
│ ├── predict_permeability.py # Permeability prediction
│ ├── batch_analysis.py # Multi-model comparison
│ └── lib/ # Shared utilities (18 functions)
├── examples/
│ └── data/ # Demo data
│ ├── demo_cyclic_peptides.smi # Sample cyclic peptide SMILES
│ ├── example for Caco2_A.csv # Model training data (10 molecules)
│ ├── example for Caco2_C.csv # Model training data (10 molecules)
│ ├── example for Caco2_L.csv # Model training data (10 molecules)
│ ├── example for PAMPA-C.csv # Model training data (10 molecules)
│ └── example for RRCK-C.csv # Model training data (10 molecules)
├── configs/ # Configuration files
│ ├── calculate_descriptors_config.json
│ ├── predict_permeability_config.json
│ ├── batch_analysis_config.json
│ └── default_config.json
└── repo/ # Original PharmPapp repository______________________________________________________________________
安装
快速设置
运行自动安装脚本:
./quick_setup.sh这将创建环境并自动安装所有依赖项。
手动设置(高级)
对于手动安装或自定义,请执行以下步骤。
先决条件
- Conda或Mamba(建议使用曼巴以加快安装速度)
- Python 3.10+
- RDKit(通过conda forge自动安装)
创建环境
请按照以下程序操作 reports/step3_environment.md推荐的工作流程如下:
# Navigate to the MCP directory
cd /home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/pharmpapp_mcp
# Check for package manager preference
if command -v mamba &> /dev/null; then
PKG_MGR="mamba"
else
PKG_MGR="conda"
fi
echo "Using package manager: $PKG_MGR"
# 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 scientific computing dependencies
mamba run -p ./env pip install pandas numpy scikit-learn matplotlib seaborn tqdm loguru click
# Install RDKit from conda-forge (essential for molecular work)
mamba install -p ./env -c conda-forge rdkit -y
# Install MCP dependencies
mamba run -p ./env pip install --force-reinstall --no-cache-dir fastmcp______________________________________________________________________
本地使用(脚本)
您可以在没有MCP的情况下直接使用脚本进行本地处理。
可用脚本
| 脚本 | 描述 | 示例 |
|---|---|---|
scripts/calculate_descriptors.py | 根据SMILES/SDF计算分子描述符 | 见下文 |
scripts/predict_permeability.py | 使用PharmApp模型预测渗透率 | 见下文 |
scripts/batch_analysis.py | 批量分析和模型比较 | 见下文 |
脚本示例
计算分子描述符
# Activate environment
mamba activate ./env
# Run with demo data
python scripts/calculate_descriptors.py --demo
# Process custom SMILES file
python scripts/calculate_descriptors.py \
--input molecules.smi \
--output descriptors.csv
# Include additional descriptor types
python scripts/calculate_descriptors.py \
--input examples/data/demo_cyclic_peptides.smi \
--output full_descriptors.csv \
--config configs/calculate_descriptors_config.json参数:
--input, -i:输入SMILES(.smi)或SDF(.SDF)文件(必需)--output, -o:输出CSV文件路径(默认:自动生成)--config:JSON配置文件(默认:基本描述符)--demo:使用内置演示数据(3种环肽)
预测渗透率
python scripts/predict_permeability.py \
--input descriptors.csv \
--model caco2_c \
--output predictions.csv
# Available models: rrck_c, pampa_c, caco2_l, caco2_c, caco2_a
python scripts/predict_permeability.py \
--input examples/data/"example for Caco2_C.csv" \
--model caco2_c \
--demo批次分析
python scripts/batch_analysis.py \
--input descriptors.csv \
--output batch_results/ \
--models caco2_c rrck_c pampa_c______________________________________________________________________
MCP服务器安装
选项1:使用fastmcp(推荐)
# Install MCP server for Claude Code
mamba run -p ./env fastmcp install src/server.py --name cycpep-tools选项2:Claude代码的手动安装
# Add MCP server to Claude Code
claude mcp add cycpep-tools -- $(pwd)/env/bin/python $(pwd)/src/server.py
# Verify installation
claude mcp list选项3:在settings.json中配置
增添 ~/.claude/settings.json:
{
"mcpServers": {
"cycpep-tools": {
"command": "/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/pharmpapp_mcp/env/bin/python",
"args": ["/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/pharmpapp_mcp/src/server.py"]
}
}
}______________________________________________________________________
使用Claude代码
安装MCP服务器后,您可以直接在Claude Code中使用它。
快速开始
# Start Claude Code
claude示例提示
工具发现
What cyclic peptide tools are available from cycpep-tools?属性计算(快速)
Calculate molecular descriptors for examples/data/demo_cyclic_peptides.smi and save to descriptors.csv渗透率预测
Predict permeability using the caco2_c model for @examples/data/"example for Caco2_C.csv"结构验证
Validate the input file @examples/data/demo_cyclic_peptides.smi and tell me what's in it批量处理(提交API)
Submit a batch analysis job for @descriptors.csv using models caco2_c and rrck_c, save results to batch_results/作业管理
Check the status of job abc12345
Get the logs for job abc12345
List all my jobs使用@引用
在克劳德代码中,使用 @ 引用文件和目录:
| 参考 | 说明 |
|---|---|
@examples/data/demo_cyclic_peptides.smi | 参考演示SMILES文件 |
@configs/calculate_descriptors_config.json | 参考配置文件 |
@results/ | 参考输出目录 |
______________________________________________________________________
与Gemini CLI一起使用
配置
增添 ~/.gemini/settings.json:
{
"mcpServers": {
"cycpep-tools": {
"command": "/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/pharmpapp_mcp/env/bin/python",
"args": ["/home/xux/Desktop/CycPepMCP/CycPepMCP/tool-mcps/pharmpapp_mcp/src/server.py"]
}
}
}示例提示
# Start Gemini CLI
gemini
# Example prompts (same as Claude Code)
> What cyclic peptide tools are available?
> Calculate descriptors for the demo cyclic peptides
> Submit a batch analysis for multiple permeability models______________________________________________________________________
可用工具
快速操作(同步API)
这些工具会立即返回结果(\10分钟):
| 工具 | 说明 | 参数 |
|---|---|---|
submit_batch_analysis | 多模型比较分析 | input_file, output_dir, models, create_plots |
submit_large_descriptor_calculation | 大规模描述符计算 | input_file, output_file, include_3d, include_fingerprints |
作业管理工具
| 工具 | 说明 |
|---|---|
get_job_status | 检查作业进度和运行时间 |
get_job_result | 完成后获取结果 |
get_job_log | 查看执行日志(尾部50) |
cancel_job | 取消正在运行的作业 |
list_jobs | 列出所有具有状态筛选器的作业 |
cleanup_old_jobs | 删除旧的已完成作业 |
______________________________________________________________________
例子
示例1:快速描述符计算
目标: 计算环肽的基本分子性质
使用脚本:
python scripts/calculate_descriptors.py \
--input examples/data/demo_cyclic_peptides.smi \
--output demo_descriptors.csv使用MCP(克劳德代码):
Calculate molecular descriptors for @examples/data/demo_cyclic_peptides.smi and save to demo_descriptors.csv预期产量:
- CSV文件,每个分子有144个分子描述符
- 描述符包括:MolWt、LogP、TPSA、NumHBD、NumHBA等。
- 处理时间:3个分子约3秒
示例2:渗透率预测
目标: 使用PharmAPP模型预测环肽通透性
使用脚本:
python scripts/predict_permeability.py \
--input "examples/data/example for Caco2_C.csv" \
--model caco2_c \
--output caco2_predictions.csv使用MCP(克劳德代码):
Predict permeability using caco2_c model for the example Caco2_C data and save results预期产量:
- 具有置信度得分的预测渗透率值
- 模型性能指标(R²,RMSE)
- 处理时间:10个分子1-3秒
示例3:多模型比较
目标: 比较不同渗透率模型的预测结果
使用MCP(克劳德代码):
Submit a batch analysis for @examples/data/"example for Caco2_C.csv" using all available models. Save results to batch_comparison/
Then check the job status and show me the results when complete.工作流程:
- 以唯一Job_id提交的作业
- 监控进度
get_job_status - 使用检索结果
get_job_result - 查看详细日志
get_job_log
示例4:端到端管道
目标: 从SMILES到多模型预测的完整工作流程
使用MCP(克劳德代码):
1. First, calculate descriptors for @examples/data/demo_cyclic_peptides.smi
2. Then submit a batch analysis using the calculated descriptors with models caco2_c and rrck_c
3. Monitor the job and show me a summary when complete______________________________________________________________________
演示数据
这 examples/data/ 目录包含用于测试的示例数据:
| 文件 | 描述 | 分子 | 与一起使用 |
|---|---|---|---|
demo_cyclic_peptides.smi | 样品环肽SMILES | 3 | 描述符计算 |
example for Caco2_A.csv | Caco2-A训练数据 | 10 | 渗透率预测 |
example for Caco2_C.csv | Caco2-C训练数据 | 10 | 渗透率预测 |
example for Caco2_L.csv | Caco2-L训练数据 | 10 | 渗透率预测 |
example for PAMPA-C.csv | PAMPA-C训练数据 | 10 | 渗透率预测 |
example for RRCK-C.csv | RRCK-C训练数据 | 10 | 渗透率预测 |
样品环肽SMILES
演示文件包含3个代表性环肽:
C1C[C@H](NC(=O)[C@H](NC(=O)[C@H](NC1=O)CC2=CC=CC=C2)CC3=CC=C(C=C3)O)CC(C)C
C[C@H]1NC(=O)[C@H](NC(=O)[C@H](NC(=O)[C@H](NC(=O)[C@H](NC1=O)CC2=CC=CC=C2)CC(C)C)CC3=CC=C(C=C3)O)CC4=CNC5=CC=CC=C54
CC[C@H](C)[C@H]1NC(=O)[C@H](NC(=O)[C@H](NC(=O)[C@H](NC(=O)[C@H](NC1=O)C)CC2=CC=CC=C2)CC(C)C)CC3=CC=C(C=C3)O______________________________________________________________________
配置文件
这 configs/ 目录包含配置模板:
| 配置 | 描述 | 关键参数 |
|---|---|---|
calculate_descriptors_config.json | 描述符计算设置 | include_3d, include_fingerprints, descriptor_types |
predict_permeability_config.json | 模型预测设置 | test_size, cross_validation, scale_features |
batch_analysis_config.json | 批量分析设置 | models_to_test, create_plots |
default_config.json | 常规设置 | random_state, n_jobs |
配置示例
{
"processing": {
"include_3d": false,
"include_fingerprints": false,
"optimize_geometry": false
},
"descriptor_types": ["basic", "topological", "constitutional", "physicochemical"],
"quality_control": {
"validate_cyclic_peptide": true,
"calculate_lipinski_violations": true
}
}______________________________________________________________________
故障排除
环境问题
问题: 未找到环境
# Recreate environment
mamba create -p ./env python=3.10 -y
mamba activate ./env
mamba run -p ./env pip install pandas numpy scikit-learn matplotlib seaborn tqdm loguru click
mamba install -p ./env -c conda-forge rdkit -y
mamba run -p ./env pip install --force-reinstall --no-cache-dir fastmcp问题: RDKit导入错误
# Install RDKit from conda-forge (essential)
mamba install -p ./env -c conda-forge rdkit -y
# Test RDKit installation
mamba run -p ./env python -c "from rdkit import Chem; print('RDKit working!')"问题: 导入错误
# Verify all dependencies
mamba run -p ./env python -c "
from src.server import mcp
from rdkit import Chem
import pandas
import fastmcp
print('All dependencies working!')
"MCP问题
问题: 在Claude代码中找不到服务器
# Check MCP registration
claude mcp list
# Re-add if needed
claude mcp remove cycpep-tools
claude mcp add cycpep-tools -- $(pwd)/env/bin/python $(pwd)/src/server.py问题: 无效的SMILES错误
Ensure your SMILES string is valid for cyclic peptides. Use the cyclo() notation
or ensure ring closure is properly specified with numbers (e.g., C1...C1).问题: 工具不工作
# Test server directly
mamba run -p ./env python -c "
from src.server import mcp
print('Available tools:', list(mcp.list_tools().keys()))
print('Total tools:', len(mcp.list_tools()))
"工作问题
问题: 作业挂起
# Check job directory and logs
ls -la jobs/在克劳德代码中:
Get the log for job with 100 lines to see what happened问题: 描述符兼容性错误\*\*
Error: Too many missing descriptors. Available: 63/94解决方案:当试图用与模型要求不匹配的描述符预测渗透率时,就会发生这种情况。使用示例CSV文件获取兼容数据,或增强描述符计算以包含MOE风格的描述符。
问题: 内存不足错误
Use submit_large_descriptor_calculation for datasets >1000 molecules
Process in smaller batches for very large datasets常见模型问题
问题: PAMPA模型需要77个描述符,找到0个
这是一个已知的限制。描述符计算产生RDKit描述符,而模型则需要MOE2D描述符。解决:
- 使用提供的具有兼容描述符的示例CSV文件
- 等待未来版本中增强的描述符映射
调试
在克劳德代码中:
# Check job status
Check the status of job
# View recent logs
Get the log for job with 50 lines
# List all jobs
List all my jobs and their statuses
# Validate input data
Validate the input file @examples/data/demo_cyclic_peptides.smi______________________________________________________________________
发展
运行测试
# Activate environment
mamba activate ./env
# Test basic functionality
python scripts/calculate_descriptors.py --demo正在启动开发服务器
# Run MCP server in development mode
mamba run -p ./env fastmcp dev src/server.py
# Test server connectivity
mamba run -p ./env python -c "from src.server import mcp; print('Server ready')"______________________________________________________________________
性能指南
何时使用同步与提交API
在以下情况下使用同步API:
- 数据集\1000个分子
- 包括3D描述符或指纹(速度慢得多)
- 批量处理多个模型
- 可能需要>10分钟的长时间运行分析
资源使用情况
| 操作 | 内存 | CPU | 时间(1000个分子) |
|---|---|---|---|
| 基本描述符 | ~100MB | 低 | ~2分钟 |
| 3D描述符 | ~500MB | 高 | ~15分钟 |
| 指纹 | ~200MB | 中等 | ~5分钟 |
| 模型预测 | ~50MB | 低 | ~1分钟 |
| 批量分析 | ~30MB | 中等 | ~10分钟 |
______________________________________________________________________
许可证
基于 法尔帕普 -弗劳恩霍夫ITMP实施
积分
此MCP服务器实现了原始PharmApp存储库中KNIME工作流的Python等效物,通过现代LLM接口提供对环肽渗透性预测模型的编程访问。
______________________________________________________________________
API参考摘要
作业管理(6个工具)
get_job_status-检查作业进度和运行时间get_job_result-获取已完成的作业结果get_job_log-查看执行日志cancel_job-取消正在运行的作业list_jobs-列出具有状态筛选器的作业cleanup_old_jobs-删除旧的已完成作业
同步分析(2个工具)
calculate_cyclic_peptide_descriptors-快速描述符计算predict_cyclic_peptide_permeability-单模型渗透率预测
异步处理(2个工具)
submit_batch_analysis-多模型比较submit_large_descriptor_calculation-大规模描述符计算
实用程序(3个工具)
get_available_models-型号信息和要求validate_input_file-文件格式验证get_example_data-可用演示数据信息
总计:13个MCP工具,涵盖完整的环肽计算分析工作流程。
