samples = ["A", "B"]
rule all:
input:
"calls/all.vcf",
"plots/quals.svg"
rule bwa:
input:
"data/genome.fa",
"data/samples/{sample}.fastq"
output:
temp("mapped/{sample}.bam")
conda:
"envs/mapping.yaml" ## 比对环境
threads: 8
shell:
"bwa mem -t {threads} {input} | samtools view -Sb - > {output}"
rule sort:
input:
"mapped/{sample}.bam"
output:
"mapped/{sample}.sorted.bam"
conda:
"envs/mapping.yaml" ## 比对环境
shell:
"samtools sort -o {output} {input}"
rule call:
input:
fa="data/genome.fa",
bam=expand("mapped/{sample}.sorted.bam", sample=samples)
output:
"calls/all.vcf"
conda:
"envs/calling.yaml" ## calling 环境
shell:
"samtools mpileup -g -f {input.fa} {input.bam} | "
"bcftools call -mv - > {output}"
rule stats:
input:
"calls/all.vcf"
output:
report("plots/quals.svg", caption="report/calling.rst")
conda:
"envs/stats.yaml" ## 统计环境
script:
"scripts/plot-quals.py"
资料来源于 公众号 老俊俊的生信笔记
主要借鉴的地方是使用不同的环境实现shell命令
# # 假设我们有一个环境叫 gen,可以导出为一个 mapping.yaml 文件。
conda env export --file mapping.yaml --name gen
网友评论