# Path: augur/translate.py
# class MissingNodeError(Exception):
# class MismatchNodeError(Exception):
# def safe_translate(sequence, report_exceptions=False):
# def translate_feature(aln, feature):
# def translate_vcf_feature(sequences, ref, feature):
#     def str_reverse_comp(str_seq):
# def construct_mut(start, pos, end):
# def assign_aa_vcf(tree, translations):
# def assign_aa_fasta(tree, translations):
# def get_genes_from_file(fname):
# def register_arguments(parser):
# def run(args):


import json
import numpy as np
import pytest
import sys
import os
import treetime
from pathlib import Path
from Bio.Seq import Seq
from Bio.SeqFeature import SeqFeature, FeatureLocation
from augur import translate
"""
Unit tests for nucleotide to acid translation
"""


# we assume (and assert) that this script is running from the tests/ directory
sys.path.append(str(Path(__file__).parent.parent.parent))


class TestTranslate:
    def test_safe_translate(self):
        '''
        Test safe_translate from a given nucleotide sequence with no gaps to amino acid, accounting for reporting_exceptions
        '''
        # initialize input and output tuples (tuple of params, expected outputs)
        params_and_outs = [(('ATG',), 'M'),
                           (('ATGGT-',), 'MX'),
                           (('ATG---',), 'M-'),
                           (('ATGTAG',), 'M*'),
                           (('',), ''),
                           (('ATGT',), 'MX'),
                           (('ATG', True), ('M', False)),
                           (('ATGA-G', True), ('MX', True))]

        # input each pair into the function and check
        for pair in params_and_outs:
            params, out = pair

# Path: augur/translate.py
# class MissingNodeError(Exception):
# class MismatchNodeError(Exception):
# def safe_translate(sequence, report_exceptions=False):
# def translate_feature(aln, feature):
# def translate_vcf_feature(sequences, ref, feature):
#     def str_reverse_comp(str_seq):
# def construct_mut(start, pos, end):
# def assign_aa_vcf(tree, translations):
# def assign_aa_fasta(tree, translations):
# def get_genes_from_file(fname):
# def register_arguments(parser):
# def run(args):


# Path: tests/test_translate.py
import json
import numpy as np
import pytest
import sys
import os
import treetime
from pathlib import Path
from Bio.Seq import Seq
from Bio.SeqFeature import SeqFeature, FeatureLocation
from augur import translate

"""
Unit tests for nucleotide to acid translation
"""


# we assume (and assert) that this script is running from the tests/ directory
sys.path.append(str(Path(__file__).parent.parent.parent))


class TestTranslate:
    def test_safe_translate(self):
        '''
        Test safe_translate from a given nucleotide sequence with no gaps to amino acid, accounting for reporting_exceptions
        '''
        # initialize input and output tuples (tuple of params, expected outputs)
        params_and_outs = [(('ATG',), 'M'),
                           (('ATGGT-',), 'MX'),
                           (('ATG---',), 'M-'),
                           (('ATGTAG',), 'M*'),
                           (('',), ''),
                           (('ATGT',), 'MX'),
                           (('ATG', True), ('M', False)),
                           (('ATGA-G', True), ('MX', True))]

        # input each pair into the function and check
        for pair in params_and_outs:
            params, out = pair

            assert translate.safe_translate(*params) == out