def correct_barcode_bitwise(query_seq, seq_possibilities, nt_to_bits=DEFAULT_GOLAY_NT_TO_BITS):
 if (nt_to_bits is None):
  nt_to_bits = DEFAULT_NT_TO_BITS
 dists = []
 query_seq_bits = seq_to_bits(query_seq, nt_to_bits)
 for seq in seq_possibilities:
  possible_seq_bits = seq_to_bits(seq, nt_to_bits)
  dists.append(hamming_dist(query_seq_bits, possible_seq_bits))
 min_dist = min(dists)
 number_mins = dists.count(min_dist)
 if (number_mins > 1):
  return (None, min_dist)
 else:
  best_hit = seq_possibilities[dists.index(min_dist)]
  return (best_hit, min_dist)

def correct_barcode_bitwise ( query_seq , seq_possibilities , nt_to_bits = DEFAULT_GOLAY_NT_TO_BITS ) : if ( nt_to_bits is None ) : nt_to_bits = DEFAULT_NT_TO_BITS dists = [ ] query_seq_bits = seq_to_bits ( query_seq , nt_to_bits ) for seq in seq_possibilities : possible_seq_bits = seq_to_bits ( seq , nt_to_bits ) dists . append ( hamming_dist ( query_seq_bits , possible_seq_bits ) ) min_dist = min ( dists ) number_mins = dists . count ( min_dist ) if ( number_mins > 1 ) : return ( None , min_dist ) else : best_hit = seq_possibilities [ dists . index ( min_dist ) ] return ( best_hit , min_dist )
finds closest match to query_seq assumes: all sequences are same length no sequence appears twice in seq_possibilities returns * best_hit is closest sequence from seq_possibilities .