def check_bcs_lengths(header, mapping_data, warnings):
 len_counts = defaultdict(int)
 header_field_to_check = 'BarcodeSequence'
 try:
  check_ix = header.index(header_field_to_check)
 except ValueError:
  return warnings
 for curr_data in range(len(mapping_data)):
  len_counts[len(mapping_data[curr_data][check_ix])] += 1
 expected_bc_len = max(len_counts.iteritems(), key=itemgetter(1))[0]
 correction_ix = 1
 for curr_data in range(len(mapping_data)):
  if (len(mapping_data[curr_data][check_ix]) != expected_bc_len):
   warnings.append(('Barcode %s differs than length %d DCTB %d,%d' % (mapping_data[curr_data][check_ix], expected_bc_len, (curr_data + correction_ix), check_ix)))
 return warnings

def check_bcs_lengths ( header , mapping_data , warnings ) : len_counts = defaultdict ( int ) header_field_to_check = 'BarcodeSequence' try : check_ix = header . index ( header_field_to_check ) except ValueError : return warnings for curr_data in range ( len ( mapping_data ) ) : len_counts [ len ( mapping_data [ curr_data ] [ check_ix ] ) ] += 1 expected_bc_len = max ( len_counts . iteritems ( ) , key = itemgetter ( 1 ) ) [ 0 ] correction_ix = 1 for curr_data in range ( len ( mapping_data ) ) : if ( len ( mapping_data [ curr_data ] [ check_ix ] ) != expected_bc_len ) : warnings . append ( ( 'Barcode %s differs than length %d DCTB %d,%d' % ( mapping_data [ curr_data ] [ check_ix ] , expected_bc_len , ( curr_data + correction_ix ) , check_ix ) ) ) return warnings
adds warnings if barcodes have different lengths as this is mostly intended to find typos in barcodes .