|
1 |
| -# Main entrypoint of the workflow. |
2 |
| -# Please follow the best practices: |
3 |
| -# https://snakemake.readthedocs.io/en/stable/snakefiles/best_practices.html, |
4 |
| -# in particular regarding the standardized folder structure mentioned there. |
| 1 | +import os |
| 2 | +from scripts.resources import Resources |
| 3 | +from scripts import general_functions as gf |
| 4 | +from snakemake.utils import min_version |
| 5 | + |
| 6 | +# set minimum snakemake version |
| 7 | +min_version("6.4.1") |
| 8 | + |
| 9 | +# load config file |
| 10 | +configfile: "config/config.yaml" |
| 11 | + |
| 12 | +# load genome resources to be used in rules |
| 13 | +resources = Resources(config["genome"], config["ensembl_genome_build"]) |
| 14 | + |
| 15 | +# get sample names |
| 16 | +SAMPLES = gf.import_samples() |
| 17 | + |
| 18 | +# import rules |
| 19 | +include: "rules/fastqc.smk" |
| 20 | +include: "rules/trimming.smk" |
| 21 | +include: "rules/resources.smk" |
| 22 | +include: "rules/damid.smk" |
| 23 | +include: "rules/bedgraph_processing.smk" |
| 24 | +include: "rules/plotting.smk" |
| 25 | + |
| 26 | +# target rule |
| 27 | +rule all: |
| 28 | + input: |
| 29 | + "results/plots/mapping_rates.pdf", |
| 30 | + "results/plots/pca.pdf", |
| 31 | + "results/plots/sample_distance.pdf", |
| 32 | + |
| 33 | + |
| 34 | +# save snakemake terminal output to log file |
| 35 | +snake_log = "logs/snakemake/snakemake.log" |
| 36 | +os.makedirs("logs/snakemake", exist_ok=True) |
| 37 | + |
| 38 | +onsuccess: |
| 39 | + shell("cp -v {log} {snake_log}") |
| 40 | + shell(f"pigz {resources.fasta}") # compress genome files |
| 41 | + print("Analysis finished successfully!") |
| 42 | + |
| 43 | +onerror: |
| 44 | + shell("cp -v {log} {snake_log}") |
| 45 | + print(f"Analysis (partly) failed...\nCheck {snake_log} for details") |
| 46 | + |
| 47 | + |
0 commit comments