Commit e6a54362 authored by Roman Sarrazin-Gendron's avatar Roman Sarrazin-Gendron
Browse files

Fixed multiple seqs, TODO fix windows

parent a0650d1a
......@@ -122,21 +122,22 @@ def get_stats(prediction_scores,modules_to_parse,threshold=-5):
for sequence in prediction_scores:
hit_dict = {}
n_sequences=n_sequences+1
for window in prediction_scores[sequence]:
scored_positions = {}
#print(window)
for module in window:
scored_positions[module] = []
#print("SCANNING",module,window[module])
#for window in prediction_scores[sequence]:
window = prediction_scores[sequence]
scored_positions = {}
#print(window)
for module in window:
scored_positions[module] = []
#print("SCANNING",module,window[module])
mod_number = module
if len(window[module])>0:
max_score = sorted(window[module],key=itemgetter(2),reverse=True)[0][2]
if max_score>threshold and window[module][0][1] not in scored_positions[module]:
#print("admissible score")
scored_positions[module].append(window[module][0][1])
hit_dict[module]=True
mod_number = module
if len(window[module])>0:
max_score = sorted(window[module],key=itemgetter(2),reverse=True)[0][2]
if max_score>threshold and window[module][0][1] not in scored_positions[module]:
#print("admissible score")
scored_positions[module].append(window[module][0][1])
hit_dict[module]=True
for mod in hit_dict:
if hit_dict[mod]:
n_hits[mod]+=1
......@@ -258,7 +259,7 @@ def run_fasta(input, modules_to_parse, dataset, ss="", arguments={}):
if len(sequences[0]) < 3000:
maxs = run_BP(sequences, ss, modules_to_parse, dataset, "NONE", aln= aln, t= t, samplesize=samplesize, pretrained=pretrained, Lambda=Lambda, Theta=Theta, Delta=Delta, fuzzy=fuzzy, verbose=verbose, first_run=first_run)
first_run=False
prediction_scores[id] = [maxs]
prediction_scores[id] = maxs
if interm:
print(maxs)
......@@ -330,7 +331,7 @@ def run_fasta(input, modules_to_parse, dataset, ss="", arguments={}):
if len(sequences[0]) < 3000:
maxs = run_BP(sequences, ss, modules_to_parse, dataset, "NONE", aln= aln, t= t, samplesize=samplesize, pretrained=pretrained, Lambda=Lambda, Theta=Theta, Delta=Delta, fuzzy=fuzzy, verbose=verbose, first_run=first_run)
first_run=False
prediction_scores[id] = [maxs]
prediction_scores[id] = maxs
if interm:
print(maxs)
......@@ -398,7 +399,7 @@ def run_fasta(input, modules_to_parse, dataset, ss="", arguments={}):
first_run=False
if interm:
print(maxs)
prediction_scores[id] = [maxs]
prediction_scores[id] = maxs
else:
all_maxes = []
......@@ -452,7 +453,7 @@ def run_fasta(input, modules_to_parse, dataset, ss="", arguments={}):
if len(seq)<300:
maxs = run_BP(seq, ss, modules_to_parse, dataset, "NONE", aln= aln, t= t, samplesize=samplesize, pretrained=pretrained, Lambda=Lambda, Theta=Theta, Delta=Delta, fuzzy=fuzzy, verbose=verbose, first_run=first_run)
first_run=False
prediction_scores[id] = [maxs]
prediction_scores[id] = maxs
else:
all_maxes = []
......@@ -573,15 +574,16 @@ def check_already_there(results, new_range, new_mod):
def present_output(all_maxes, threshold, offset=0):
OUTPUT_STRING = ""
output = []
for m in all_maxes:
#for m in all_maxes:
#print("all_maxes",m)
for current_module in sorted(m.keys()):
if len(m[current_module])<1:
continue
for sub_max in m[current_module]:
this_max = [round(sub_max[2], 3), seq_ranges(sub_max[1]),sub_max[0]]
if this_max[0] > threshold and not check_already_there(output, this_max, current_module):
output.append(["|", current_module, *this_max, "|"])
m = all_maxes
for current_module in sorted(m.keys()):
if len(m[current_module])<1:
continue
for sub_max in m[current_module]:
this_max = [round(sub_max[2], 3), seq_ranges(sub_max[1]),sub_max[0]]
if this_max[0] > threshold and not check_already_there(output, this_max, current_module):
output.append(["|", current_module, *this_max, "|"])
output = sorted(output)
#print(output)
OUTPUT_STRING=OUTPUT_STRING+("=========================================================================================\n")
......@@ -708,8 +710,16 @@ if __name__ == "__main__":
print(toPrint)
#generate SVG
outName = arguments["o"]
for seqCounter,inputSeqKey in enumerate(list(all_results.keys())):
modules_in_svg, chef_ss = bp_chefs_choice(all_results[inputSeqKey],seqInfo[seqCounter],arguments["t"],arguments["o"])
if seqCounter>0:
finalName = outName+str(counter)
else:
finalName = outName
#print("THE HITS")
#print(all_results[inputSeqKey])
modules_in_svg, chef_ss = bp_chefs_choice(all_results[inputSeqKey],seqInfo[seqCounter],arguments["t"],finalName)
#now we need to fill svg hits
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment