【发布时间】:2022-01-16 07:41:44
【问题描述】:
我正在尝试使用 snakemake 的 shell 命令中的 samtools 重新标头将染色体编号符号从 [0-9XY] 更改为 Chr[0-9XY]。
rule rename:
input:
os.path.join(config["input"], "{sample}.bam"),
output:
os.path.join(config["output"], "new_sample/{sample}_chr.bam")
log:
os.path.join(config["log"], "samtools/{sample}")
shell:
"samtools view -H {input} | sed -e 's/SN:\([0-9XY]*\)/SN:chr\1\/' -e 's/SN:MT/SN:chrM/' |samtools reheader - {input} > {output}"
代码在终端中运行成功,但是当我在snakemake中使用代码时出现错误:
shell:
samtools view -H /Users/EGA_dataset/cnvkit_snakemake/input/EGAF00000788153_PD11458c.bam | sed -e 's/SN:\([0-9XY]*\)/SN:chr/' -e 's/SN:MT/SN:chrM/' |samtools reheader - /Users/cnvkit_snakemake/input/EGAF00000788153_PD11458c.bam > /Users/EGA_dataset/cnvkit_snakemake/output/new_sample/EGAF00000788153_PD11458c_chr.bam
(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
当我查看错误时,我发现snakemake 将 sed -e 's/SN:([0-9XY]*)/SN:chr\1/ 读取为 's/SN:([0-9XY]*)/SN:chr/'。也就是说,由于某些我不明白的原因,它截断了代码。
【问题讨论】:
-
你有一个错字,你不能反斜线在第一次替换
chr\1\/
标签: python shell unix bioinformatics snakemake