def test_extras_reverse(self): loc = build_compound([(6, 9), (0, 3), (15, 18)], -1) lower, upper = splitter(loc) self.check_pairs(lower, [(6, 9), (0, 3)]) self.check_pairs(upper, [(15, 18)]) loc = build_compound([(0, 3), (15, 18), (6, 9)], -1) lower, upper = splitter(loc) self.check_pairs(lower, [(0, 3)]) self.check_pairs(upper, [(15, 18), (6, 9)])
def test_not_bridging_reverse(self): loc = build_compound([(9, 12), (0, 3)], -1) with self.assertRaisesRegex(ValueError, "Location does not bridge origin"): print(splitter(loc)) loc = build_compound([(15, 18), (9, 12), (0, 3)], -1) with self.assertRaisesRegex(ValueError, "Location does not bridge origin"): print(splitter(loc))
def test_bad_strand(self): loc = build_compound([(9, 12), (0, 3)], -1) loc.parts[0].strand = 1 loc.parts[1].strand = -1 assert loc.strand is None with self.assertRaisesRegex(ValueError, "Cannot separate bridged location without a valid strand"): print(splitter(loc))
def test_unusable(self): # this format crosses the origin multiple times and can't be interpreted raw_loc_parts = [(0, 3), (6, 9), (12, 15), (18, 21)] # test a variety of badly ordered parts for ordering in [[0, 2, 1, 3], [0, 1, 3, 2], [0, 3, 1, 2]]: # cycle them around to test position independence for i in range(len(ordering)): loc_parts = [ raw_loc_parts[i] for i in ordering[i:] + ordering[:i] ] # forward loc = build_compound(loc_parts, 1) assert is_bridged(loc) with self.assertRaisesRegex( ValueError, "cannot determine correct ordering"): splitter(loc) # reverse loc = build_compound(loc_parts[::-1], -1) assert is_bridged(loc) with self.assertRaisesRegex( ValueError, "cannot determine correct ordering"): splitter(loc)
def test_frameshifts(self): loc = build_compound([(4772224, 4772573), (4772572, 4773186), (0, 258)], 1) low, high = splitter(loc) assert low == loc.parts[2:] assert high == loc.parts[0:2]
def test_not_bridging_forward(self): loc = build_compound([(0, 3), (9, 12)], 1) with self.assertRaisesRegex(ValueError, "Location does not bridge origin"): print(splitter(loc))
def test_simple_reverse(self): loc = build_compound([(0, 3), (9, 12)], -1) lower, upper = splitter(loc) self.check_pairs(lower, [(0, 3)]) self.check_pairs(upper, [(9, 12)])
def test_simple_forward(self): loc = build_compound([(9, 12), (0, 3)], 1) lower, upper = splitter(loc) self.check_pairs(lower, [(0, 3)]) self.check_pairs(upper, [(9, 12)])