def test_parse_reads_with_single_read_file_returns_correct_events(
        single_read_test_file, single_read_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(single_read_test_file))
    for i, event in enumerate(reads[0].events):
        expected_event = single_read_expected["events"][i]
        assert is_event_correct(event, expected_event) == True
def test_parse_reads_with_repeated_kmer_returns_separate_events(
        repeated_kmer_test_file, repeated_kmer_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(repeated_kmer_test_file))
    for i, event in enumerate(reads[0].events):
        expected_event = repeated_kmer_expected["events"][i]
        assert is_event_correct(event, expected_event) == True
def test_parse_reads_with_model_kmer_NNNNN_returns_correct_events(
        model_kmer_NNNNN_test_file, model_kmer_NNNNN_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(model_kmer_NNNNN_test_file))
    for i, _ in enumerate(reads):
        for j, event in enumerate(reads[i].events):
            expected_event = model_kmer_NNNNN_expected[i]["events"][j]
            assert is_event_correct(event, expected_event) == True
def test_parse_reads_with_skipped_position_returns_correct_events(
        skipped_position_test_file, skipped_position_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(skipped_position_test_file))
    for i, _ in enumerate(reads):
        for j, event in enumerate(reads[i].events):
            expected_event = skipped_position_expected[i]["events"][j]
            assert is_event_correct(event, expected_event) == True
def test_parse_reads_with_repeated_position_returns_correct_indexes(
        repeated_position_test_file, repeated_position_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(repeated_position_test_file))
    for i, event in enumerate(reads[0].events):
        expected_event = repeated_position_expected["events"][i]
        assert event.start_idx == expected_event["start_idx"]
        assert event.end_idx == expected_event["end_idx"]
Esempio n. 6
0
def test_parse_writes_reads_to_h5_file_with_event_order_preserved():
    parser = AlignedEventParser(EventalignReadParser())
    parser.parse("{0}position_ordering.tsv".format(IN), OUT)
    expected_events = [
        "event-10", "event-11", "event-12", "event-101", "event-102",
        "event-103"
    ]
    actual_events = []
    with h5py.File("{0}position_ordering.h5".format(OUT), "r") as h5:
        read = h5["read-c1654154-560c-42e4-a8c1-197e9ade83fb"]
        for event in read:
            actual_events.append(event)
    assert actual_events == expected_events
Esempio n. 7
0
def test_parse_writes_reads_to_h5_file():
    parser = AlignedEventParser(EventalignReadParser())
    parser.parse("{0}multiple_reads.tsv".format(IN), OUT)
    expected_reads = {
        "read-c1654154-560c-42e4-a8c1-197e9ade83fb",
        "read-8c329395-b3c6-41f2-82a8-b2b78b4c19de",
        "read-fb90c5fa-859e-455a-87d4-cac02fa565e7"
    }
    actual_reads = set()
    with h5py.File("{0}multiple_reads.h5".format(OUT), "r") as h5:
        for read in h5.keys():
            actual_reads.add(read)
    assert actual_reads == expected_reads
def test_parse_reads_with_multiple_read_file_returns_correct_contigs(
        multiple_read_test_file, multiple_read_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(multiple_read_test_file))
    for i, read in enumerate(reads):
        assert read.contig == multiple_read_expected[i]["contig"]
def test_parse_reads_with_multiple_read_file_returns_multiple_reads(
        multiple_read_test_file, multiple_read_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(multiple_read_test_file))
    assert len(reads) == len(multiple_read_expected)
Esempio n. 10
0
def test_parse_reads_with_single_read_file_returns_correct_contig(
        single_read_test_file, single_read_expected):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(single_read_test_file))
    assert reads[0].contig == single_read_expected["contig"]
Esempio n. 11
0
def test_parse_reads_with_single_read_file_returns_one_read(
        single_read_test_file):
    parser = EventalignReadParser()
    reads = list(parser.parse_reads(single_read_test_file))
    assert len(reads) == 1
Esempio n. 12
0
def test_parse_raises_exception_if_file_not_found():
    parser = AlignedEventParser(EventalignReadParser())
    with pytest.raises(FileNotFoundError):
        parser.parse("{0}fake_file.tsv".format(IN), OUT)
Esempio n. 13
0
def test_parse_writes_h5_file_with_correct_path():
    parser = AlignedEventParser(EventalignReadParser())
    parser.parse("{0}model_kmer_NNNNN.tsv".format(IN), OUT)
    assert os.path.isfile('{0}model_kmer_NNNNN.h5'.format(OUT)) == True