File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ dependencies:
66 - bcftools
77 - bedtools
88 - samtools
9+ - bedops
910
Original file line number Diff line number Diff line change 11rule genome_consensus :
22 input :
3- alignment = "consensusmap .bam" ,
3+ alignment = "refgenome .bam" ,
44 ref = "NC_045512.fa" ,
55 vcf = "filtered.vcf"
66 output :
7- consensus = "results/consensus.fa" ,
7+ "results/consensus.fa" ,
88 log :
99 "log/test.log"
1010 params :
Original file line number Diff line number Diff line change 1616log = snakemake .log_fmt_shell (stdout = False , stderr = True )
1717
1818# Temp files
19- temp_vcfgz = tempfile .TemporaryFile ()
19+ temp_vcfgz = tempfile .NamedTemporaryFile ()
2020vcfgz_index = str (temp_vcfgz .name ) + ".csi"
21- temp_consensus = tempfile .TemporaryFile ()
22- temp_bed = tempfile .TemporaryFile ()
21+ del_bed = tempfile .NamedTemporaryFile ()
22+ cov_bed = tempfile .NamedTemporaryFile ()
23+ mask_bed = tempfile .NamedTemporaryFile ()
24+ mask_bed = str (mask_bed .name ) + ".bed"
2325
2426shell (
2527 """
2628 (bgzip -c {snakemake.input.vcf} > {temp_vcfgz.name}
2729 bcftools index {temp_vcfgz.name}
28- cat {snakemake.input.ref} | bcftools consensus {temp_vcfgz.name} > {temp_consensus.name}
29- samtools view -h -b -q {mapping_quality} -f 0x3 {snakemake.input.alignment} | genomeCoverageBed -bga -ibam stdin | awk '$4 < {mask}' | bedtools merge > {temp_bed.name}
30- bedtools maskfasta -fi {temp_consensus.name} -bed {temp_bed.name} -fo {snakemake.output.consensus}) {log}
31- """
32- )
33-
34- shell (
35- """
36- rm -f {temp_vcfgz.name}
37- rm -f {vcfgz_index}
38- rm -f {temp_consensus.name}
39- rm -f {temp_bed.name}
30+ samtools view -h -b -q {mapping_quality} {snakemake.input.alignment} | genomeCoverageBed -bga -ibam stdin | awk '$4 < {mask}' | bedtools merge > {cov_bed.name}
31+ vcf2bed --deletions < {snakemake.input.vcf} > {del_bed.name}
32+ bedtools subtract -a {cov_bed.name} -b {del_bed.name} > {mask_bed}
33+ bcftools consensus -f {snakemake.input.ref} -m {mask_bed} {temp_vcfgz.name} > {snakemake.output[0]}) {log}
4034 """
4135)
You can’t perform that action at this time.
0 commit comments