Beispiel #1
0
 def ram_dists(self):
     for rft_dim in self.rft_dims:
         ramifier = RotatingRamifier(self.k, rft_dim,
                                     self.rotation['rotation'],
                                     self.rotation['center'],
                                     self.rotation['scale'])
         euc, manhattan = [], []
         for i, row in self.tbl.iterrows():
             q_rft = ramifier.ramify(row['query'])
             t_rft = ramifier.ramify(row['target'])
             euc.append(np.linalg.norm(q_rft - t_rft, ord=2))
             manhattan.append(np.linalg.norm(q_rft - t_rft, ord=1))
         self.tbl[f'ram_{rft_dim}_euc'] = euc
         self.tbl[f'ram_{rft_dim}_manhattan'] = manhattan
Beispiel #2
0
 def test_rotating_ramifier(self):
     stat_ram = StatisticalRam(31, 100)
     stat_ram.add_kmers_from_file(KMER_TABLE)
     centers = stat_ram.get_centers()
     scales = stat_ram.get_scales()
     rotation = stat_ram.get_rotation()
     rotater = RotatingRamifier(31, 8, rotation, centers, scales)
     rft = rotater.ramify('ATCGATCGATCGATCGATCGATCGATCGATC')
     self.assertTrue(rft.shape == (8, ))