【问题标题】:Use wildcard on params在参数上使用通配符
【发布时间】:2018-03-29 17:19:18
【问题描述】:

我尝试使用一种工具,但我需要在输入中使用通配符。

这是一个例子:

aDict = {"120":"121" } #tumor : normal


rule all:
 input: expand("{case}.mutect2.vcf",case=aDict.keys())


def get_files_somatic(wildcards):
 case = wildcards.case
 control = aDict[wildcards.case]
 return [case + ".sorted.bam", control + ".sorted.bam"]



rule gatk_Mutect2:
    input:
        get_files_somatic,

    output:
        "{case}.mutect2.vcf"

    params:
        genome="ref/hg19.fa",
        target= "chr12",
        name_tumor='{case}'
    log:
        "logs/{case}.mutect2.log"
    threads: 8
    shell:
        " gatk-launch Mutect2 -R {params.genome} -I {input[0]} -tumor {params.name_tumor} -I {input[1]} -normal {wildcards.control}"
        " -L {params.target} -O {output}"

我有这个错误:

'Wildcards' object has no attribute 'control'

所以我有一个带有大小写和控制的功能。我无法提取代码。

【问题讨论】:

    标签: bioinformatics snakemake vcf-variant-call-format


    【解决方案1】:

    通配符源自输出文件/模式。这就是为什么您只有通配符称为 case。您必须从中获得控制权。尝试用这个替换你的 shell 语句:

    run:
        control = aDict[wildcards.case]
        shell(
            "gatk-launch Mutect2 -R {params.genome} -I {input[0]} "
            "-tumor {params.name_tumor} -I {input[1]} -normal {control} "
            "-L {input.target2} -O {output}"
        )
    

    【讨论】:

      【解决方案2】:

      您可以在params 中定义control。 shell命令中的{input.target2}也会导致错误。可能应该是params.target

      rule gatk_Mutect2:
          input:
              get_files_somatic,
          output:
              "{case}.mutect2.vcf"
          params:
              genome="ref/hg19.fa",
              target= "chr12",
              name_tumor='{case}',
              control = lambda wildcards: aDict[wildcards.case]
          shell:
              """
              gatk-launch Mutect2 -R {params.genome} -I {input[0]} -tumor {params.name_tumor} \\
                  -I {input[1]} -normal {params.control} -L {params.target} -O {output}
              """
      

      【讨论】:

        猜你喜欢
        • 2014-12-03
        • 2019-11-19
        • 2016-04-11
        • 2011-07-24
        • 1970-01-01
        • 1970-01-01
        • 2014-12-20
        • 2015-03-25
        • 2011-08-15
        相关资源
        最近更新 更多