import unittest
from micall.core import aln2counts


class TranslateTest(unittest.TestCase):
    def testSingleCodon(self):
        nucs = 'TTT'
        expected_aminos = 'F'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testPartialCodon(self):
        nucs = 'TTTCC'
        expected_aminos = 'F'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testTwoCodons(self):
        nucs = 'TTTCCT'
        expected_aminos = 'FP'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testLowerCase(self):
        nucs = 'TttCCT'
        expected_aminos = 'FP'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testOffset(self):
        nucs = "TTTCCT"
        offset = 3
        expected_aminos = "-FP"

        aminos = aln2counts.translate(nucs, offset)

        self.assertEqual(expected_aminos, aminos)

    def testSingleDashAmbiguous(self):
        nucs = '-TT'
        expected_aminos = '?'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testSingleDashUnambiguous(self):
        nucs = 'CG-'  # CGA, CGC, CGG, CGT all map to R
        expected_aminos = 'R'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testTwoDashes(self):
        nucs = '--T'
        expected_aminos = '?'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testThreeDashes(self):
        nucs = '---'
        expected_aminos = '-'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testAmbiguousBasesThatAreSynonyms(self):
        nucs = 'TTY'  # TTC or TTT: both map to F
        expected_aminos = 'F'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testTwoAmbiguousBasesThatAreSynonyms(self):
        nucs = 'MGR'  # CGA, CGG, AGA, or AGG: all map to R
        expected_aminos = 'R'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testTwoAmbiguousBasesThatAreNotSynonyms(self):
        nucs = 'RGR'  # GGA, GGG, AGA, or AGG: map to G and R, respectively
        expected_aminos = '?'

        aminos = aln2counts.translate(nucs)

        self.assertEqual(expected_aminos, aminos)

    def testMixturesNotTranslated(self):
        nucs = 'TTY'  # TTC or TTT: both map to F
        expected_aminos = '?'

        aminos = aln2counts.translate(nucs, translate_mixtures=False)

        self.assertEqual(expected_aminos, aminos)

@@ -25,30 +25,42 @@
 all.
-core import aln2counts
+utils.translation import translate
 %0A%0A%0Ac
@@ -194,35 +194,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -365,35 +365,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -535,35 +535,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -705,35 +705,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -892,35 +892,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -1076,35 +1076,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -1289,35 +1289,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -1455,35 +1455,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -1623,35 +1623,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -1838,35 +1838,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -2066,35 +2066,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -2313,35 +2313,24 @@
    aminos = 
-aln2counts.
 translate(nu
@@ -2499,32 +2499,32 @@
 d_aminos = '?'%0A%0A
+
         aminos =
@@ -2528,19 +2528,8 @@
 s = 
-aln2counts.
 tran

Use more direct import in translation_test.