def get_pairs(all_files, read1_indicator, read2_indicator, match_barcodes=False, barcode_indicator='_I1_'):
 pairs = {}
 bc_pairs = {}
 read1_files = []
 read2_files = []
 bc_files = []
 for curr_file in all_files:
  curr_file_string_r1 = curr_file.split(read1_indicator)
  curr_file_string_r2 = curr_file.split(read2_indicator)
  if match_barcodes:
   curr_file_string_bc = curr_file.split(barcode_indicator)
  if (len(curr_file_string_r1) == 2):
   read1_files.append(curr_file_string_r1)
  elif (len(curr_file_string_r2) == 2):
   read2_files.append(curr_file_string_r2)
  elif (match_barcodes and (len(curr_file_string_bc) == 2)):
   bc_files.append(curr_file_string_bc)
  else:
   raise ValueError, ((('Invalid filename found for splitting on input ' + ('for file %s, ' % curr_file)) + 'check input read1_indicator ') + 'and read2_indicator parameters as well.')
 for curr_read1 in read1_files:
  for curr_read2 in read2_files:
   if (curr_read1 == curr_read2):
    pairs[read1_indicator.join(curr_read1)] = read2_indicator.join(curr_read2)
 if match_barcodes:
  for curr_read1 in read1_files:
   for curr_bc in bc_files:
    if (curr_read1 == curr_bc):
     bc_pairs[read1_indicator.join(curr_read1)] = barcode_indicator.join(curr_bc)
  forward_reads = set(pairs.keys())
  bc_reads = set(bc_pairs.keys())
  non_matching_f_reads = (forward_reads - bc_reads)
  if non_matching_f_reads:
   raise ValueError, ('Found forward reads without matching barcodes file: %s' % non_matching_f_reads)
 return (pairs, bc_pairs)

def get_pairs ( all_files , read1_indicator , read2_indicator , match_barcodes = False , barcode_indicator = '_I1_' ) : pairs = { } bc_pairs = { } read1_files = [ ] read2_files = [ ] bc_files = [ ] for curr_file in all_files : curr_file_string_r1 = curr_file . split ( read1_indicator ) curr_file_string_r2 = curr_file . split ( read2_indicator ) if match_barcodes : curr_file_string_bc = curr_file . split ( barcode_indicator ) if ( len ( curr_file_string_r1 ) == 2 ) : read1_files . append ( curr_file_string_r1 ) elif ( len ( curr_file_string_r2 ) == 2 ) : read2_files . append ( curr_file_string_r2 ) elif ( match_barcodes and ( len ( curr_file_string_bc ) == 2 ) ) : bc_files . append ( curr_file_string_bc ) else : raise ValueError , ( ( ( 'Invalid filename found for splitting on input ' + ( 'for file %s, ' % curr_file ) ) + 'check input read1_indicator ' ) + 'and read2_indicator parameters as well.' ) for curr_read1 in read1_files : for curr_read2 in read2_files : if ( curr_read1 == curr_read2 ) : pairs [ read1_indicator . join ( curr_read1 ) ] = read2_indicator . join ( curr_read2 ) if match_barcodes : for curr_read1 in read1_files : for curr_bc in bc_files : if ( curr_read1 == curr_bc ) : bc_pairs [ read1_indicator . join ( curr_read1 ) ] = barcode_indicator . join ( curr_bc ) forward_reads = set ( pairs . keys ( ) ) bc_reads = set ( bc_pairs . keys ( ) ) non_matching_f_reads = ( forward_reads - bc_reads ) if non_matching_f_reads : raise ValueError , ( 'Found forward reads without matching barcodes file: %s' % non_matching_f_reads ) return ( pairs , bc_pairs )
get the list of callback/errback pairs from the user .