Snakemake使用bamtools合并多个bam文件

时间:2019-12-04 13:08:23

标签: yaml snakemake

我要合并的其他目录中有多个BAM文件。在我的config.yaml文件中,我指出了要合并的文件的路径:

var:
   var1: [ "/DATA/utent3/DATI/var/var1/leaf/trimmed/leaf_var1_ref1.bam", "/DATA/utent3/DATI/var/var1/stem/trimmed/stem_var1_ref1.bam", "/DATA/utent3/DATI/var/var1/flower/trimmed/flower_var1_ref1.bam" ]
....
   var9: [ "/DATA/utent3/DATI/var/var9/leaf/trimmed/leaf_var9_ref1.bam", "/DATA/utent3/DATI/var/var9/stem/trimmed/stem_var9_ref1.bam", "/DATA/utent3/DATI/var/var9/flower/trimmed/flower_var9_ref1.bam" ]

executables:
    bamtools: /home/utent3/anaconda3/bin/bamtools

这是我的蛇文件

configfile: "config.yaml"
workdir: "/DATA/utent3/DATI/var/"

rule all:
    input:
        expand("{sample}.accepted.bam", sample = config["var"])

rule bamtools:
    input:
        bams = lambda wildcards: config["var"][wildcards.sample]
    output:
        bam = "{sample}.accepted.bam"
    params:
        executable = config["executables"]["bamtools"]
    run:
        shell("{params.executable} merge -list {input.bams} -out {output.bam}")

我收到此错误:

WorkflowError: Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards.

通常有人可以解释如何在配置文件中写入多个文件路径。

更新 现在它说(现在我只尝试使用var1):

ERROR: Some problems were encountered when parsing the command line options:
   An unrecognized argument was found: /DATA/utent3/DATI/var/var1/stem/trimmed/stem_var1_ref1.bam
   An unrecognized argument was found: /DATA/utent3/DATI/var/var1/flower/trimmed/flower_var1_ref1.bam

我认为是因为它没有正确读取config.file var ...

2 个答案:

答案 0 :(得分:1)

我怀疑您以

的身份执行snakemake
snakemake [opts] bamtools

而不是

snakemake [opts]

使用前一个命令,您将“ bamtools”作为目标规则,正如错误所言,该规则包含通配符。

答案 1 :(得分:0)

因此,根据bamtools帮助合并文档,我解决了调整脚本以下部分的问题,肯定不是最好的方法,但是可以解决问题:

run:
    shell("{params.executable} merge -in {input.bams[0]} -in {input.bams[1]} -in {input.bams[2]} -out {output.bam}")