ORTHANQ

https://img.shields.io/badge/wrapper_version-v9.1.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/orthanq?label=version%20update%20pull%20requests&color=1cb481

Orthanq is a tool for haplotype quantification in both viral and HLA contexts. This wrapper supports all three main subcommands (candidates, preprocess, and call) for both hla and virus use cases. - candidates: Generates candidate variants for quantification. - preprocess: Preprocesses raw reads into BCF. - call: Quantifies haplotypes using a Bayesian model.

URL: https://github.com/orthanq/orthanq

Example

This wrapper can be used in the following way:

# Candidates HLA
rule orthanq_candidates_hla:
    input:
        genome="refs/genome_hla.fasta",
        xml="refs/alleles.xml",
        alleles="refs/alleles.fasta",
    output:
        directory("out/candidates")
    log:
        "logs/orthanq_candidates/candidates.log",
    params:
        command="candidates",
        subcommand="hla",
        output_bcf=False
    wrapper:
        "v9.1.0/bio/orthanq"

# Candidates Virus
rule orthanq_candidates_virus:
    input:
        genome="refs/genome_virus.fasta",
        lineages="refs/lineages.fasta"
    output:
        "out/candidates.vcf"
    log:
        "logs/orthanq_candidates/candidates.log",
    params:
        command="candidates",
        subcommand="virus"
    wrapper:
        "v9.1.0/bio/orthanq"

# Preprocess HLA
rule orthanq_preprocess_hla:
    input:
        genome="refs/genome_hla.fasta",
        reads=["reads/read_1_hla.fq", "reads/read_2_hla.fq"],
        haplotype_variants="variants/haplotype_variants_hla.vcf",
        vg_index="refs/hprc_prebuilt.xg",
    output:
        "out/preprocess_hla.bcf",
    log:
        "logs/orthanq_preprocess/preprocess.log",
    params:
        command="preprocess",
        subcommand="hla"
    wrapper:
        "v9.1.0/bio/orthanq"

# Preprocess Virus
rule orthanq_preprocess_virus:
    input:
        genome="refs/genome_virus.fasta",
        reads=["reads/read_1_virus.fq", "reads/read_2_virus.fq"],
        haplotype_variants="variants/haplotype_variants_virus.vcf",
    output:
        "out/preprocess_virus.bcf"
    log:
        "logs/orthanq_preprocess/preprocess.log",
    params:
        command="preprocess",
        subcommand="virus"
    wrapper:
        "v9.1.0/bio/orthanq"

# Call HLA
rule orthanq_call_hla:
    input:
        haplotype_calls="variants/haplotype_calls.bcf",
        haplotype_variants="variants/haplotype_variants_hla.vcf",
        xml="refs/alleles.xml"
    output:
        directory("out/calls_hla")
    log:
        "logs/orthanq_call/call.log",
    params:
        command="call",
        subcommand="hla",
        prior="diploid",
        extra=""
    wrapper:
        "v9.1.0/bio/orthanq"

# Call Virus
rule orthanq_call_virus:
    input:
        haplotype_calls="variants/haplotype_calls.bcf",
        haplotype_variants="variants/haplotype_variants_virus.vcf"
    output:
        directory("out/calls_virus")
    log:
        "logs/orthanq_call/call.log",
    params:
        command="call",
        subcommand="virus",
        prior="uniform"
    wrapper:
        "v9.1.0/bio/orthanq"

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.

Notes

Software dependencies

  • orthanq=1.21.0

Params

  • command: One of candidates, preprocess, or call

  • subcommand: One of hla or virus

  • prior: Prior model used in Bayesian quantification (uniform or diploid) - required for call

  • extra: Optional extra parameters passed to the orthanq command (e.g. –sample-name used in call hla for multi-sample VCFs)

Authors

  • Hamdiye Uzuner

Code

__author__ = "Hamdiye Uzuner"
__copyright__ = "Copyright 2025, Hamdiye Uzuner"
__license__ = "MIT"

from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=True, stderr=True)
extra = snakemake.params.get("extra", "")

# Parse inputs
reads = snakemake.input.get("reads")
if reads:
    extra += f" --reads {reads}"

genome = snakemake.input.get("genome")
if genome:
    extra += f" --genome {genome}"

alleles = snakemake.input.get("alleles")
if alleles:
    extra += f" --alleles {alleles}"

xml = snakemake.input.get("xml")
if xml:
    extra += f" --xml {xml}"

lineages = snakemake.input.get("lineages")
if lineages:
    extra += f" --lineages {lineages}"

haplotype_variants = snakemake.input.get("haplotype_variants")
if haplotype_variants:
    extra += f" --haplotype-variants {haplotype_variants}"

haplotype_calls = snakemake.input.get("haplotype_calls")
if haplotype_calls:
    extra += f" --haplotype-calls {haplotype_calls}"

vg_index = snakemake.input.get("vg_index")
if vg_index:
    extra += f" --vg-index {vg_index}"


# Parse params
if snakemake.params.command == "call":
    extra += f" --prior {snakemake.params.prior}"


# Finalize with output and log
shell(
    "orthanq {snakemake.params.command} {snakemake.params.subcommand} {extra} --output {snakemake.output[0]} {log}"
)