Skip to content

Commit 0deceb4

Browse files
committed
update for pip
1 parent 32a8d3d commit 0deceb4

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

grim/conf/minimal-configuration.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@
3535
"number_of_pop_results": 100,
3636
"output_MUUG": true,
3737
"output_haplotypes": true,
38-
"node_csv_file": "imputation/graph_generation/output/csv/nodes.csv",
39-
"edges_csv_file": "imputation/graph_generation/output/csv/edges.csv",
40-
"info_node_csv_file": "imputation/graph_generation/output/csv/info_node.csv",
41-
"top_links_csv_file": "imputation/graph_generation/output/csv/top_links.csv",
38+
"graph_files_path": "output/csv" ,
39+
"node_csv_file": "nodes.csv",
40+
"edges_csv_file": "edges.csv",
41+
"info_node_csv_file": "info_node.csv",
42+
"top_links_csv_file": "top_links.csv",
4243
"imputation_in_file": "validation/simulation/data/simulated_donor.csv",
4344
"imputation_out_umug_freq_filename": "don.umug.freqs",
4445
"imputation_out_umug_pops_filename": "don.umug.pops",
4546
"imputation_out_hap_freq_filename": "don.hap.freqs",
4647
"imputation_out_hap_pops_filename": "don.hap.pops",
4748
"imputation_out_miss_filename": "don.miss",
4849
"imputation_out_problem_filename": "don.problem",
49-
"max_haplotypes_number_in_phase": 100
50+
"max_haplotypes_number_in_phase": 100,
51+
"imuptation_out_path": "output"
5052
}

grim/grim.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,21 @@
3030
from .imputation.imputegl.networkx_graph import Graph
3131
import os
3232

33-
def graph_freqs(conf_file = "", freq_file='default', path='default', for_em = False, em_pop=None ):
33+
def graph_freqs(conf_file = "", for_em = False, em_pop=None ):
3434
if conf_file == "":
3535
conf_file = os.path.dirname(os.path.realpath(__file__)) + '/conf/minimal-configuration.json'
36-
if path == "default":
37-
path = os.path.dirname(os.path.realpath(__file__)) + '/imputation/graph_generation/'
38-
if freq_file == "default":
39-
freq_file = 'output/hpf.csv'
4036

41-
generate_neo4j_multi_hpf.generate_graph(freq_file=freq_file, path=path, config_file=conf_file, em_pop=em_pop,
37+
38+
generate_neo4j_multi_hpf.generate_graph(config_file=conf_file, em_pop=em_pop,
4239
em=for_em)
4340

4441
def impute(conf_file = ""):
45-
project_dir = ""
42+
project_dir_in_file, project_dir_graph = "", ""
4643
if conf_file == "":
4744
conf_file = os.path.dirname(os.path.realpath(__file__)) + '/conf/minimal-configuration.json'
48-
project_dir = os.path.dirname(os.path.realpath(__file__)) + '/'
49-
runfile.run_impute(conf_file, project_dir)
45+
project_dir_graph = os.path.dirname(os.path.realpath(__file__)) + '/imputation/graph_generation/'
46+
project_dir_in_file = os.path.dirname(os.path.realpath(__file__)) + '/'
47+
runfile.run_impute(conf_file, project_dir_graph, project_dir_in_file)
5048

5149
def impute_instance(config):
5250
graph = Graph(config)

grim/imputation/graph_generation/generate_neo4j_multi_hpf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,17 @@ def loci_order(loc_values):
192192

193193
return FULL_LOCI, full_name_index_dict
194194

195-
def generate_graph(freq_file = 'output/hpf.csv', path = '', config_file = "../../conf/minimal-configuration.json", em_pop = None, em= False):
195+
def generate_graph(config_file = "../../conf/minimal-configuration.json", em_pop = None, em= False):
196196
##############################################################################
197197
# Configure
198198
##############################################################################
199199
# set output directory and create it if it doesn't exist
200-
csvdir = path +"output/csv"
200+
csvdir = "output/csv"
201201
pathlib.Path(csvdir).mkdir(parents=True, exist_ok=True)
202202

203+
203204
# Input file
204-
freq_file = path + freq_file
205+
#freq_file = path + freq_file
205206

206207
parser = argparse.ArgumentParser()
207208
parser.add_argument("-c", "--config",
@@ -222,6 +223,9 @@ def generate_graph(freq_file = 'output/hpf.csv', path = '', config_file = "../..
222223
pops = em_pop
223224
freq_trim = conf.get("freq_trim_threshold")
224225

226+
freq_file = conf.get("freq_file", "default" )
227+
if freq_file == "default":
228+
freq_file = os.path.dirname(os.path.realpath(__file__)) + '/output/hpf.csv'
225229
dict_count_of_pop = {}
226230
#if em:
227231
for pop in pops:

grim/validation/runfile.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@
1414
#pr = cProfile.Profile()
1515
#pr.enable()
1616

17-
def run_impute(conf_file = "../conf/minimal-configuration.json", project_dir = ""):
17+
def run_impute(conf_file = "../conf/minimal-configuration.json", project_dir_graph = "", project_dir_in_file = ""):
1818

1919
configuration_file = conf_file
2020

2121
#project_dir = ""# "../"
22-
output_dir = "output/"
22+
#output_dir = "output/"
2323

2424

2525
# Read configuration file and load properties
2626
with open(configuration_file) as f:
2727
json_conf = json.load(f)
2828

29+
graph_files_path = json_conf.get("graph_files_path")
30+
if graph_files_path[-1] != '/':
31+
graph_files_path += '/'
32+
output_dir = json_conf.get("imuptation_out_path", "output")
33+
if output_dir[-1] != '/':
34+
output_dir += '/'
2935
config = {
3036
"planb": json_conf.get('planb', True),
3137
"pops": json_conf.get('populations'),
@@ -35,10 +41,10 @@ def run_impute(conf_file = "../conf/minimal-configuration.json", project_dir = "
3541
"number_of_pop_results": json_conf.get('number_of_pop_results', 100),
3642
"output_MUUG": json_conf.get("output_MUUG", True),
3743
"output_haplotypes": json_conf.get("output_haplotypes", False),
38-
"node_file": project_dir + json_conf.get("node_csv_file"),
39-
"top_links_file": project_dir + json_conf.get("top_links_csv_file"),
40-
"edges_file": project_dir + json_conf.get("edges_csv_file"),
41-
"imputation_input_file": project_dir+ json_conf.get("imputation_in_file"),
44+
"node_file": project_dir_graph + graph_files_path + json_conf.get("node_csv_file"),
45+
"top_links_file": project_dir_graph + graph_files_path + json_conf.get("top_links_csv_file"),
46+
"edges_file": project_dir_graph + graph_files_path +json_conf.get("edges_csv_file"),
47+
"imputation_input_file": project_dir_in_file + json_conf.get("imputation_in_file"),
4248
"imputation_out_umug_freq_file": output_dir + json_conf.get("imputation_out_umug_freq_filename"),
4349
"imputation_out_umug_pops_file": output_dir + json_conf.get("imputation_out_umug_pops_filename"),
4450
"imputation_out_hap_freq_file": output_dir + json_conf.get("imputation_out_hap_freq_filename"),
@@ -55,11 +61,11 @@ def run_impute(conf_file = "../conf/minimal-configuration.json", project_dir = "
5561
[[1], [2, 3], [4], [5]],
5662
[[1], [2], [3], [4], [5]]
5763
]),
58-
"pops_count_file": project_dir + json_conf.get("pops_count_file",'' ),
64+
"pops_count_file": project_dir_graph + json_conf.get("pops_count_file",'' ),
5965
"use_pops_count_file": json_conf.get("pops_count_file",False),
6066
"number_of_options_threshold": json_conf.get("number_of_options_threshold", 100000),
6167
"max_haplotypes_number_in_phase": json_conf.get("max_haplotypes_number_in_phase",100 ),
62-
"bin_imputation_input_file": project_dir + json_conf.get("bin_imputation_in_file", "None"),
68+
"bin_imputation_input_file": project_dir_in_file + json_conf.get("bin_imputation_in_file", "None"),
6369
"nodes_for_plan_A": json_conf.get("Plan_A_Matrix", []),
6470
"save_mode": json_conf.get("save_space_mode", False)
6571

0 commit comments

Comments
 (0)