def make_fastq_multi(in_fasta, quals, out_fp, label_transform=split_lib_transform):
 mkdir(out_fp)
 seen_libs = defaultdict(list)
 for (rec, label) in iter_fastq(in_fasta, quals, label_transform):
  (lib_id, seq_id) = label.rsplit('_', 1)
  seen_libs[lib_id].append(rec)
 for (lib, recs) in seen_libs.items():
  if (lib is None):
   continue
  outfile = open((((out_fp + '/') + lib) + '.fastq'), 'w')
  outfile.write('\n'.join(recs))
  outfile.close()

def make_fastq_multi ( in_fasta , quals , out_fp , label_transform = split_lib_transform ) : mkdir ( out_fp ) seen_libs = defaultdict ( list ) for ( rec , label ) in iter_fastq ( in_fasta , quals , label_transform ) : ( lib_id , seq_id ) = label . rsplit ( '_' , 1 ) seen_libs [ lib_id ] . append ( rec ) for ( lib , recs ) in seen_libs . items ( ) : if ( lib is None ) : continue outfile = open ( ( ( ( out_fp + '/' ) + lib ) + '.fastq' ) , 'w' ) outfile . write ( '\n' . join ( recs ) ) outfile . close ( )
makes a fastq file for each library warning: this implementation reads everything into memory .