コード例 #1
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_discard():
    """Discard sequences from store if they exist"""
    store = SequenceStore(4)
    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)
コード例 #2
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_remove():
    """Remove sequences from store"""
    store = SequenceStore(4)
    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)
コード例 #3
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_search():
    """Find all approximate matches"""
    store = SequenceStore(4)
    store.add("AAAA")
    store.add("AAAT")
    store.add("AATT")
    store.add("ATTT")
    match = store.search('TTTT', 4, max_hits=None)
    assert len(match) == 4, "%r != 4" % len(match)
    match = store.search('TTTT', 2, max_hits=None)
    assert len(match) == 2, "%r != 2" % len(match)
コード例 #4
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_find_wild(search, expect):
    """Find best approximate match"""
    store = SequenceStore(4)
    store.add("AAAA")
    store.add("AATT")
    store.add("TTTT")
    match = store.find(search, 2, wildcard='N')
    assert match == expect, "%r != %r" % (match, expect)
コード例 #5
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_add_wild():
    """Add entries to sequence store"""
    store = SequenceStore(4)
    store.add("AAAA", wildcard='N')
    assert len(store) == 1, "%r != 1" % len(store)
    assert "AAAA" in store
    store.add("CTNT", wildcard='N')
    assert len(store) == 2, "%r != 2" % len(store)
    assert "CTNT" in store
コード例 #6
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_add():
    """Add entries to sequence store"""
    store = SequenceStore(4)
    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
コード例 #7
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_new():
    """Create empty sequence store"""
    store = SequenceStore(5)
    assert len(store) == 0, "%r != 0" % len(store)
コード例 #8
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_list():
    """Create sequence store from list."""
    store = SequenceStore.from_list(['AAAA', 'CTGT'])
    assert "AAAA" in store, "'AAAA' not found in store"
    assert "CTGT" in store, "'CTGT' not found in store"
コード例 #9
0
ファイル: test_sequence.py プロジェクト: humburg/pirates
def test_store_contains():
    """Test sequences for membership in store"""
    store = SequenceStore(4)
    store.add("AAAA")
    assert "AAAA" in store, "'AAAA' not found in store"
    assert "AACT" not in store, "'AACT' should not be in store"