Пример #1
0
 def test_get_centroids(self):
     ramifier = RotatingRamifier.from_file(4, KMER_ROTATION)
     db = GridCoverDB(sqlite3.connect(':memory:'),
                      ramifier=ramifier,
                      box_side_len=0.5)
     db.py_add_point_to_cluster(np.array([0., 0., 0., 0.]), KMER_30 + 'A')
     db.py_add_point_to_cluster(np.array([0., 0., 0., 0.]), KMER_30 + 'T')
     db.py_add_point_to_cluster(np.array([1., 0., 0., 0.]), KMER_30 + 'C')
     db.commit()
     centroids = db.centroids()
     self.assertEqual(centroids.shape, (2, 4))
Пример #2
0
 def test_merge_dbs(self):
     ramifier = RotatingRamifier.from_file(4, KMER_ROTATION)
     db1 = GridCoverDB(sqlite3.connect(':memory:'),
                       ramifier=ramifier,
                       box_side_len=0.5)
     db1.py_add_point_to_cluster(np.array([0., 0., 0., 0.]), KMER_30 + 'A')
     db1.py_add_point_to_cluster(np.array([1., 0., 0., 0.]), KMER_30 + 'T')
     db1.commit()
     db2 = GridCoverDB(sqlite3.connect(':memory:'),
                       ramifier=ramifier,
                       box_side_len=0.5)
     db2.py_add_point_to_cluster(np.array([0., 0., 0., 0.]), KMER_30 + 'C')
     db2.py_add_point_to_cluster(np.array([1., 1., 0., 0.]), KMER_30 + 'G')
     db2.commit()
     db1.load_other(db2)
     centroids = db1.centroids()
     self.assertEqual(centroids.shape, (3, 4))
     kmers = [el[1] for el in db1.get_kmers()]
     self.assertEqual(len(kmers), 4)
     for char in 'ATCG':
         self.assertIn(KMER_30 + char, kmers)