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)
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))
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)
def test_error_detection(): testing = 'ATTTAACATGAGXTAACATGCATGCATGCAT' testing = testing.encode('ascii') assert kmers.kmers(testing, KMER_SIZE) is None