Snakemake:如何更改文字标签

时间:2018-02-20 15:21:44

标签: snakemake

我有一条规则:

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

1 个答案:

答案 0 :(得分:2)

你只需要使用制表符字符,以便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}