def AceIterator(handle):
 for ace_contig in Ace.parse(handle):
  consensus_seq_str = ace_contig.sequence
  if ('U' in consensus_seq_str):
   if ('T' in consensus_seq_str):
    alpha = generic_nucleotide
   else:
    alpha = generic_rna
  else:
   alpha = generic_dna
  if ('*' in consensus_seq_str):
   assert ('-' not in consensus_seq_str)
   consensus_seq = Seq(consensus_seq_str.replace('*', '-'), Gapped(alpha, gap_char='-'))
  else:
   consensus_seq = Seq(consensus_seq_str, alpha)
  seq_record = SeqRecord(consensus_seq, id=ace_contig.name, name=ace_contig.name)
  quals = []
  i = 0
  for base in consensus_seq:
   if (base == '-'):
    quals.append(0)
   else:
    quals.append(ace_contig.quality[i])
    i += 1
  assert (i == len(ace_contig.quality))
  seq_record.letter_annotations['phred_quality'] = quals
  (yield seq_record)

def AceIterator ( handle ) : for ace_contig in Ace . parse ( handle ) : consensus_seq_str = ace_contig . sequence if ( 'U' in consensus_seq_str ) : if ( 'T' in consensus_seq_str ) : alpha = generic_nucleotide else : alpha = generic_rna else : alpha = generic_dna if ( '*' in consensus_seq_str ) : assert ( '-' not in consensus_seq_str ) consensus_seq = Seq ( consensus_seq_str . replace ( '*' , '-' ) , Gapped ( alpha , gap_char = '-' ) ) else : consensus_seq = Seq ( consensus_seq_str , alpha ) seq_record = SeqRecord ( consensus_seq , id = ace_contig . name , name = ace_contig . name ) quals = [ ] i = 0 for base in consensus_seq : if ( base == '-' ) : quals . append ( 0 ) else : quals . append ( ace_contig . quality [ i ] ) i += 1 assert ( i == len ( ace_contig . quality ) ) seq_record . letter_annotations [ 'phred_quality' ] = quals ( yield seq_record )
returns seqrecord objects from an ace file .