def FastqPhredIterator(handle, alphabet=single_letter_alphabet, title2ids=None):
 assert (SANGER_SCORE_OFFSET == ord('!'))
 q_mapping = dict()
 for letter in range(0, 255):
  q_mapping[chr(letter)] = (letter - SANGER_SCORE_OFFSET)
 for (title_line, seq_string, quality_string) in FastqGeneralIterator(handle):
  if title2ids:
   (id, name, descr) = title2ids(title_line)
  else:
   descr = title_line
   id = descr.split()[0]
   name = id
  record = SeqRecord(Seq(seq_string, alphabet), id=id, name=name, description=descr)
  qualities = [q_mapping[letter] for letter in quality_string]
  if (qualities and ((min(qualities) < 0) or (max(qualities) > 93))):
   raise ValueError('Invalid character in quality string')
  dict.__setitem__(record._per_letter_annotations, 'phred_quality', qualities)
  (yield record)

def FastqPhredIterator ( handle , alphabet = single_letter_alphabet , title2ids = None ) : assert ( SANGER_SCORE_OFFSET == ord ( '!' ) ) q_mapping = dict ( ) for letter in range ( 0 , 255 ) : q_mapping [ chr ( letter ) ] = ( letter - SANGER_SCORE_OFFSET ) for ( title_line , seq_string , quality_string ) in FastqGeneralIterator ( handle ) : if title2ids : ( id , name , descr ) = title2ids ( title_line ) else : descr = title_line id = descr . split ( ) [ 0 ] name = id record = SeqRecord ( Seq ( seq_string , alphabet ) , id = id , name = name , description = descr ) qualities = [ q_mapping [ letter ] for letter in quality_string ] if ( qualities and ( ( min ( qualities ) < 0 ) or ( max ( qualities ) > 93 ) ) ) : raise ValueError ( 'Invalid character in quality string' ) dict . __setitem__ ( record . _per_letter_annotations , 'phred_quality' , qualities ) ( yield record )
generator function to iterate over fastq records .