def write_trunc_qual(trunc_qual_scores, qual_out_fp, seq_order):
 qual_line_size = 60
 qual_out = open(qual_out_fp, 'w')
 for label in seq_order:
  trunc_label = label.split()[0].strip()
  current_trunc_qual_scores = trunc_qual_scores[trunc_label]
  qual_out.write(('>%s\n' % label))
  current_qual_scores_lines = []
  for slice in range(0, len(trunc_qual_scores[trunc_label]), qual_line_size):
   current_segment = current_trunc_qual_scores[slice:(slice + qual_line_size)]
   current_qual_scores_lines.append(' '.join(current_segment))
  qual_out.write('\n'.join(current_qual_scores_lines))
  qual_out.write('\n')

def write_trunc_qual ( trunc_qual_scores , qual_out_fp , seq_order ) : qual_line_size = 60 qual_out = open ( qual_out_fp , 'w' ) for label in seq_order : trunc_label = label . split ( ) [ 0 ] . strip ( ) current_trunc_qual_scores = trunc_qual_scores [ trunc_label ] qual_out . write ( ( '>%s\n' % label ) ) current_qual_scores_lines = [ ] for slice in range ( 0 , len ( trunc_qual_scores [ trunc_label ] ) , qual_line_size ) : current_segment = current_trunc_qual_scores [ slice : ( slice + qual_line_size ) ] current_qual_scores_lines . append ( ' ' . join ( current_segment ) ) qual_out . write ( '\n' . join ( current_qual_scores_lines ) ) qual_out . write ( '\n' )
writes truncated quality score files out in proper format trunc_qual_scores: dict of seq label: numpy array of scores as ints qual_out_fp: output filepath to write truncated quality scores to seq_order: list of full fasta labels to write to output filepath and maintain the same order as input quality file .