Skip to content

Allow ranges marked as 'unspecified' to overlap #501

@bencap

Description

@bencap

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 ScoreRangeBase object:
    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_specified class may overlap with only other not_specified classes.
  • Evaluate the bold note at the top of this description and implement any decisions related to that.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions