astheeggeggs / lshmm

code to run Li and Stephens
MIT License
3 stars 3 forks source link

Refactor `get_emission_probability_haploid` and `get_index_in_emission_matrix_haploid` #98

Closed szhan closed 2 weeks ago

szhan commented 2 weeks ago

I think the logic of those functions can be put into one function, like the following:

@jit.numba_njit
def get_emission_probability_haploid(ref_allele, query_allele, site, emission_matrix):
    if ref_allele == NONCOPY:
        return 0.0
    elif query_allele == MISSING:
        return 1.0
    else:
        if ref_allele == query_allele:
            return emission_matrix[site, 1]
        else:
            return emission_matrix[site, 0]
szhan commented 2 weeks ago

Also, added some documentation. And modified how a test query is generated during testing.