Ejemplo n.º 1
0
 def test_intersection(self):
     bf1 = BloomFilter.build_from_probs(40, 500, 0.00001)
     bf2 = BloomFilter.build_from_probs(40, 500, 0.00001)
     for _ in range(100):
         kmer = random_kmer(40)
         bf1.py_add(kmer)
         bf2.py_add(kmer)
     for _ in range(100):
         bf1.py_add(random_kmer(40))
         bf2.py_add(random_kmer(40))
     intersection = bf1.intersection(bf2)
     self.assertGreaterEqual(intersection, -10)
     self.assertLessEqual(intersection, 110)
Ejemplo n.º 2
0
 def test_union(self):
     bf1 = BloomFilter.build_from_probs(40, 500, 0.01)
     bf2 = BloomFilter.build_from_probs(40, 500, 0.01)
     for _ in range(100):
         kmer = random_kmer(40)
         bf1.py_add(kmer)
         bf2.py_add(kmer)
     for _ in range(100):
         bf1.py_add(random_kmer(40))
         bf2.py_add(random_kmer(40))
     union = bf1.union(bf2)
     self.assertGreaterEqual(union, 290)
     self.assertLessEqual(union, 410)
Ejemplo n.º 3
0
 def test_not_in_bloom(self):
     bf = BloomFilter.build_from_probs(5, 500, 0.01)
     kmer = random_kmer(5)
     bf.py_add(kmer)
     self.assertTrue(bf.py_contains(kmer))
     for _ in range(10):
         self.assertFalse(bf.py_contains(random_kmer(5)))
Ejemplo n.º 4
0
 def test_mostly_not_in_bloom_small(self):
     k = 6
     bf = BloomFilter.build_from_probs(k, 200, 0.01)
     for _ in range(100):
         bf.py_add(random_kmer(k))
     in_bloom = 0
     for _ in range(100):
         if bf.py_contains(random_kmer(k)):
             in_bloom += 1
     self.assertLessEqual(in_bloom, 5)
Ejemplo n.º 5
0
 def test_in_bloom(self):
     bf = BloomFilter.build_from_probs(5, 500, 0.01)
     kmer = random_kmer(5)
     bf.py_add(kmer)
     self.assertTrue(bf.py_contains(kmer))
Ejemplo n.º 6
0
 def test_add_to_bloom(self):
     bf = BloomFilter.build_from_probs(5, 500, 0.01)
     for _ in range(100):
         bf.py_add(random_kmer(5))
     self.assertEqual(bf.n_elements, 100)