Snakemake:如何更改文字选项卡

Snakemake: how to change literal tab

我有这样的规则:

rule merge_fastq_by_lane:
    input:
        r1 = get_fastq_r1,
        r2 = get_fastq_r2
    output:
        r1_o = "{sample}/fastq/lanes/{sample}_{unit}_R1.fastq",
        r2_o = "{sample}/fastq/lanes/{sample}_{unit}_R2.fastq",
        bam = "{sample}/bam/lanes/{sample}_{unit}.bam"
    threads: 
        1
    message:
        "Merge fastq from the same sample and lane and align using bwa"
    shell:
        """
        cat {input.r1} > {output.r1_o}
        cat {input.r2} > {output.r2_o}
        {bwa} mem -M -t {threads} -R "@RG\tID:{wildcards.sample}_{wildcards.unit}\tSM:{wildcards.sample}" {bwa_index} {output.r1_o} {output.r2_o} | {samtools} view -bS - | {samtools} sort - > {output.bam}
        """

由于 bwa 的 -R 参数中的制表符问题,我收到此错误消息

bwa mem -M -t 1 -R "@RG ID:P1_L001  SM:P1" Homo_sapiens.GRCh37.dna.primary_assembly P1/fastq/lanes/P1_L001_R1.fastq P1/fastq/lanes/P1_L001_R2.fastq | samtools view -bS - | samtools sort - > P1/bam/lanes/P1_L001.bam

[E::bwa_set_rg] the read group line contained literal <tab> characters -- replace with escaped tabs: \t

你只需要转义制表符,这样 snakemake 就不会解释它:

{bwa} mem -M -t {threads} -R "@RG\tID:{wildcards.sample}_{wildcards.unit}\tSM:{wildcards.sample}" {bwa_index} {output.r1_o} {output.r2_o} | {samtools} view -bS - | {samtools} sort - > {output.bam}