Skip to content
Snippets Groups Projects
Snakefile 1.76 KiB
Newer Older
Malte Nyhuis's avatar
Malte Nyhuis committed
from snakemake.utils import Paramspace
import pandas as pd


from database.case_templates.case_templates import CASE_TEMPLATES
from ntrfc.database.case_templates.case_templates import create_filelist_from_template

configfile : "casesettings.yaml"
validate(config,"config.schema.yaml")
Malte Nyhuis's avatar
Malte Nyhuis committed
TEMPLATENAME = config["case_params"]["case_type"]
TEMPLATE = CASE_TEMPLATES[TEMPLATENAME]
Malte Nyhuis's avatar
Malte Nyhuis committed
TEMPLATE_PATH = TEMPLATE.path
TEMPLATE_SCHEMA = TEMPLATE.schema
TEMPLATEFILES = create_filelist_from_template(TEMPLATENAME)
PARAMS=pd.read_csv("caseparams.tsv", sep="\t")
Malte Nyhuis's avatar
Malte Nyhuis committed
validate(PARAMS, TEMPLATE_SCHEMA)
paramspace = Paramspace(PARAMS)
Malte Nyhuis's avatar
Malte Nyhuis committed
        # Aggregate over entire parameter space (or a subset thereof if needed)
        # of course, something like this can happen anywhere in the workflow (not
        # only at the end).
        *[f"01_Simulations/{instance_pattern}/{file}" for instance_pattern in paramspace.instance_patterns for file in TEMPLATEFILES]
rule create_case:
    input:
        [f"{TEMPLATE_PATH}/{file}" for file in TEMPLATEFILES]
        # format a wildcard pattern like "alpha~{alpha}/beta~{beta}/gamma~{gamma}"
        # into a file path, with alpha, beta, gamma being the columns of the data frame
        *[f"01_Simulations/{paramspace.wildcard_pattern}/{file}" for file in TEMPLATEFILES]
    params:
        case_type = config["case_params"]["case_type"],
        # automatically translate the wildcard values into an instance of the param space
        # in the form of a dict (here: {"alpha": ..., "beta": ..., "gamma": ...})
        simulation=paramspace.instance
Malte Nyhuis's avatar
Malte Nyhuis committed
        from ntrfc.preprocessing.case_creation.create_case import create_case
        create_case(input, output,params["case_type"],params["simulation"])