def demultiplex_sequences(file_data, keep_barcode=False, barcode_type='golay_12', max_bc_errors=1.5, start_index=1, write_unassigned_reads=False, disable_bc_correction=False, added_demultiplex_field=None):
 (header, mapping_data) = check_map(file_data['mapping_file'], barcode_type, added_demultiplex_field)
 ids_bcs_added_field = get_ids_bcs_added_field(header, mapping_data, barcode_type, added_demultiplex_field)
 bc_lens = get_bc_lens(ids_bcs_added_field)
 all_bcs = [curr_bc[0] for curr_bc in ids_bcs_added_field.keys()]
 (log_data, bc_freqs, seq_counts, corrected_bc_count) = assign_seqs(file_data, ids_bcs_added_field, bc_lens, all_bcs, keep_barcode, barcode_type, max_bc_errors, start_index, write_unassigned_reads, disable_bc_correction, added_demultiplex_field)
 return (log_data, bc_freqs, seq_counts, corrected_bc_count)

def demultiplex_sequences ( file_data , keep_barcode = False , barcode_type = 'golay_12' , max_bc_errors = 1.5 , start_index = 1 , write_unassigned_reads = False , disable_bc_correction = False , added_demultiplex_field = None ) : ( header , mapping_data ) = check_map ( file_data [ 'mapping_file' ] , barcode_type , added_demultiplex_field ) ids_bcs_added_field = get_ids_bcs_added_field ( header , mapping_data , barcode_type , added_demultiplex_field ) bc_lens = get_bc_lens ( ids_bcs_added_field ) all_bcs = [ curr_bc [ 0 ] for curr_bc in ids_bcs_added_field . keys ( ) ] ( log_data , bc_freqs , seq_counts , corrected_bc_count ) = assign_seqs ( file_data , ids_bcs_added_field , bc_lens , all_bcs , keep_barcode , barcode_type , max_bc_errors , start_index , write_unassigned_reads , disable_bc_correction , added_demultiplex_field ) return ( log_data , bc_freqs , seq_counts , corrected_bc_count )
main program function for demultiplexing fasta sequence data file_data: dict of open file objects .