def get_added_demultiplex_field(ids_bcs_added_field, fasta_label, added_demultiplex_field):
 for curr_bc_added_field in ids_bcs_added_field.keys():
  curr_added_field = curr_bc_added_field[1]
  if (added_demultiplex_field == 'run_prefix'):
   curr_label_slice = fasta_label[0:len(curr_added_field)]
   if (curr_label_slice == curr_added_field):
    return curr_label_slice
  else:
   if (curr_added_field not in fasta_label):
    continue
   curr_label_slice = fasta_label.split((added_demultiplex_field + '='))[1][0:len(curr_added_field)]
   if (curr_label_slice == curr_added_field):
    return curr_label_slice
 return None

def get_added_demultiplex_field ( ids_bcs_added_field , fasta_label , added_demultiplex_field ) : for curr_bc_added_field in ids_bcs_added_field . keys ( ) : curr_added_field = curr_bc_added_field [ 1 ] if ( added_demultiplex_field == 'run_prefix' ) : curr_label_slice = fasta_label [ 0 : len ( curr_added_field ) ] if ( curr_label_slice == curr_added_field ) : return curr_label_slice else : if ( curr_added_field not in fasta_label ) : continue curr_label_slice = fasta_label . split ( ( added_demultiplex_field + '=' ) ) [ 1 ] [ 0 : len ( curr_added_field ) ] if ( curr_label_slice == curr_added_field ) : return curr_label_slice return None
returns matches to added demultiplex field from fasta label ids_bcs_added_field: dict of : sampleid added_demultiplex_field: uses data supplied in metadata mapping field and demultiplexes according to data in fasta labels .