VARLOCIRAPTOR CALL VARIANTS

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/varlociraptor/call-variants?label=version%20update%20pull%20requests

Call variants with Varlociraptor using a given scenario

URL: https://varlociraptor.github.io/docs/calling/

Example

This wrapper can be used in the following way:

rule varlociraptor_call:
    input:
        # collect preprocessed observations for the considered sample group
        # Use lookup or a custom function to obtain the list of samples
        # for the given sample group here
        # and below in the params specification.
        # Example: lookup(query="group == '{sample_group}'", cols=["sample"], within=samples)
        # assuming that samples in a pandas dataframe.
        observations=collect("results/observations/{sample}.bcf", sample=["NA12878"]),
        scenario="resources/scenarios/{sample_group}.yaml",
    output:
        "results/variant-calls/{sample_group}.bcf",
    log:
        "logs/varlociraptor/call-variants/{sample_group}.log",
    params:
        samples=["NA12878"],
        extra="",  # optional additional parameters
    wrapper:
        "v5.5.2-17-g33d5b76/bio/varlociraptor/call-variants"

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

  • varlociraptor=8.6.0

Input/Output

Input:

  • preprocessed observations for the samples in the scenario (if a sample is omitted, it will be treated as if there are no observations available)

  • a scenario

Output:

  • variants calls

Authors

  • Johannes Köster

Code

import subprocess as sp

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

# Validate inputs
samples = snakemake.params.samples
observations = snakemake.input.observations
if not isinstance(observations, list):
    observations = [observations]
if len(samples) != len(observations):
    raise ValueError("Number of samples must match number of observations")
if not samples:
    raise ValueError("At least one sample is required")
# Quote paths to handle spaces
obs = " ".join(f"{sample}='{path}'" for sample, path in zip(samples, observations))

sp.run(
    "varlociraptor call variants "
    f"{snakemake.params.get('extra', '')} "
    f"generic --obs {obs} "
    f"--scenario {snakemake.input.scenario} "
    f"> {snakemake.output[0]} {log}",
    check=True,
    shell=True,
)