def format_mapping_file(headers, mapping_data, comments=None):
 result = []
 result.append(('#' + ' DCTB '.join(headers)))
 if (comments is not None):
  for comment in comments:
   result.append(('#' + comment))
 for mapping_line in mapping_data:
  if (not (len(mapping_line) == len(headers))):
   raise RuntimeError(('error formatting mapping file, does each ' + 'sample have the same length of data as the headers?'))
  result.append(' DCTB '.join(mapping_line))
 str_result = '\n'.join(result)
 return str_result

def format_mapping_file ( headers , mapping_data , comments = None ) : result = [ ] result . append ( ( '#' + ' DCTB ' . join ( headers ) ) ) if ( comments is not None ) : for comment in comments : result . append ( ( '#' + comment ) ) for mapping_line in mapping_data : if ( not ( len ( mapping_line ) == len ( headers ) ) ) : raise RuntimeError ( ( 'error formatting mapping file, does each ' + 'sample have the same length of data as the headers?' ) ) result . append ( ' DCTB ' . join ( mapping_line ) ) str_result = '\n' . join ( result ) return str_result
returns a large formatted string representing the entire mapping file each input is a list .