](https://mseep.ai/app/sirusb-samtools-mcp)
SAMtools MCP(模型控制协议)
SAM工具的模型控制协议实现,为处理SAM/BAM/CRAM文件提供了一个标准化的接口。
特性
- 查看和转换SAM/BAM/CRAM文件
- 对对齐文件进行排序
- 索引BAM/CRAM文件
- 生成统计数据
- 合并多个BAM文件
- 计算读取深度
- FASTA文件索引
- 还有更多。..
核心能力
- 文件格式支持:处理SAM(文本)、BAM(二进制)和CRAM(压缩)对齐文件
- 格式转换:在SAM、BAM和CRAM格式之间无缝转换
- 区域特定分析:提取并分析特定的基因组区域
- 基于标志的过滤:基于SAM标志的筛选器读取
- 性能优化:用于排序和合并的多线程操作
- 统计分析:生成全面的对齐统计数据
工具概述
| 工具 | 描述 | 主要功能 |
|---|---|---|
view | 查看和转换对齐文件 | -格式转换(SAM/BAM/CRAM) |
-区域过滤 -基于标志的过滤 -标题操作| | sort |排序对齐文件|-基于坐标的排序 -基于名称的排序 -每线程内存控制 -多线程支持| | index |索引BAM/CRAM文件|-BAI索引生成 -CSI指数支持 -CRAM索引创建| | merge |合并多个BAM/CRAM文件|-多文件合并 -支持线程的处理 -表头对账| | depth |计算读取深度|-每基深度计算 -区域特定分析 -多文件支持| | flagstat |生成对齐统计|-综合标志统计 -质量检查 -配对终端指标| | idxstats |BAM/CRAM索引统计|-参考序列统计 -已映射/未映射计数 -长度信息| | faidx |FASTA文件索引|-FASTA索引 -区域提取 -序列检索|
安装
使用Docker(推荐)
使用SAMtools MCP最简单的方法是通过Docker:
# Pull the Docker image
docker pull nadhir/samtools-mcp:latest
# Run the container
docker run -it --rm nadhir/samtools-mcp:latest
# To process BAM files, mount a volume:
docker run -it --rm -v /path/to/your/bam/files:/data nadhir/samtools-mcp:latest本地安装
- 克隆存储库:
git clone https://github.com/your-username/samtools_mcp.git
cd samtools_mcp- 安装依赖项:
pip install uv
uv pip install -r requirements.txt配置
MCP服务器配置
要配置MCP服务器以使用Docker镜像,请将以下内容添加到MCP配置文件中:
{
"servers": {
"samtools": {
"type": "docker",
"image": "nadhir/samtools-mcp:latest",
"volumes": [
{
"source": "/path/to/your/data",
"target": "/data"
}
]
}
}
}本地MCP配置
配置MCP以使用运行 uv,将以下内容添加到您的 ~/.cursor/mcp.json:
{
"samtools_mcp": {
"command": "uv",
"args": ["run", "--with", "fastmcp", "fastmcp", "run", "/path/to/samtools_mcp.py"]
}
}替换 /path/to/samtools_mcp.py 与您的实际路径 samtools_mcp.py 文件。
用法
基本命令
- 查看BAM文件:
from samtools_mcp import SamtoolsMCP
mcp = SamtoolsMCP()
result = mcp.view(input_file="/data/example.bam")- 对BAM文件进行排序:
result = mcp.sort(input_file="/data/example.bam", output_file="/data/sorted.bam")- 索引BAM文件:
result = mcp.index(input_file="/data/sorted.bam")高级用法
- 查看带有标志的特定区域:
result = mcp.view(
input_file="/data/example.bam",
region="chr1:1000-2000",
flags_required="0x2",
output_format="SAM"
)- 按读取名称排序:
result = mcp.sort(
input_file="/data/example.bam",
output_file="/data/namesorted.bam",
sort_by_name=True
)- 使用多个输入文件计算深度:
result = mcp.depth(
input_files=["/data/sample1.bam", "/data/sample2.bam"],
region="chr1:1-1000000"
)贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
