comparison query.py @ 12:19ac771cf32a draft

Uploaded 20180414
author fabio
date Sat, 14 Apr 2018 07:33:58 -0400
parents 1af09c5ec0a1
children 9ec4acef30ed
comparison
equal deleted inserted replaced
11:51e30a7f48c4 12:19ac771cf32a
86 is_sabutan = False; 86 is_sabutan = False;
87 for hit in hits_block: 87 for hit in hits_block:
88 if type(hit) is dict: # sabutan 88 if type(hit) is dict: # sabutan
89 #accessions_list = accessions_list + str(hit['accession_number']) + "\t" + str(hit['score']) + "\n"; 89 #accessions_list = accessions_list + str(hit['accession_number']) + "\t" + str(hit['score']) + "\n";
90 accession_number = hit['accession_number']; 90 accession_number = hit['accession_number'];
91 #------------
92 #score = hit['score'];
93 #score_split = score.split("/");
94 #accessions_dict[accession_number] = "{0:.6f}".format(float(score_split[0])/float(score_split[1]));
95 #------------
96 fraction = hit['fraction'];
91 score = hit['score']; 97 score = hit['score'];
92 score_split = score.split("/"); 98 accession_scores = {
93 accessions_dict[accession_number] = "{0:.6f}".format(float(score_split[0])/float(score_split[1])); 99 "fraction": str(fraction),
100 "score": float(score)
101 }
102 accessions_dict[accession_number] = accession_scores;
94 is_sabutan = True; 103 is_sabutan = True;
95 else: # all-some 104 else: # all-some
96 accessions_list = accessions_list + str(hit) + "\n"; 105 accessions_list = accessions_list + str(hit) + "\n";
97 if is_sabutan: 106 if is_sabutan:
98 sorted_accessions = sorted(accessions_dict, key=lambda i: float(accessions_dict[i])); 107 sorted_accessions = sorted(accessions_dict, key=lambda i: float(accessions_dict[i]["score"]), reverse=True);
99 for acc in sorted_accessions: 108 for acc in sorted_accessions:
100 accessions_list = accessions_list + str(acc) + "\t" + str(accessions_dict[acc]) + "\n"; 109 accessions_list = accessions_list + str(acc) + "\t" + str(accessions_dict[acc]) + "\n";
101 with open(output_file_path, 'w') as out: 110 with open(output_file_path, 'w') as out:
102 out.write(accessions_list.strip()); 111 out.write(accessions_list.strip());
103 return sys.exit(OK_EXIT_CODE); 112 return sys.exit(OK_EXIT_CODE);