def test_refDoesntMatch_raisesError(self, mocked_variant): name = "foo" comment = "" seq = "hello world" record = Record(name, comment, seq) relative_start = 1 mocked_variant.POS = 1 mocked_variant.REF = "hall" with pytest.raises(ValueError): record.apply_variant(mocked_variant, relative_start)
def test_noAlt_returnsEmpty(self, mocked_variant): name = "foo" comment = "" seq = "hello world" record = Record(name, comment, seq) relative_start = 1 mocked_variant.POS = 1 mocked_variant.REF = "hell" mocked_variant.ALT = [] actual = record.apply_variant(mocked_variant, relative_start) expected = [] assert actual == expected
def test_variantEndsInNextLoci_skips(self, mocked_variant): name = "foo" comment = "" seq = "yyACG" record = Record(name, comment, seq) relative_start = 5 mocked_variant.POS = 7 mocked_variant.REF = "ACGTACGT" mocked_variant.ALT = ["abcdefgh"] with patch("uuid.uuid4", return_value=name) as mocked_uuid4: actual = record.apply_variant(mocked_variant, relative_start) assert mocked_uuid4.call_count == 0 expected = [] assert actual == expected
def test_oneAlt_returnsOneRecord(self, mocked_variant): name = "foo" comment = "" seq = "hello world" record = Record(name, comment, seq) relative_start = 1 mocked_variant.POS = 1 mocked_variant.REF = "hello" mocked_variant.ALT = ["hola"] with patch("uuid.uuid4", return_value=name) as mocked_uuid4: actual = record.apply_variant(mocked_variant, relative_start) assert mocked_uuid4.call_count == 1 expected_comment = f"POS=1|ALT=0|ALT_POS_IN_SEQ=[0,4)" expected = [Record(name, expected_comment, "hola world")] assert actual == expected
def test_twoAltsOneTooLong_returnsOneRecord(self, mocked_variant): name = "foo" comment = "" seq = "hello world" record = Record(name, comment, seq) max_indel_len = 3 relative_start = 2 mocked_variant.POS = 4 mocked_variant.REF = "l" mocked_variant.ALT = ["ins", "longlong"] with patch("uuid.uuid4", return_value=name) as mocked_uuid4: actual = record.apply_variant( mocked_variant, relative_start, max_indel_len=max_indel_len ) assert mocked_uuid4.call_count == 1 expected_comment1 = f"POS=4|ALT=0|ALT_POS_IN_SEQ=[2,5)" expected = [ Record(name, expected_comment1, "heinslo world"), ] assert actual == expected