Skip to content
Snippets Groups Projects
Commit e141bf23 authored by Coralie Rohmer's avatar Coralie Rohmer
Browse files

fix total_data_format for threshold

parent 34bab247
No related branches found
No related tags found
No related merge requests found
......@@ -111,17 +111,18 @@ bases=[]
reads=[]
MSA={}
for threshold in files :
data["order"]=[]
data[threshold]={}
data[threshold]["order"]=[]
for exp_name in files[threshold] :
data[exp_name]={}
data[exp_name]["order"]=[]
data["order"]=data["order"] + [exp_name]
data[threshold][exp_name]={}
data[threshold][exp_name]["order"]=[]
data[threshold]["order"]=data[threshold]["order"] + [exp_name]
header=[]
header_size=0
for dir in files[threshold][exp_name]:
data[exp_name][dir] = {}
data[threshold][exp_name][dir] = {}
MSA[exp_name]=[]
data[exp_name]["order"]=data[exp_name]["order"] + [dir]
data[threshold][exp_name]["order"]=data[threshold][exp_name]["order"] + [dir]
name_file = os.path.join(EXP,exp_name,dir,RESULT_FOLDER,files[threshold][exp_name][dir])
try:
read = open(name_file, "r")
......@@ -133,10 +134,10 @@ for threshold in files :
base_pair=int(tab_line[1])
nb_read=int(tab_line[2])
if (base_pair not in data[exp_name][dir]):
data[exp_name][dir][base_pair] = {}
if (nb_read not in data[exp_name][dir][base_pair]):
data[exp_name][dir][base_pair][nb_read] = {}
if (base_pair not in data[threshold][exp_name][dir]):
data[threshold][exp_name][dir][base_pair] = {}
if (nb_read not in data[threshold][exp_name][dir][base_pair]):
data[threshold][exp_name][dir][base_pair][nb_read] = {}
if (base_pair not in bases):
bases.append(base_pair)
......@@ -145,9 +146,9 @@ for threshold in files :
if (msa not in MSA[exp_name]):
MSA[exp_name].append(msa)
data[exp_name][dir][base_pair][nb_read][msa] = {}
data[threshold][exp_name][dir][base_pair][nb_read][msa] = {}
for i in range(3,header_size):
data[exp_name][dir][base_pair][nb_read][msa][header[i]] = tab_line[i]
data[threshold][exp_name][dir][base_pair][nb_read][msa][header[i]] = tab_line[i]
else:
header=tab_line
header_size=len(header)
......@@ -181,8 +182,8 @@ for threshold in files :
output_mean.write(",,")
if(not re.search("^sd_",attribute)):
output_all.write(",,")
for exp_name in data["order"]:
for dir in data[exp_name]["order"]:
for exp_name in data[threshold]["order"]:
for dir in data[threshold][exp_name]["order"]:
if dir == "":
output_mean.write("," + exp_name)
for msa in MSA[exp_name]:
......@@ -195,8 +196,8 @@ for threshold in files :
output_mean.write("\nlenght,cover,")
if(not re.search("^sd_",attribute)):
output_all.write("\nlenght,cover,")
for exp_name in data["order"]:
for dir in data[exp_name]["order"]:
for exp_name in data[threshold]["order"]:
for dir in data[threshold][exp_name]["order"]:
if dir == "":
for msa in MSA[exp_name]:
output_mean.write("," + msa)
......@@ -218,20 +219,20 @@ for threshold in files :
output_mean.write(str(base) + "," + str(read) + ",")
if(not re.search("^sd_",attribute)):
output_all.write(str(base) + "," + str(read) + ",")
for exp_name in data["order"]:
for dir in data[exp_name]["order"]:
for exp_name in data[threshold]["order"]:
for dir in data[threshold][exp_name]["order"]:
if dir == "":
for msa in MSA[exp_name]:
if (base in data[exp_name][dir]) and (read in data[exp_name][dir][base]) and (msa in data[exp_name][dir][base][read]):
output_mean.write("," + data[exp_name][dir][base][read][msa][attribute])
if (base in data[threshold][exp_name][dir]) and (read in data[threshold][exp_name][dir][base]) and (msa in data[threshold][exp_name][dir][base][read]):
output_mean.write("," + data[threshold][exp_name][dir][base][read][msa][attribute])
else:
output_mean.write(",")
output_mean.write(",")
else:
if(not re.search("^sd_",attribute)):
for msa in MSA[exp_name]:
if (base in data[exp_name][dir]) and (read in data[exp_name][dir][base]) and (msa in data[exp_name][dir][base][read]):
output_all.write("," + data[exp_name][dir][base][read][msa][attribute])
if (base in data[threshold][exp_name][dir]) and (read in data[threshold][exp_name][dir][base]) and (msa in data[threshold][exp_name][dir][base][read]):
output_all.write("," + data[threshold][exp_name][dir][base][read][msa][attribute])
else:
output_all.write(",")
output_all.write(",")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment