Ejemplo n.º 1
0
 def manual_barcodes_test(self):
     bc_list = list(self.barcodes)
     for i in range(len(self.barcodes)):
         bc1 = num2dna(bc_list[i], self.bc_len)
         for j in range(i+1, len(self.barcodes)):
             bc2 = num2dna(bc_list[j], self.bc_len)
             dist = editmeasures.free_divergence(bc1, bc2)
             if dist < self.max_err:
                 log.error('!'*10 + ' FAIL ' + '!'*10)
                 log.error('Distance {} between {} and {}.'.format(dist, bc1, bc2))
                 return
     log.info('Barcodes Pass Manual Check')
Ejemplo n.º 2
0
    def iterator_test(self, iterator='self'):
        log.info('Generating self set...')
        if iterator == 'self':
            self_set = set(self)
        elif iterator == 'parallel_num':
            self_set = set(
                seqtools.num2dna(seq, len(self.c))
                for seq in self.parallel_num_iterator())
        else:
            raise ValueError('Invalid iterator to test: {}'.format(iterator))

        log.info('Generating brute force set...')
        bf_set = set(''.join(tup)
                     for tup in itertools.product(bases, repeat=len(self.c))
                     if self.min_r <= editmeasures.free_divergence(
                         self.c, ''.join(tup)) <= self.r)
        log.info('Comparing...')
        if self_set == bf_set:
            log.info('PASS')
        else:
            log.error('#### FAIL ####')
            log.error('{} missing seqs, {} extra seqs'.format(
                len(bf_set - self_set), len(self_set - bf_set)))