def test_translate(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 161
    config['endBase'] = 355
    result = parsing.translate(config, rc=False)
    assert result['seq'] == 'CTGCCTTTTGGTGTCGTTTATTTCGGCTTTTGCCATAGAAGCCAAAGCCCCCAGAAGTTCGCCTTTGTCCCATGTTGGATTGCCGGTCTTACTATCGACCAGACCGGCCAGAATAAGCAGGCCAGCAGACTGGATGAGGTTATGCGTTCTTTCCTTGTCCTTGGCGTCTCTTTCTCTCTTGGCGATTTTCGATGA'
    assert result['trans'] == 'LPFGVVYFGFCHRSQSPQKFAFVPCWIAGLTIDQTGQNKQASRLDEVMRSFLVLGVSFSLGDFR*'
def test_trans_complement(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 116
    config['endBase'] = 562
    result = parsing.translate(config, rc=True)
    assert result['seq'] == 'ATGGCCTCTTTTCGGATTGAAACGCATATCGCTAACCTTCGACAGCTTGAGAAGCCATCGACAGAACAGCGCATCCTGATCTTGCTCTATGACAAGACTGACAGAACGCCAAAAGAGGAAAGAGACCTCAAGGCACTCATCCGGTCGGAAAAAGCGCAGGAAGCCGTAAAAGAGGCTAAAGCCAAAGCATCCGAAGCAAAGGCCAGATCATCGAAAATCGCCAAGAGAGAAAGAGACGCCAAGGACAAGGAAAGAACGCATAACCTCATCCAGTCTGCTGGCCTGCTTATTCTGGCCGGTCTGGTCGATAGTAAGACCGGCAATCCAACATGGGACAAAGGCGAACTTCTGGGGGCTTTGGCTTCTATGGCAAAAGCCGAAATAAACGACACCAAAAGGCAGGAGTGGAAAGAAAAAGGTGATGCGTTATTAGCCGGAGAAAAATGA'
    assert result['trans'] == 'MASFRIETHIANLRQLEKPSTEQRILILLYDKTDRTPKEERDLKALIRSEKAQEAVKEAKAKASEAKARSSKIAKRERDAKDKERTHNLIQSAGLLILAGLVDSKTGNPTWDKGELLGALASMAKAEINDTKRQEWKEKGDALLAGEK*'
def test_trans_myco(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 116
    config['endBase'] = 562
    config['mycoplasma'] = True
    result = parsing.translate(config, rc=True)
    assert result['trans'] == 'MASFRIETHIANLRQLEKPSTEQRILILLYDKTDRTPKEERDLKALIRSEKAQEAVKEAKAKASEAKARSSKIAKRERDAKDKERTHNLIQSAGLLILAGLVDSKTGNPTWDKGELLGALASMAKAEINDTKRQEWKEKGDALLAGEKW'
def translate2(path):
    "Translate the known file with params"
    config = build_config(path)
    try:
        return jsonify(
            parsing.translate(config, parsing.tobool(request.args.get('rc')))
        )
    except Exception as e:
        logger.exception('Error While Translating')
        return flask.make_response(repr(e), 500)