-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_program.jl
117 lines (95 loc) · 3.71 KB
/
run_program.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using ArgParse, YAML, Printf
include("utils/parameter_parsing.jl")
include("preprocessing/preprocessing.jl")
include("optimisation/abc.jl")
include("algorithms/genotype/genotype_algorithm.jl")
include("algorithms/phenotype/phenotype_algorithm.jl")
include("evaluation/evaluation.jl")
"""Executes the program, according to which pipelines and configuration options are specified in the input
Note that any combination of pipelines can be run together, except the optimisation pipeline, which exits immediately after running
Also note that there is a specific ordering to the pipeline execution
"""
function run_program(pipelines, options)
if pipelines["preprocessing"]
@info "Running the preprocessing pipeline"
run_preprocessing(options)
end
if pipelines["optimisation"]
@info "Optimising model parameter values"
run_optimisation(options)
exit(0)
end
if pipelines["genotype"]
@info "Generating synthetic genotype data"
t = @elapsed begin
create_synthetic_genotype(options)
end
@info @sprintf("Genotype generation completed in %s minutes", t/60)
end
if pipelines["phenotype"]
@info "Generating synthetic phenotype data"
t = @elapsed begin
create_synthetic_phenotype(options)
end
@info @sprintf("Phenotype generation completed in %s minutes", t/60)
end
if pipelines["evaluation"]
@info "Evaluating synthetic data quality"
run_evaluation(options)
end
end
function parse_commandline()
s = ArgParseSettings()
@add_arg_table s begin
"--config"
help = "filepath to YAML configuration file"
arg_type = String
required = false
"--preprocessing"
help = "preprocesses raw data to use as input for synthetic data generation"
action = :store_true
"--genotype"
help = "generate synthetic genotype data"
action = :store_true
"--phenotype"
help = "generate synthetic phenotype data (requires synthetic genotype data input)"
action = :store_true
"--evaluation"
help = "evaluate synthetic data quality (requires synthetic genotype data input)"
action = :store_true
"--optimisation"
help = "run procedure for optimising model parameter values"
action = :store_true
end
return parse_args(s)
end
function main()
parsed_args = parse_commandline()
options = YAML.load_file("config.yaml")
if parsed_args["config"] != nothing
options_override = YAML.load_file(parsed_args["config"])
options = merge(options, options_override)
end
pipelines = Dict("preprocessing" => parsed_args["preprocessing"],
"genotype" => parsed_args["genotype"],
"phenotype" => parsed_args["phenotype"],
"evaluation" => parsed_args["evaluation"],
"optimisation" => parsed_args["optimisation"])
@info "Creating output directories"
outdirs = [@sprintf("%s/%s", options["filepaths"]["general"]["output_dir"], x) for x in ["evaluation", "optimisation", "reference"]]
push!(outdirs, options["filepaths"]["general"]["output_dir"])
for outdir in outdirs
if !isdir(outdir)
mkpath(outdir)
end
end
# set random seed for reproducibility
Random.seed!(options["global_parameters"]["random_seed"])
println("Running pipelines:")
for (arg,val) in pipelines
println(" $arg => $val")
end
@info @sprintf("Using %s thread/s for computations", Threads.nthreads())
run_program(pipelines, options)
end
main()