def check_dna_chars_bcs(header, mapping_data, errors, has_barcodes=True):
 valid_dna_chars = DNASequence.iupac_standard_characters()
 header_fields_to_check = []
 if has_barcodes:
  header_fields_to_check.append('BarcodeSequence')
 check_indices = []
 for curr_field in range(len(header)):
  if (header[curr_field] in header_fields_to_check):
   check_indices.append(curr_field)
 correction_ix = 1
 for curr_data in range(len(mapping_data)):
  for curr_ix in check_indices:
   if (len(mapping_data[curr_data][curr_ix]) == 0):
    errors.append(('Missing expected DNA sequence DCTB %d,%d' % ((curr_data + correction_ix), curr_ix)))
    continue
   for curr_nt in mapping_data[curr_data][curr_ix]:
    if (curr_nt not in valid_dna_chars):
     errors.append(('Invalid DNA sequence detected: %s DCTB %d,%d' % (mapping_data[curr_data][curr_ix], (curr_data + correction_ix), curr_ix)))
     continue
 return errors

def check_dna_chars_bcs ( header , mapping_data , errors , has_barcodes = True ) : valid_dna_chars = DNASequence . iupac_standard_characters ( ) header_fields_to_check = [ ] if has_barcodes : header_fields_to_check . append ( 'BarcodeSequence' ) check_indices = [ ] for curr_field in range ( len ( header ) ) : if ( header [ curr_field ] in header_fields_to_check ) : check_indices . append ( curr_field ) correction_ix = 1 for curr_data in range ( len ( mapping_data ) ) : for curr_ix in check_indices : if ( len ( mapping_data [ curr_data ] [ curr_ix ] ) == 0 ) : errors . append ( ( 'Missing expected DNA sequence DCTB %d,%d' % ( ( curr_data + correction_ix ) , curr_ix ) ) ) continue for curr_nt in mapping_data [ curr_data ] [ curr_ix ] : if ( curr_nt not in valid_dna_chars ) : errors . append ( ( 'Invalid DNA sequence detected: %s DCTB %d,%d' % ( mapping_data [ curr_data ] [ curr_ix ] , ( curr_data + correction_ix ) , curr_ix ) ) ) continue return errors
checks for valid dna characters in barcode field also flags empty fields as errors unless flags are passed to suppress barcode or primer checks .