def write_qual_line(demultiplexed_qual_f, qual_seq, label_line, keep_barcode, bc_len):
 if keep_barcode:
  final_seq = qual_seq
 else:
  final_seq = qual_seq[bc_len:]
 qual_line_size = 60
 current_qual_scores_lines = []
 for slice in range(0, len(final_seq), qual_line_size):
  current_segment = final_seq[slice:(slice + qual_line_size)]
  current_qual_scores_lines.append(' '.join(map(str, current_segment)))
 demultiplexed_qual_f.write(('>%s\n' % label_line))
 demultiplexed_qual_f.write('\n'.join(current_qual_scores_lines))
 demultiplexed_qual_f.write('\n')

def write_qual_line ( demultiplexed_qual_f , qual_seq , label_line , keep_barcode , bc_len ) : if keep_barcode : final_seq = qual_seq else : final_seq = qual_seq [ bc_len : ] qual_line_size = 60 current_qual_scores_lines = [ ] for slice in range ( 0 , len ( final_seq ) , qual_line_size ) : current_segment = final_seq [ slice : ( slice + qual_line_size ) ] current_qual_scores_lines . append ( ' ' . join ( map ( str , current_segment ) ) ) demultiplexed_qual_f . write ( ( '>%s\n' % label_line ) ) demultiplexed_qual_f . write ( '\n' . join ( current_qual_scores_lines ) ) demultiplexed_qual_f . write ( '\n' )
writes quality score sequence out in proper format demultiplexed_qual_f: open file object to write label/qual scores to .