def check_chars_data_fields(header, mapping_data, warnings):
 allowed_data_field_chars = (('+-%./ :,;_' + digits) + letters)
 allowed_sampleid_chars = (('.' + digits) + letters)
 correction = 1
 sample_id_field = 'SampleID'
 fields_to_skip = ['BarcodeSequence', 'LinkerPrimerSequence', 'ReversePrimer']
 for curr_field in range(len(header)):
  if (header[curr_field] in fields_to_skip):
   continue
  if (header[curr_field] == sample_id_field):
   valid_chars = allowed_sampleid_chars
  else:
   valid_chars = allowed_data_field_chars
  for curr_data in range(len(mapping_data)):
   curr_cell = mapping_data[curr_data][curr_field].replace('\n', '')
   for curr_char in curr_cell:
    if (curr_char not in valid_chars):
     warnings.append(('Invalid characters found in %s DCTB %d,%d' % (mapping_data[curr_data][curr_field].replace('\n', ''), (curr_data + correction), curr_field)))
     break
 return warnings

def check_chars_data_fields ( header , mapping_data , warnings ) : allowed_data_field_chars = ( ( '+-%./ :,;_' + digits ) + letters ) allowed_sampleid_chars = ( ( '.' + digits ) + letters ) correction = 1 sample_id_field = 'SampleID' fields_to_skip = [ 'BarcodeSequence' , 'LinkerPrimerSequence' , 'ReversePrimer' ] for curr_field in range ( len ( header ) ) : if ( header [ curr_field ] in fields_to_skip ) : continue if ( header [ curr_field ] == sample_id_field ) : valid_chars = allowed_sampleid_chars else : valid_chars = allowed_data_field_chars for curr_data in range ( len ( mapping_data ) ) : curr_cell = mapping_data [ curr_data ] [ curr_field ] . replace ( '\n' , '' ) for curr_char in curr_cell : if ( curr_char not in valid_chars ) : warnings . append ( ( 'Invalid characters found in %s DCTB %d,%d' % ( mapping_data [ curr_data ] [ curr_field ] . replace ( '\n' , '' ) , ( curr_data + correction ) , curr_field ) ) ) break return warnings
checks for valid sampleid and other data field characters header: list of header strings mapping_data: list of lists of raw metadata mapping file data warnings: list of warnings .