def check_phylip_reject_duplicate():
 handle = StringIO()
 sequences = [SeqRecord(Seq('AAAA'), id='longsequencename1'), SeqRecord(Seq('AAAA'), id='longsequencename2'), SeqRecord(Seq('AAAA'), id='other_sequence')]
 alignment = MultipleSeqAlignment(sequences)
 try:
  AlignIO.write(alignment, handle, 'phylip')
  assert False, 'Duplicate IDs after truncation are not allowed.'
 except ValueError as e:
  assert ("Repeated name 'longsequen'" in str(e))

def check_phylip_reject_duplicate ( ) : handle = StringIO ( ) sequences = [ SeqRecord ( Seq ( 'AAAA' ) , id = 'longsequencename1' ) , SeqRecord ( Seq ( 'AAAA' ) , id = 'longsequencename2' ) , SeqRecord ( Seq ( 'AAAA' ) , id = 'other_sequence' ) ] alignment = MultipleSeqAlignment ( sequences ) try : AlignIO . write ( alignment , handle , 'phylip' ) assert False , 'Duplicate IDs after truncation are not allowed.' except ValueError as e : assert ( "Repeated name 'longsequen'" in str ( e ) )
ensure that attempting to write sequences with duplicate ids after truncation fails for phylip format .