Skip to content

Commit

Permalink
Add onstart + onsuccess + onerror
Browse files Browse the repository at this point in the history
  • Loading branch information
akcorut committed Nov 22, 2021
1 parent 51798c8 commit 6474655
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ min_version("6.10")
# =========================================================================================================

# Load config file
configfile: "../.test/config/maize_config.yaml"
configfile: "../.test/config_arabidopsis/config.yaml"

# validate(config, schema="../schemas/config.schema.yaml")

Expand Down Expand Up @@ -38,10 +38,39 @@ include: "rules/align_kmers.smk"
include: "rules/fetch_reads.smk"
include: "rules/align_reads.smk"

# =========================================================================================================
# The `onstart` Checker
# =========================================================================================================

onstart:
try:
print("Checking if all required files are provided...")
important_files = [ config["samples"],
config["phenotypes"] ]
for filename in important_files:
if not os.path.exists(filename):
raise FileNotFoundError(filename)
except FileNotFoundError as e:
print("This file is not available or accessible: %s" % e)
sys.exit(1)
else:
print("\tAll required files are present!")


# =========================================================================================================
# Target Outputs
# =========================================================================================================

rule all:
input:
get_target_output,

# =========================================================================================================
# Success and Failure Messages
# =========================================================================================================

onsuccess:
print("Success! The Snakemake workflow is completed.")

onerror:
print("Error! The Snakemake workflow aborted.")

0 comments on commit 6474655

Please sign in to comment.