Skip to main content
Glama

SAMtools MCP(模型控制协议)

SAMtools 的模型控制协议实现,为处理 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 索引 - 区域提取 - 序列检索

Related MCP server: Nmap MCP Server

安装

使用 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

本地安装

  1. 克隆存储库:

git clone https://github.com/your-username/samtools_mcp.git
cd samtools_mcp
  1. 安装依赖项:

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文件的实际路径。

用法

基本命令

  1. 查看BAM文件:

from samtools_mcp import SamtoolsMCP

mcp = SamtoolsMCP()
result = mcp.view(input_file="/data/example.bam")
  1. 对 BAM 文件进行排序:

result = mcp.sort(input_file="/data/example.bam", output_file="/data/sorted.bam")
  1. 索引BAM文件:

result = mcp.index(input_file="/data/sorted.bam")

高级用法

  1. 查看带有标志的特定区域:

result = mcp.view(
    input_file="/data/example.bam",
    region="chr1:1000-2000",
    flags_required="0x2",
    output_format="SAM"
)
  1. 按阅读名称排序:

result = mcp.sort(
    input_file="/data/example.bam",
    output_file="/data/namesorted.bam",
    sort_by_name=True
)
  1. 使用多个输入文件计算深度:

result = mcp.depth(
    input_files=["/data/sample1.bam", "/data/sample2.bam"],
    region="chr1:1-1000000"
)

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sirusb/samtools_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server