def split_sff(sff_file_handles, map_file_handle, outdir='/tmp/'):
 try:
  (flowgrams, header) = cat_sff_files(sff_file_handles)
 except ValueError:
  raise FileFormatError(('Wrong flogram file format. Make sure you pass the sff.txt format ' + 'produced by sffinfo. The binary .sff will not work here.'))
 (inverse_map, map_count) = build_inverse_barcode_map(parse_fasta(map_file_handle))
 filenames = []
 for barcode_id in map_count.keys():
  fh = open((outdir + barcode_id), 'w')
  write_sff_header(header, fh, map_count[barcode_id])
  fh.close()
  filenames.append((outdir + barcode_id))
 for f in flowgrams:
  if (f.Name in inverse_map):
   barcode_id = inverse_map[f.Name]
   fh = open((outdir + barcode_id), 'a')
   fh.write((f.createFlowHeader() + '\n'))
 return filenames

def split_sff ( sff_file_handles , map_file_handle , outdir = '/tmp/' ) : try : ( flowgrams , header ) = cat_sff_files ( sff_file_handles ) except ValueError : raise FileFormatError ( ( 'Wrong flogram file format. Make sure you pass the sff.txt format ' + 'produced by sffinfo. The binary .sff will not work here.' ) ) ( inverse_map , map_count ) = build_inverse_barcode_map ( parse_fasta ( map_file_handle ) ) filenames = [ ] for barcode_id in map_count . keys ( ) : fh = open ( ( outdir + barcode_id ) , 'w' ) write_sff_header ( header , fh , map_count [ barcode_id ] ) fh . close ( ) filenames . append ( ( outdir + barcode_id ) ) for f in flowgrams : if ( f . Name in inverse_map ) : barcode_id = inverse_map [ f . Name ] fh = open ( ( outdir + barcode_id ) , 'a' ) fh . write ( ( f . createFlowHeader ( ) + '\n' ) ) return filenames
splits a sff .