无法在Snakemake中执行bash脚本

无法在Snakemake中执行bash脚本,bash,snakemake,Bash,Snakemake,这是我关于Snakemake的第一个问题,因为现有的资源和论坛极大地帮助我解决了大部分问题 我目前遇到的问题是,我无法使bash脚本在Snakemake中执行,尽管我能够在命令行上很好地执行相同的bash脚本 下面是我如何在命令行上成功运行bash脚本 bash scripts/genome_coverage.sh -m results/mapped_reads -o final_out.txt 但是当我在Snakemake中运行它时,我得到了错误 下面是Snakefile中与正在执行的bas

这是我关于Snakemake的第一个问题,因为现有的资源和论坛极大地帮助我解决了大部分问题

我目前遇到的问题是,我无法使bash脚本在Snakemake中执行,尽管我能够在命令行上很好地执行相同的bash脚本

下面是我如何在命令行上成功运行bash脚本

bash scripts/genome_coverage.sh -m results/mapped_reads -o final_out.txt
但是当我在Snakemake中运行它时,我得到了错误

下面是Snakefile中与正在执行的bash脚本相对应的规则

rule genome_coverage:
    input:
        "results/mapped_reads"
    output:
        "genome_coverage.txt"
    script:
        "scripts/genome_coverage.sh -m {input} -o {output}"
这就是我得到的错误。我不知道我做错了什么

Error in rule genome_coverage:
    jobid: 16
    output: genome_coverage.txt
RuleException:
NameError in line 153 of /Illumina-mRNA/Snakefile:
The name 'input' is unknown in this context. Please make sure that you defined that variable. Also note that braces not used for variable access have to be escaped by repeating them, i.e. {{print $1}}
您需要用shell替换脚本:

您需要用shell替换脚本:


只是为了扩大一点。脚本用于外部python、R或julia脚本文件。如果只需要bash命令,可以使用shell。如果你想要内联python,你可以使用run,它也可以使用snakemake提供的shell函数打开。只是稍微扩展一下。脚本用于外部python、R或julia脚本文件。如果只需要bash命令,可以使用shell。如果您想要内联python,可以使用run,它也可以使用snakemake提供的shell函数打开。
rule genome_coverage:
    input:
        "results/mapped_reads"
    output:
        "genome_coverage.txt"
    shell:
        "scripts/genome_coverage.sh -m {input} -o {output}"