|
|
@@ -1,6 +1,6 @@ |
|
|
|
"""Test consolidators |
|
|
|
|
|
|
|
Consolidators work on a List of Faetures, and Features a constructed from Interval objects. |
|
|
|
Consolidators work on a List of Features, and Features are constructed from Interval objects. |
|
|
|
As such, we need to mock an Interval object and a Feature object to test the consolidators. |
|
|
|
""" |
|
|
|
import unittest |
|
|
@@ -14,6 +14,11 @@ class TestOverlapConsolidation(unittest.TestCase): |
|
|
|
def __init__(self, start, end): |
|
|
|
self.start = start |
|
|
|
self.end = end |
|
|
|
|
|
|
|
def move_end(self, new_end): |
|
|
|
"""Mocked method to move the end of the interval""" |
|
|
|
self.end = new_end |
|
|
|
|
|
|
|
class MockFeature(): |
|
|
|
"""Mock feature object for overlap testing -- only has interval attribute""" |
|
|
|
def __init__(self, interval): |
|
|
@@ -36,7 +41,7 @@ class TestOverlapConsolidation(unittest.TestCase): |
|
|
|
self.assertEqual(consolidator.features, self.populated_features) |
|
|
|
|
|
|
|
def test_consolidate(self): |
|
|
|
# 4 features for overlap test: ABCD, overlap A-B, C-D |
|
|
|
# 4 features for overlap test: ABCD, overlap A-B, C-D (2) |
|
|
|
self.featureA = self.MockFeature(interval=self.MockInterval(start=0, end=10)) |
|
|
|
self.featureB = self.MockFeature(interval=self.MockInterval(start=5, end=15)) |
|
|
|
self.featureC = self.MockFeature(interval=self.MockInterval(start=20, end=30)) |
|
|
@@ -47,7 +52,7 @@ class TestOverlapConsolidation(unittest.TestCase): |
|
|
|
# check that A-B and C-D have been merged |
|
|
|
self.assertEqual(len(consolidator.features), 2) |
|
|
|
|
|
|
|
# 4 features for no overlap test |
|
|
|
# 4 features for no overlap test (4) |
|
|
|
self.feature1 = self.MockFeature(interval=self.MockInterval(start=0, end=10)) |
|
|
|
self.feature2 = self.MockFeature(interval=self.MockInterval(start=15, end=25)) |
|
|
|
self.feature3 = self.MockFeature(interval=self.MockInterval(start=30, end=40)) |
|
|
@@ -58,7 +63,7 @@ class TestOverlapConsolidation(unittest.TestCase): |
|
|
|
# check that no features have been merged |
|
|
|
self.assertEqual(len(consolidator.features), 4) |
|
|
|
|
|
|
|
# 3 features for overlap test: ABC, overlap A-B, B-C |
|
|
|
# 3 features for overlap test: ABC, overlap A-B, B-C (1) |
|
|
|
self.featureA = self.MockFeature(interval=self.MockInterval(start=0, end=10)) |
|
|
|
self.featureB = self.MockFeature(interval=self.MockInterval(start=5, end=15)) |
|
|
|
self.featureC = self.MockFeature(interval=self.MockInterval(start=12, end=20)) |
|
|
|