LOFREQ INDELQUAL
Insert indel qualities into BAM file (required for indel predictions)
URL: https://csb5.github.io/lofreq/
Example
This wrapper can be used in the following way:
rule lofreq_uniform_indelqual:
input:
bam="data/{sample}.bam",
output:
"out/indelqual/{sample}.uindel.bam"
log:
"logs/{sample}.uindel.log"
params:
extra="-u 15"
threads: 8
wrapper:
"v3.9.0-1-gc294552/bio/lofreq/indelqual"
rule lofreq_dindel_indelqual:
input:
bam="data/{sample}.bam",
ref="data/hg38_chr21.fa"
output:
"out/indelqual/{sample}.dindel.bam"
log:
"logs/{sample}.dindel.log"
params:
extra="--dindel"
threads: 8
wrapper:
"v3.9.0-1-gc294552/bio/lofreq/indelqual"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Software dependencies
samtools=1.20
lofreq=2.1.5
Input/Output
Input:
bam file that will have variants called
reference genome of bam (optional unless –dindel specified)
Output:
bam file with indel qualities added
Code
__author__ = "Tobin Groth"
__copyright__ = "Copyright 2023, Tobin Groth"
__email__ = "tobingroth1@gmail.com"
__license__ = "MIT"
import os
from snakemake.shell import shell
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
extra = snakemake.params.get("extra", "")
if len(snakemake.output) != 1:
raise ValueError("Expecting only one output file!")
ref = snakemake.input.get("ref", "")
if "--dindel" in extra and not ref:
raise ValueError("Reference required if --dindel option specified")
if ref:
ref = f"--ref {ref}"
shell(
"lofreq indelqual "
" {snakemake.input.bam}"
" {ref}"
" -o {snakemake.output[0]}"
" {extra}"
" {log}"
)