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

from ntrfc.database.case_templates.case_templates import CASE_TEMPLATES
TEMPLATE = CASE_TEMPLATES[config["case_params"]["case_type"]]
PARAMS = pd.read_csv("caseparams.tsv",sep="\t")


def validate_configuration(config):
    validate(config,"config.schema.yaml")
    # todo: the next line is not working. currently TEMPLATE.schema does not have the right format
    validate(PARAMS, TEMPLATE.schema)
    paramspace = Paramspace(PARAMS)
    return paramspace, config
paramspace, config = validate_configuration(config)
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 TEMPLATE.files]
rule create_case:
    input:
        [f"{TEMPLATE.path}/{file}" for file in TEMPLATE.files]
        # 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 TEMPLATE.files]
    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": ...})
Malte Nyhuis's avatar
Malte Nyhuis committed
        from ntrfc.preprocessing.case_creation.create_case import create_case
        from ntrfc.utils.dictionaries.dict_utils import merge
        print(params["simparams"])
        print(config["case_options"])
        simconfig = merge(params["simparams"],config["case_options"])
        create_case(input,output,params["case_type"],simconfig)