Skip to content

Commit 0652c80

Browse files
committed
Replace Freyja variants with equivalent samtools and ivar command
1 parent 245ec94 commit 0652c80

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

workflow/rules/demix.smk

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@ rule demix_update:
2222

2323
rule demix_preprocessing:
2424
threads: 1
25-
conda: "../envs/freyja.yaml"
25+
conda: "../envs/var_calling.yaml"
2626
shadow: "minimal"
2727
input:
2828
bam = get_input_bam,
2929
ref_fasta = lambda wildcards: select_mapping_references_fasta()
3030
params:
31-
minq = config["DEMIX"]["MIN_QUALITY"]
31+
minq = config["DEMIX"]["MIN_QUALITY"],
3232
output:
3333
depth_file = OUTDIR/"demixing"/"{sample}/{sample}_depth.txt",
34-
variants_file = OUTDIR/"demixing"/"{sample}/{sample}_variants.tsv"
34+
variants_file = OUTDIR/"demixing"/"{sample}/{sample}_variants.tsv",
3535
log:
36-
LOGDIR / "demix_preprocessing" / "{sample}.log.txt"
36+
pileup = LOGDIR / "demix_preprocessing" / "{sample}_pileup.log.txt",
37+
ivar = LOGDIR / "demix_preprocessing" / "{sample}_ivar.log.txt",
3738
shell:
38-
"""
39-
freyja variants \
40-
"{input.bam}" \
41-
--variants {output.variants_file} \
42-
--depths {output.depth_file} \
43-
--minq {params.minq} \
44-
--ref {input.ref_fasta} >{log} 2>&1
45-
"""
39+
"set -euo pipefail && "
40+
"samtools mpileup -aa -A -d 600000 -Q {params.minq} -q 0 -B -f {input.ref_fasta:q} {input.bam:q} >sample.pileup 2>{log.pileup:q} && "
41+
"ivar variants -p variants -q {params.minq} -r {input.ref_fasta:q} >{log.ivar:q} 2>&1 <sample.pileup && "
42+
"cut -f1-4 sample.pileup >{output.depth_file:q} && "
43+
"mv variants.tsv {output.variants_file:q}"
4644

4745

4846
rule demix:

0 commit comments

Comments
 (0)