예제 #1
0
def test_grouped_find_wild(search, expect):
    """Find best approximate match"""
    store = GroupedSequenceStore(4, max_diff=2, tag_size=2, wildcard='N')
    store.add("AAAA")
    store.add("AATT")
    store.add("TTTT")
    match = store.find(search)
    assert match == expect, "%r != %r" % (match, expect)
예제 #2
0
def test_grouped_contains():
    """Test sequences for membership in GroupedSequenceStore"""
    store = GroupedSequenceStore(4, tag_size=2, wildcard='N')
    store.add("AAAA")
    store.add("NAAA")
    assert "AAAA" in store, "'AAAA' not found in store"
    assert "NAAA" in store, "'NAAA' not found in store"
    assert "AACT" not in store, "'AACT' should not be in store"
    assert "AANT" not in store, "'AANT' should not be in store"
예제 #3
0
def test_grouped_add_wild():
    """Add entries to GroupedSequenceStore"""
    store = GroupedSequenceStore(4, tag_size=2, wildcard='N')
    store.add("AAAA")
    assert len(store) == 1, "%r != 1" % len(store)
    assert "AAAA" in store
    store.add("CTNT")
    assert len(store) == 2, "%r != 2" % len(store)
    assert "CTNT" in store, "'CTNT' not found in store"
예제 #4
0
def test_grouped_search(max_diff, expect_hits):
    """Find all approximate matches"""
    store = GroupedSequenceStore(4, max_diff=max_diff, tag_size=2)
    store.add("AAAA")
    store.add("AAAT")
    store.add("AATT")
    store.add("ATTT")
    match = store.search('TTTT', max_hits=None)
    assert len(match) == expect_hits, "%r != %r (found %r)" % (
        len(match), expect_hits, match)
예제 #5
0
def test_grouped_discard():
    """Discard sequences from GroupedSequenceStore if they exist"""
    store = GroupedSequenceStore(4, tag_size=2)
    store.add("AAAA")
    store.add("CTGT")
    assert "AAAA" in store, "'AAAA' not found in store"
    assert "CTGT" in store, "'CTGT' not found in store"
    store.discard("AAAA")
    assert "AAAA" not in store, "'AAAA' remains in store after removal"
    store.discard("AAAA")
    assert "CTGT" in store, "'CTGT' not found in store"
    assert len(store) == 1, "%r != 1" % len(store)
    store.discard("CTGT")
    assert "CTGT" not in store, "'CTGT' remains in store after removal"
    assert len(store) == 0, "%r != 0" % len(store)
예제 #6
0
def test_grouped_remove():
    """Remove sequences from GroupedSequenceStore"""
    store = GroupedSequenceStore(4, tag_size=2)
    store.add("AAAA")
    store.add("CTGT")
    assert "AAAA" in store, "'AAAA' not found in store"
    assert "CTGT" in store, "'CTGT' not found in store"
    store.remove("AAAA")
    assert "AAAA" not in store, "'AAAA' remains in store after removal"
    with helper.assertRaises(KeyError):
        store.remove("AAAA")
    assert "CTGT" in store, "'CTGT' not found in store"
    assert len(store) == 1, "%r != 1" % len(store)
    store.remove("CTGT")
    assert "CTGT" not in store, "'CTGT' remains in store after removal"
    assert len(store) == 0, "%r != 0" % len(store)
예제 #7
0
def test_grouped_add():
    """Add entries to GroupedSequenceStore"""
    store = GroupedSequenceStore(4, tag_size=2)
    store.add("AAAA")
    assert len(store) == 1, "%r != 1" % len(store)
    assert "AAAA" in store
    store.add("CTGT")
    assert len(store) == 2, "%r != 2" % len(store)
    assert "CTGT" in store
    store.add("CTAA")
    assert len(store) == 3, "%r != 3" % len(store)
    assert "CTAA" in store