-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtapioca.py
56 lines (48 loc) · 2.38 KB
/
tapioca.py
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
import predict as p
import preprocess as pre
import scripts as scr
import os
def run_tapioca(input_file, ref_channel, pre_normalized, co_fractionation, tissue, base_save_name, full_model):
if pre_normalized == False:
if co_fractionation == False:
logistic_curve_fit = True
if os.path.exists('./raw_input/' + input_file):
input_file = './raw_input/' + input_file
normalized_file = pre.preprocess(input_file, ref_norm=ref_channel,
logistic_curve_fit=logistic_curve_fit)
else:
raise FileNotFoundError('Error, could not find the input file')
else:
logistic_curve_fit = False
if os.path.exists('./raw_input/' + input_file):
input_file = './raw_input/' + input_file
normalized_file = pre.preprocess(input_file, ref_norm=ref_channel,
logistic_curve_fit=logistic_curve_fit)
else:
raise FileNotFoundError('Error, could not find the input file')
else:
if os.path.exists('./normalized_input/' + input_file):
input_file = './normalized_input/' + input_file
normalized_file = input_file
else:
raise FileNotFoundError('Error, could not find the input file')
if full_model == False:
model_type = 'B'
else:
model_type = 'F'
curve_points = scr.get_curve_points(normalized_file)
conditions = scr.get_conditions(normalized_file)
replicates = scr.get_replicates(normalized_file)
master_curve_dict = scr.create_master_curve_dict(normalized_file, curve_points=curve_points)
if co_fractionation == True:
master_curve_dict = pre.normalzie_cofrac_dict(master_curve_dict)
if tissue != '':
tissue_address = './data/tissue_functional_networks/' + tissue
else:
tissue_address = tissue
for rep in replicates:
for cond in conditions:
rep_cond_base_save_name = base_save_name + '_' + cond + '_rep_' + rep
curve_dict = scr.curve_dict_from_pd_master_curve_dict(master_curve_dict, rep, condition=cond,
curve_points_len=len(curve_points))
p.tapioca_predict(rep_cond_base_save_name, tissue_address, curve_dict, curve_points, model_type)