# run as "snakemake --cores all --use-conda --use-singularity --singularity-prefix=/media --singularity-args="-B /media:/media" -p all"
# TODO: add reporting https://github.com/tanaes/snarkmark/blob/master/rules/report.rule

from os.path import join

flow               = config["flow"]
is_client          = config["mode"] == "client"
use_simulated_ibd  = config["use_simulated_ibd"] if "use_simulated_ibd" in config else False

REF_DIR            = config["ref_dir"]
# print('REF_DIR: ', REF_DIR)
# print('REF DIR type ', type(REF_DIR))
# print('grch37', config["reference"]["GRCh37_fasta"])
# print('grch37 type', type(config["reference"]["GRCh37_fasta"]))

GRCH37_FASTA       = join(REF_DIR, config["reference"]["GRCh37_fasta"]["file"])
GENETIC_MAP        = join(REF_DIR, config["reference"]["GENETIC_MAP"]["file"])
GENETIC_MAP_GRCH37 = join(REF_DIR, config["reference"]["genetic_map_GRCh37"]["file"])
REF_VCF            = join(REF_DIR, config["reference"]["vcfRef"]["file"])
REF_HAPS           = join(REF_DIR, config["reference"]["refHaps"]["file"])
LIFT_CHAIN         = join(REF_DIR, config["reference"]["lift_chain"]["file"])
CMMAP              = join(REF_DIR, config["reference"]["cmmap"]["file"])
SITE_1000GENOME    = join(REF_DIR, config["reference"]["SITE_1000GENOME"]["file"])
HAPMAP_PED         = join(REF_DIR, config["reference"]["hapmap_ped"]["file"])
HAPMAP_MP          = join(REF_DIR, config["reference"]["hapmap_mp"]["file"])
HAPMAP_FAM         = join(REF_DIR, config["reference"]["hapmap_fam"]["file"])
PEDSIM_MAP         = join(REF_DIR, config["reference"]["pedsim_map"]["file"])

print('execution mode is: ' + config["mode"])

CHROMOSOMES     = [str(i) for i in range(1, 23)]
PLINK_FORMATS   = ['bed', 'bim', 'fam']
PLINK_FORMATS_EXT   = ['bed', 'bim', 'fam', 'nosex']

# include: "rules/report.rule"

# if config["mode"] == "all":
#     ruleorder: convert_imputed_to_plink > merge_convert_imputed_to_plink
# else:
#     ruleorder: merge_convert_imputed_to_plink > convert_imputed_to_plink

rule all:
    input:
        "results/relatives.tsv",
        # rules.report_benchmark_summary.output


if flow == 'ibis':
    include: "../../rules/relatives_ibis.smk"
elif flow == 'germline':
    include: "../../rules/relatives.smk"
elif flow == 'ibis_king':
    include: "../../rules/relatives_ibis_king.smk"
