def format_read_as_fna(read, qual=False):
 out = StringIO()
 out.write(('>%s' % read['Name']))
 start_idx = (read['clip_qual_left'] - 1)
 end_idx = read['clip_qual_right']
 out.write((' length=%d' % (end_idx - start_idx)))
 (timestamp, _, region, location) = decode_accession(read['Name'])
 out.write((' xy=%04d_%04d' % location))
 out.write((' region=%d' % region))
 out.write((' run=R_%d_%02d_%02d_%02d_%02d_%02d_' % timestamp))
 out.write('\n')
 if qual:
  scores = read['quality_scores'][start_idx:end_idx]
  out.write(' '.join([('%d' % s) for s in scores]))
 else:
  bases = read['Bases'][start_idx:end_idx]
  out.write(bases)
 out.write('\n')
 return out.getvalue()

def format_read_as_fna ( read , qual = False ) : out = StringIO ( ) out . write ( ( '>%s' % read [ 'Name' ] ) ) start_idx = ( read [ 'clip_qual_left' ] - 1 ) end_idx = read [ 'clip_qual_right' ] out . write ( ( ' length=%d' % ( end_idx - start_idx ) ) ) ( timestamp , _ , region , location ) = decode_accession ( read [ 'Name' ] ) out . write ( ( ' xy=%04d_%04d' % location ) ) out . write ( ( ' region=%d' % region ) ) out . write ( ( ' run=R_%d_%02d_%02d_%02d_%02d_%02d_' % timestamp ) ) out . write ( '\n' ) if qual : scores = read [ 'quality_scores' ] [ start_idx : end_idx ] out . write ( ' ' . join ( [ ( '%d' % s ) for s in scores ] ) ) else : bases = read [ 'Bases' ] [ start_idx : end_idx ] out . write ( bases ) out . write ( '\n' ) return out . getvalue ( )
format a single read from a binary sff file as a fasta record .