from Bio import SeqIO
import logging
import unittest

from select_taxa import select_genomes_by_ids
import translate


class Test(unittest.TestCase):

    def setUp(self):
        self.longMessage = True
        logging.root.setLevel(logging.DEBUG)

    def test_translate_genomes(self):
        # Select genomes
        genomes = select_genomes_by_ids(['13305.1']).values()

        # Call translate
        dnafiles, aafiles = translate.translate_genomes(genomes)

        # Verify expected output
        first_header = '13305.1|NC_008253.1|YP_667942.1|None|thr'
        first = next(SeqIO.parse(dnafiles[0], 'fasta'))
        self.assertEqual(first_header, first.id)
        first = next(SeqIO.parse(aafiles[0], 'fasta'))
        self.assertEqual(first_header, first.id)

@@ -748,28 +748,591 @@
 ual(first_header, first.id)%0A
+%0A        # Verify no header appears twice%0A        headers = %5Brecord.id for record in SeqIO.parse(aafiles%5B0%5D, 'fasta')%5D%0A        self.assertEqual(len(headers), len(set(headers)))%0A%0A    def test_translate_93125_2(self):%0A        # Select genomes%0A        genomes = select_genomes_by_ids(%5B'93125.2'%5D).values()%0A%0A        # Call translate%0A        aafiles = translate.translate_genomes(genomes)%5B1%5D%0A%0A        # Verify no header appears twice%0A        headers = %5Brecord.id for record in SeqIO.parse(aafiles%5B0%5D, 'fasta')%5D%0A        self.assertEqual(len(headers), len(set(headers)))

Verify no header appears twice when translating 93125.2