Commit 5baf420d by Yoann Dufresne

local score computation

parent 01d8b380
 ... ... @@ -22,7 +22,8 @@ class PartialOrder: self.len_sets = 0 # The number of successive udg. Same as len(udg_order) self.len_udgs = 0 # TODO: score # This score must be updated when the order is modified self.score = 0 def _get_right_overlaps(self, udg): """" Get the overlap of an udg with the right part of the multiset partial order. ... ... @@ -78,11 +79,48 @@ class PartialOrder: self.len_barcodes += sum(new_multiset.values()) # Step 4 - Add the udg as covering the right multisets for idx in range(max(0, leftmost_idx), len(self.udg_per_set)): for idx in range(max(0, leftmost_idx), self.len_sets): self.udg_per_set[idx].add(udg) # TODO: Step 5 - Modify score def get_add_score(self, udg): score = 0 leftmost_idx, left_non_overlap, remaining_right = self._get_right_overlaps(udg) # 1 point for the rightmost future multiset if len(remaining_right) > 0: score += 1 # x points if the leftmost multiset is split in 2 (x = covering udg number) if len(left_non_overlap) > 0: score += len(self.udg_per_set[leftmost_idx]) # covering number points for the new udg score += self.len_sets - leftmost_idx # Negative points for redundant elements # shift one left remaining_size = sum(remaining_right.values()) - sum(left_non_overlap.values()) leftmost_idx -= 1 # Search for non overlapped common barcodes while remaining_size > 0 and leftmost_idx >= 0: ms = self.barcode_order[leftmost_idx] # Compute intersection common = ms & remaining_right candidate_negative = sum(common.values()) score -= min(candidate_negative, remaining_size) # Update structures remaining_right -= common remaining_size -= sum(ms.values()) leftmost_idx -= 1 return score def __len__(self): return self.len_barcodes
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!