用snakemake定义替代规则

时间:2019-01-02 07:47:24

标签: snakemake

你好,我是snakemake的新手,我需要一些帮助。

我的目标是索引一个基因组(使用bowtie2) 但是我需要一些其他步骤,具体取决于可用的文件

1> check if index already exist in storage (/storage/index)
2> if yes, copy index in local (/index)
3> if no, create index in local (/index)
4> then copy new index in storage (/storage/index)

我设法设置了一个bash脚本来检查现有文件和替代工作流程。但是我希望使用snakemake,但不确定如何定义规则以获得类似的行为。

1 个答案:

答案 0 :(得分:0)

您的psedocode逻辑似乎在snakemake中造成了循环依赖性问题。为了简化起见,我将step3更改为if no, create new index in storage (/storage/index),这使step4与step1相同。

rule create_index:
    input:
        "/storage/index/a.fa"
    output:
        "/storage/index/a.idx"
    message:
        "Create index at source dir"
    shell:
        '''
        index_tool {input} {output}
        '''


rule copy_index:
    input:
        "/storage/index/a.idx"
    output:
        "/local/index/a.idx"
    message:
        "copy index to local dir"
    shell:
        '''
        cp {input} {output}
        '''