from snakemake.utils import min_version
# 8: envs/cellqc.yaml's floor, and the version the qcstatus checkpoint was
# written against -- temp() outputs are kept until every pending checkpoint has
# run, which is what lets postproc's temp() matrix wait for `publish`.
min_version("8.0")

include: "rules/config.smk"
include: "rules/common.smk"

rule all:
  input:
    final_targets(),
    published_targets,

include: "rules/ambient.smk"
include: "rules/barcoderank.smk"
include: "rules/nuclear_fraction.smk"
include: "rules/filterbycount.smk"

# Doublet callers are selected by config, not by conditional rule inclusion.
# Both rule files are always defined; `doublet.run` decides which outputs are
# ever requested, and `doublet.decider` decides which one removes cells. That
# keeps the DAG shape fixed no matter how the callers are configured, and it is
# why there is no skip flag left to thread through the includes.
include: "rules/doubletfinder.smk"
include: "rules/scdblfinder.smk"

include: "rules/filterdoublet.smk"
include: "rules/postproc.smk"
# Resolves per-sample, per-step status into result/qc_status.csv and decides
# which samples are published to result/. Nothing before it fails the run on a
# sample's account.
include: "rules/qcstatus.smk"
include: "rules/qcreport.smk"
include: "rules/slidereport.smk"

onsuccess:
  run_outcome()
