【问题标题】:Command lines in snakemakesnakemake 中的命令行
【发布时间】:2021-02-03 01:16:47
【问题描述】:

我想使用此命令行在文件夹中创建 BAM 文件列表:

 ls *.bam > bam_list

但是,我想把它集成到snakemake中。这个怎么做?这是我尝试过的,但不起作用:

rule bam_list:
    input:
         inlist ="dup/{sample}.bam"
    output:
         outlist = "dup/bam_list"
    shell:
         """
         ls {input.inlist} > {output.outlist}
         """

输出 bam_list 如下所示:

  bob.bam
  anne.bam
  john.bam

【问题讨论】:

    标签: ls snakemake bam


    【解决方案1】:

    你可以完全跳过输入:

    rule bam_list:
        output:
             outlist = "dup/bam_list"
        shell:
             """
             ls *.bam > {output.outlist}
             """
    

    编辑

    rule bam_list:
        input:
            rules.previous.output
        output:
             outlist = "dup/bam_list"
        params:
            indir = lambda wildcards, input: os.path.dirname(input[0])
        shell:
             """
             ls {params.indir}*.bam > {output.outlist}
             """
    

    对于更复杂的逻辑,您可能必须使用输入函数。

    【讨论】:

    • 谢谢!!第二个不起作用...第一个给我带来了问题,因为我在一个命令行中有一系列规则,并且它希望在创建 bam 文件之前使用 bam_list 规则,因为输入名称不相同.. .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多