-
Notifications
You must be signed in to change notification settings - Fork 2
Labels
app: backendTask implementation touches the backendTask implementation touches the backendsprint: added mid-sprintTask was added mid-sprintTask was added mid-sprinttype: enhancementEnhancement to an existing featureEnhancement to an existing feature
Description
Should we also allow ranges with normal and abnormal classifications to overlap? See urn:mavedb:00000054-a-1 (PubMed: 29706350), which is an example of such a data set where ranges with classifications were reported as overlapping.
This feature should allow ranges with the not_specified classification to overlap. We should:
- Relax the validator defined on the
ScoreRangeBaseobject:mavedb-api/src/mavedb/view_models/score_range.py
Lines 97 to 139 in 6419b01
def test_overlap(range_test: ScoreRangeBase, range_check: ScoreRangeBase) -> bool: # Always check the tuple with the lowest lower bound. If we do not check # overlaps in this manner, checking the overlap of (0,1) and (1,2) will # yield different results depending on the ordering of tuples. if min(inf_or_float(range_test.range[0], True), inf_or_float(range_check.range[0], True)) == inf_or_float( range_test.range[0], True ): range_with_min_value = range_test range_with_non_min_value = range_check else: range_with_min_value = range_check range_with_non_min_value = range_test # If both ranges have inclusive bounds and their bounds intersect, we consider them overlapping. if ( range_with_min_value.inclusive_upper_bound and range_with_non_min_value.inclusive_lower_bound and ( inf_or_float(range_with_min_value.range[1], False) == inf_or_float(range_with_non_min_value.range[0], True) ) ): return True # Since we have ordered the ranges, it's a guarantee that the lower bound of the first range is less # than or equal to the lower bound of the second range. If the upper bound of the first range is greater # than the lower bound of the second range, then the two ranges overlap. Inclusive bounds only come into # play when the boundaries are equal and both bounds are inclusive. if inf_or_float(range_with_min_value.range[1], False) > inf_or_float( range_with_non_min_value.range[0], True ): return True return False for i, range_test in enumerate(field_value): for range_check in list(field_value)[i + 1 :]: if test_overlap(range_test, range_check): raise ValidationError( f"Score ranges may not overlap; `{range_test.label}` ({range_test.range}) overlaps with `{range_check.label}` ({range_check.range})." ) return field_value - Update any associated tests and ensure
not_specifiedclass may overlap with only othernot_specifiedclasses. - Evaluate the bold note at the top of this description and implement any decisions related to that.
Metadata
Metadata
Assignees
Labels
app: backendTask implementation touches the backendTask implementation touches the backendsprint: added mid-sprintTask was added mid-sprintTask was added mid-sprinttype: enhancementEnhancement to an existing featureEnhancement to an existing feature