
"""
This is the main phylogenetic Snakefile that orchestrates the full phylogenetic
workflow and defines its default output(s).
"""
# The workflow filepaths are written relative to this Snakefile's base directory
workdir: workflow.current_basedir

# Use default configuration values. Override with Snakemake's --configfile/--config options.
configfile: "defaults/config.yaml"

segments = config['segments']

wildcard_constraints:
    segment = "|".join(segments)

rule all:
    input:
        auspice_tree = expand("auspice/lassa_{segment}.json", segment=segments)

include: "../shared/vendored/snakemake/remote_files.smk"
include: "rules/merge_inputs.smk"
include: "rules/prepare_sequences.smk"
include: "rules/construct_phylogeny.smk"
include: "rules/annotate_phylogeny.smk"
include: "rules/export.smk"

# Allow users to import custom rules provided via the config.
# This allows users to run custom rules that can extend or override the workflow.
# A concrete example of using custom rules is the extension of the workflow with
# rules to support the Nextstrain automation that upload files and send internal
# Slack notifications.
# For extensions, the user will have to specify the custom rule targets when
# running the workflow.
# For overrides, the custom Snakefile will have to use the `ruleorder` directive
# to allow Snakemake to handle ambiguous rules
# https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#handling-ambiguous-rules
if "custom_rules" in config:
    for rule_file in config["custom_rules"]:

        include: rule_file
