From 8636ff8120979f98651eb57aa75418ed4d57f110 Mon Sep 17 00:00:00 2001 From: Luca Venturini Date: Wed, 7 Oct 2015 16:43:41 +0100 Subject: [PATCH] BF again for BLAST loading --- mikado_lib/loci_objects/transcript.py | 4 +--- mikado_lib/serializers/blast_serializer.py | 11 ++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mikado_lib/loci_objects/transcript.py b/mikado_lib/loci_objects/transcript.py index 9a18854b7..ab60c0ae1 100644 --- a/mikado_lib/loci_objects/transcript.py +++ b/mikado_lib/loci_objects/transcript.py @@ -1271,9 +1271,7 @@ def __recalculate_hit(self, hit, boundary): pass else: hsp_dict_list.append(hsp) - if (hsp["hsp_evalue"] < best_hsp[0] or - (hsp["hsp_evalue"] == best_hsp[0] and - hsp["hsp_bits"] > best_hsp[1])): + if (hsp["hsp_evalue"] < best_hsp[0]): best_hsp = (hsp["hsp_evalue"], hsp["hsp_bits"]) q_intervals.append((hsp["query_hsp_start"], hsp["query_hsp_end"])) diff --git a/mikado_lib/serializers/blast_serializer.py b/mikado_lib/serializers/blast_serializer.py index 0f1a23a09..04c8b9c2a 100644 --- a/mikado_lib/serializers/blast_serializer.py +++ b/mikado_lib/serializers/blast_serializer.py @@ -1060,9 +1060,7 @@ def prepare_hit(cls, hit, query_id, target_id, **kwargs): hsp_dict["hsp_length"] = hsp.align_length hsp_dict["hsp_bits"] = hsp.bits hsp_dict["hsp_evalue"] = hsp.expect - if (hsp_dict["hsp_evalue"] < best_hsp[0] or - (hsp_dict["hsp_evalue"] == best_hsp[0] and - hsp_dict["hsp_bits"] > best_hsp[1])): + if (hsp_dict["hsp_evalue"] < best_hsp[0]): best_hsp = (hsp_dict["hsp_evalue"], hsp_dict["hsp_bits"]) hsp_dict["query_id"] = query_id @@ -1086,7 +1084,10 @@ def prepare_hit(cls, hit, query_id, target_id, **kwargs): hit_dict["target_end"] = t_merged_intervals[-1][1] hit_dict["global_identity"] = len(identical_positions) * 100 / q_aligned hit_dict["global_positives"] = len(positives) * 100 / q_aligned - assert hit_dict["evalue"] == best_hsp[0] - assert hit_dict["bits"] == best_hsp[1] + if hit_dict["evalue"] != best_hsp[0] or hit_dict["bits"] != best_hsp[1]: + raise ValueError("Discrepant evalue/bits for hsps and hit; best: {0}, reported {1}".format( + best_hsp, + (hit_dict["evalue"], hit_dict["bits"]) + )) return hit_dict, hsp_dict_list