Skip to content

Commit

Permalink
Print an immediate error if no input samples were found.
Browse files Browse the repository at this point in the history
Also clean up the comment and remove unused glob import.
  • Loading branch information
tbooth committed Mar 6, 2024
1 parent 34c590f commit e3bf6ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 5 additions & 12 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# Main entrypoint of the workflow.
# Please follow the best practices:
# Main Snakefile and entry point of the workflow.
# Please see the best practices:
# https://snakemake.readthedocs.io/en/stable/snakefiles/best_practices.html,
# in particular regarding the standardized folder structure mentioned there.


# Main Snakefile


# set config file where you can specify your inputs
configfile: "config/config.yaml"


# import glob to read {sample}
import glob

# set {samples} wildcard
samples = glob_wildcards(config["hic_path"] + "{sample}_1.fastq.gz").sample
samples_in_pattern = "{sample}_1.fastq.gz"
samples = glob_wildcards(config["hic_path"] + samples_in_pattern).sample


# Include the hifi_prep rule
Expand Down Expand Up @@ -58,4 +51,4 @@ include: "rules/common.smk"
# input files are defined in the common.smk file
rule all:
input:
get_all_inputs(),
get_all_inputs
8 changes: 7 additions & 1 deletion workflow/rules/common.smk
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Define function for the inputs to rule_all
# this rule just defines the inputs to the final rule

def get_all_inputs(wc=None):
if not samples:
# Show the user a meaningful error message
logger.error(f"No files matching {samples_in_pattern} were found in"
f" {config.get('hic_path')}. Please check your config file.")
logger.error(f"Exiting.")
sys.exit(1)

def get_all_inputs():
inputs = [
"results/reads/hifi/hifi.fastq.gz", # output of hifi_prep rule
"results/nanoplot/NanoPlot-report.html", # nanoplot report
Expand Down

0 comments on commit e3bf6ac

Please sign in to comment.