Skip to content

Commit 32bf35c

Browse files
committed
Fix lint issues
Merge branch 'Regev32-MLO' into MLO
2 parents 75bc2b9 + aad6608 commit 32bf35c

File tree

4 files changed

+529
-3
lines changed

4 files changed

+529
-3
lines changed

RunGrim.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import json
2+
import os
3+
import pandas as pd
4+
5+
from graph_generation.generate_hpf import produce_hpf
6+
from grim.grim import graph_freqs
7+
from grim.grim import impute
8+
from filter_top_3 import change_donor_file
9+
from filter_by_rest import change_output_by_extra_gl
10+
11+
12+
def remove_empty_rows(file_path):
13+
df = pd.read_csv(file_path)
14+
15+
df_cleaned = df.dropna(how="all")
16+
17+
df_cleaned.to_csv(file_path, index=False)
18+
19+
20+
def run_original_grim(
21+
path_configuration, hap_pop_pair=True, Producehpf=False, dominant3=True
22+
):
23+
with open(path_configuration, "r") as f:
24+
config = json.load(f)
25+
26+
# first step in py-graph-imputation
27+
if Producehpf:
28+
produce_hpf(conf_file=path_configuration)
29+
30+
path_hpf = config["freq_file"]
31+
# remove empty rows from hpf otherwise doesnt work
32+
remove_empty_rows(path_hpf)
33+
34+
# second step in py-graph-imputation
35+
graph_freqs(conf_file=path_configuration)
36+
37+
# changing donor file to 3 most imporatnt gls and returning short_gl,extra_gl for each row in donor
38+
if dominant3:
39+
path_donor = config["imputation_in_file"]
40+
41+
gls, lines = change_donor_file(path_donor) # change so wont change donor file
42+
43+
# imputation
44+
impute(conf_file=path_configuration, hap_pop_pair=hap_pop_pair)
45+
46+
# change the output and filter by the extra_gl
47+
if dominant3:
48+
path_pmug = os.path.join(
49+
config["imputation_out_path"], config["imputation_out_hap_freq_filename"]
50+
)
51+
path_umug = os.path.join(
52+
config["imputation_out_path"], config["imputation_out_umug_freq_filename"]
53+
)
54+
path_umug_pops = os.path.join(
55+
config["imputation_out_path"], config["imputation_out_umug_pops_filename"]
56+
)
57+
path_pmug_pops = os.path.join(
58+
config["imputation_out_path"], config["imputation_out_hap_pops_filename"]
59+
)
60+
path_miss = os.path.join(
61+
config["imputation_out_path"], config["imputation_out_miss_filename"]
62+
)
63+
64+
change_output_by_extra_gl(
65+
config, gls, path_pmug, path_umug, path_umug_pops, path_pmug_pops, path_miss
66+
) # filter reasults in our origianl file, add miss to existing miss
67+
68+
# changing to original donor file
69+
with open(path_donor, "w") as file:
70+
for line in lines:
71+
file.write(line)
72+
file.close()
73+
74+
75+
if __name__ == "__main__":
76+
conf_file = "conf/minimal-configuration.json"
77+
run_original_grim(conf_file, True, True, True)

conf/minimal-configuration.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"populations": [
33
"CAU"
44
],
5-
"freq_trim_threshold": 1e-5,
5+
"freq_trim_threshold": 0.1,
66
"priority": {
77
"alpha": 0.4999999,
88
"eta": 0,
@@ -29,10 +29,10 @@
2929
[[1], [2, 3], [4], [5]],
3030
[[1], [2], [3], [4], [5]]
3131
],
32-
"planb": true,
32+
"planb": false,
3333
"number_of_options_threshold": 100000,
3434
"epsilon": 1e-3,
35-
"number_of_results": 10,
35+
"number_of_results": 1000,
3636
"number_of_pop_results": 100,
3737
"output_MUUG": true,
3838
"output_haplotypes": true,

0 commit comments

Comments
 (0)