示例#1
0
def test_shift(seq):
    import numpy as np
    shifted = np.array([
        kmers.kmers(seq[i:i + KMER_SIZE].encode('ascii'), KMER_SIZE)[0]
        for i in range(len(seq) - KMER_SIZE + 1)
    ])
    fast = kmers.kmers(seq.encode('ascii'), KMER_SIZE)
    assert len(shifted) == len(fast)
    assert np.all(shifted == fast)
示例#2
0
def test_kmers():
    testing = 'ATTTAACATGAGATAACATGCATGCATGCATTGCGGCTCAGCTAGTCAGCTAGCTAGCTAGCTACGATCGATCGTAGCATCGATCGATCGATCGATCGATCGATCGTACGTACGTAGCTACGATCGTAGCTAGCTAG'

    testing = testing.encode('ascii')
    print(kmers.kmers(testing, KMER_SIZE))

    testing = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

    testing = testing.encode('ascii')
    print(kmers.kmers(testing, KMER_SIZE))
示例#3
0
def test_extended_IUPAC_alphabet(seq):
    import numpy as np
    n = np.array([
        encode_kmer_min(seq[i:i + KMER_SIZE])
        for i in range(len(seq) - KMER_SIZE + 1)
    ])
    fast = kmers.kmers(seq.encode('ascii'), KMER_SIZE)
    assert len(n) == len(fast)
    assert np.all(n == fast)
示例#4
0
def test_error_detection():
    testing = 'ATTTAACATGAGXTAACATGCATGCATGCAT'
    testing = testing.encode('ascii')
    assert kmers.kmers(testing, KMER_SIZE) is None