from math import log

import pytest
from imm.testing import assert_allclose

from nmm import BaseAlphabet, BaseLprob


def test_base_lprob():
    base = BaseAlphabet.create(b"ACGT", b"X")
    basep = BaseLprob.create(base, (log(0.1), log(0.2), log(0.3), log(0.4)))
    assert_allclose(basep.lprob(b"A"), log(0.1))
    assert_allclose(basep.lprob(b"C"), log(0.2))
    assert_allclose(basep.lprob(b"G"), log(0.3))
    assert_allclose(basep.lprob(b"T"), log(0.4))

    with pytest.raises(Exception):
        basep = BaseLprob.create(base, (log(0.1), log(0.2), log(0.3)))
