def compare_record(old, new, truncate=None):
 if (old.id != new.id):
  raise ValueError(("'%s' vs '%s' " % (old.id, new.id)))
 if ((old.description != new.description) and (((old.id + ' ') + old.description).strip() != new.description) and (new.description != '<unknown description>') and (new.description != '')):
  raise ValueError(("'%s' vs '%s' " % (old.description, new.description)))
 if (len(old.seq) != len(new.seq)):
  raise ValueError(('%i vs %i' % (len(old.seq), len(new.seq))))
 if (isinstance(old.seq, UnknownSeq) or isinstance(new.seq, UnknownSeq)):
  pass
 elif (str(old.seq) != str(new.seq)):
  if (len(old.seq) < 200):
   raise ValueError(("'%s' vs '%s'" % (old.seq, new.seq)))
  else:
   raise ValueError(("'%s...' vs '%s...'" % (old.seq[:100], new.seq[:100])))
 if (('phred_quality' in old.letter_annotations) and ('phred_quality' in new.letter_annotations) and (old.letter_annotations['phred_quality'] != new.letter_annotations['phred_quality'])):
  if (truncate and ([min(q, truncate) for q in old.letter_annotations['phred_quality']] == [min(q, truncate) for q in new.letter_annotations['phred_quality']])):
   pass
  else:
   raise ValuerError('Mismatch in phred_quality')
 if (('solexa_quality' in old.letter_annotations) and ('solexa_quality' in new.letter_annotations) and (old.letter_annotations['solexa_quality'] != new.letter_annotations['solexa_quality'])):
  if (truncate and ([min(q, truncate) for q in old.letter_annotations['solexa_quality']] == [min(q, truncate) for q in new.letter_annotations['solexa_quality']])):
   pass
  else:
   raise ValueError('Mismatch in phred_quality')
 if (('phred_quality' in old.letter_annotations) and ('solexa_quality' in new.letter_annotations)):
  converted = [round(QualityIO.solexa_quality_from_phred(q)) for q in old.letter_annotations['phred_quality']]
  if truncate:
   converted = [min(q, truncate) for q in converted]
  if (converted != new.letter_annotations['solexa_quality']):
   print('')
   print(old.letter_annotations['phred_quality'])
   print(converted)
   print(new.letter_annotations['solexa_quality'])
   raise ValueError('Mismatch in phred_quality vs solexa_quality')
 if (('solexa_quality' in old.letter_annotations) and ('phred_quality' in new.letter_annotations)):
  converted = [round(QualityIO.phred_quality_from_solexa(q)) for q in old.letter_annotations['solexa_quality']]
  if truncate:
   converted = [min(q, truncate) for q in converted]
  if (converted != new.letter_annotations['phred_quality']):
   print(old.letter_annotations['solexa_quality'])
   print(converted)
   print(new.letter_annotations['phred_quality'])
   raise ValueError('Mismatch in solexa_quality vs phred_quality')
 return True

def compare_record ( old , new , truncate = None ) : if ( old . id != new . id ) : raise ValueError ( ( "'%s' vs '%s' " % ( old . id , new . id ) ) ) if ( ( old . description != new . description ) and ( ( ( old . id + ' ' ) + old . description ) . strip ( ) != new . description ) and ( new . description != '<unknown description>' ) and ( new . description != '' ) ) : raise ValueError ( ( "'%s' vs '%s' " % ( old . description , new . description ) ) ) if ( len ( old . seq ) != len ( new . seq ) ) : raise ValueError ( ( '%i vs %i' % ( len ( old . seq ) , len ( new . seq ) ) ) ) if ( isinstance ( old . seq , UnknownSeq ) or isinstance ( new . seq , UnknownSeq ) ) : pass elif ( str ( old . seq ) != str ( new . seq ) ) : if ( len ( old . seq ) < 200 ) : raise ValueError ( ( "'%s' vs '%s'" % ( old . seq , new . seq ) ) ) else : raise ValueError ( ( "'%s...' vs '%s...'" % ( old . seq [ : 100 ] , new . seq [ : 100 ] ) ) ) if ( ( 'phred_quality' in old . letter_annotations ) and ( 'phred_quality' in new . letter_annotations ) and ( old . letter_annotations [ 'phred_quality' ] != new . letter_annotations [ 'phred_quality' ] ) ) : if ( truncate and ( [ min ( q , truncate ) for q in old . letter_annotations [ 'phred_quality' ] ] == [ min ( q , truncate ) for q in new . letter_annotations [ 'phred_quality' ] ] ) ) : pass else : raise ValuerError ( 'Mismatch in phred_quality' ) if ( ( 'solexa_quality' in old . letter_annotations ) and ( 'solexa_quality' in new . letter_annotations ) and ( old . letter_annotations [ 'solexa_quality' ] != new . letter_annotations [ 'solexa_quality' ] ) ) : if ( truncate and ( [ min ( q , truncate ) for q in old . letter_annotations [ 'solexa_quality' ] ] == [ min ( q , truncate ) for q in new . letter_annotations [ 'solexa_quality' ] ] ) ) : pass else : raise ValueError ( 'Mismatch in phred_quality' ) if ( ( 'phred_quality' in old . letter_annotations ) and ( 'solexa_quality' in new . letter_annotations ) ) : converted = [ round ( QualityIO . solexa_quality_from_phred ( q ) ) for q in old . letter_annotations [ 'phred_quality' ] ] if truncate : converted = [ min ( q , truncate ) for q in converted ] if ( converted != new . letter_annotations [ 'solexa_quality' ] ) : print ( '' ) print ( old . letter_annotations [ 'phred_quality' ] ) print ( converted ) print ( new . letter_annotations [ 'solexa_quality' ] ) raise ValueError ( 'Mismatch in phred_quality vs solexa_quality' ) if ( ( 'solexa_quality' in old . letter_annotations ) and ( 'phred_quality' in new . letter_annotations ) ) : converted = [ round ( QualityIO . phred_quality_from_solexa ( q ) ) for q in old . letter_annotations [ 'solexa_quality' ] ] if truncate : converted = [ min ( q , truncate ) for q in converted ] if ( converted != new . letter_annotations [ 'phred_quality' ] ) : print ( old . letter_annotations [ 'solexa_quality' ] ) print ( converted ) print ( new . letter_annotations [ 'phred_quality' ] ) raise ValueError ( 'Mismatch in solexa_quality vs phred_quality' ) return True
this is meant to be a strict comparison for exact agreement .