def PairedFastaQualIterator(fasta_handle, qual_handle, alphabet=single_letter_alphabet, title2ids=None):
 from Bio.SeqIO.FastaIO import FastaIterator
 fasta_iter = FastaIterator(fasta_handle, alphabet=alphabet, title2ids=title2ids)
 qual_iter = QualPhredIterator(qual_handle, alphabet=alphabet, title2ids=title2ids)
 while True:
  try:
   f_rec = next(fasta_iter)
  except StopIteration:
   f_rec = None
  try:
   q_rec = next(qual_iter)
  except StopIteration:
   q_rec = None
  if ((f_rec is None) and (q_rec is None)):
   break
  if (f_rec is None):
   raise ValueError('FASTA file has more entries than the QUAL file.')
  if (q_rec is None):
   raise ValueError('QUAL file has more entries than the FASTA file.')
  if (f_rec.id != q_rec.id):
   raise ValueError(('FASTA and QUAL entries do not match (%s vs %s).' % (f_rec.id, q_rec.id)))
  if (len(f_rec) != len(q_rec.letter_annotations['phred_quality'])):
   raise ValueError(('Sequence length and number of quality scores disagree for %s' % f_rec.id))
  f_rec.letter_annotations['phred_quality'] = q_rec.letter_annotations['phred_quality']
  (yield f_rec)

def PairedFastaQualIterator ( fasta_handle , qual_handle , alphabet = single_letter_alphabet , title2ids = None ) : from Bio . SeqIO . FastaIO import FastaIterator fasta_iter = FastaIterator ( fasta_handle , alphabet = alphabet , title2ids = title2ids ) qual_iter = QualPhredIterator ( qual_handle , alphabet = alphabet , title2ids = title2ids ) while True : try : f_rec = next ( fasta_iter ) except StopIteration : f_rec = None try : q_rec = next ( qual_iter ) except StopIteration : q_rec = None if ( ( f_rec is None ) and ( q_rec is None ) ) : break if ( f_rec is None ) : raise ValueError ( 'FASTA file has more entries than the QUAL file.' ) if ( q_rec is None ) : raise ValueError ( 'QUAL file has more entries than the FASTA file.' ) if ( f_rec . id != q_rec . id ) : raise ValueError ( ( 'FASTA and QUAL entries do not match (%s vs %s).' % ( f_rec . id , q_rec . id ) ) ) if ( len ( f_rec ) != len ( q_rec . letter_annotations [ 'phred_quality' ] ) ) : raise ValueError ( ( 'Sequence length and number of quality scores disagree for %s' % f_rec . id ) ) f_rec . letter_annotations [ 'phred_quality' ] = q_rec . letter_annotations [ 'phred_quality' ] ( yield f_rec )
iterate over matched fasta and qual files as seqrecord objects .