FGBIO ANNOTATEBAMWITHUMIS
Annotates existing BAM files with UMIs (Unique Molecular Indices, aka Molecular IDs, Molecular barcodes) from a separate FASTQ file.
URL: https://fulcrumgenomics.github.io/fgbio/
Example
This wrapper can be used in the following way:
rule annotate_bam_single_fastq:
input:
bam="mapped/{sample}.bam",
umi="umi/{sample}.fastq",
output:
"mapped/{sample}.annotated.bam",
params:
"",
resources:
# suggestion assuming unsorted input, so that memory should
# be proportional to input size:
# https://fulcrumgenomics.github.io/fgbio/tools/latest/AnnotateBamWithUmis.html
mem_mb=lambda wildcards, input: max([input.size_mb * 1.3, 200]),
log:
"logs/fgbio/annotate_bam/{sample}.log",
wrapper:
"v9.4.2/bio/fgbio/annotatebamwithumis"
rule annotate_bam_multiple_fastqs:
input:
bam="mapped/{sample}.bam",
umi=[
"umi/{sample}.fastq",
"umi/{sample}.fastq",
],
output:
"mapped/{sample}-{sample}.annotated.bam",
params:
"",
resources:
# suggestion assuming unsorted input, so that memory should
# be proportional to input size:
# https://fulcrumgenomics.github.io/fgbio/tools/latest/AnnotateBamWithUmis.html
mem_mb=lambda wildcards, input: max([input.size_mb * 1.3, 200]),
log:
"logs/fgbio/annotate_bam/{sample}-{sample}.log",
wrapper:
"v9.4.2/bio/fgbio/annotatebamwithumis"
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
fgbio=4.0.0snakemake-wrapper-utils=0.8.0
Code
__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2018, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com"
__license__ = "MIT"
from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
extra_params = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
shell(
"fgbio {java_opts} AnnotateBamWithUmis"
" -i {snakemake.input.bam}"
" -f {snakemake.input.umi}"
" {extra_params}"
" -o {snakemake.output[0]}"
" {log}"
)