Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Apr 19, 2024
1 parent 114efbb commit d944219
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 0 additions & 2 deletions tests/lsbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ def get_examples_parameters_diploid(self, ts, seed=42):
rs = [np.zeros(m) + 0.999, np.zeros(m) + 1e-6, np.random.rand(m)]
mus = [np.zeros(m) + 0.33, np.zeros(m) + 1e-6, np.random.rand(m) * 0.33]

e = self.get_emission_prob_matrix_diploid(mu, m)

for s, r, mu in itertools.product(genotypes, rs, mus):
r[0] = 0
e = self.get_emission_prob_matrix_diploid(mu, m)
Expand Down
11 changes: 0 additions & 11 deletions tests/test_API.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import itertools
import pytest

import numpy as np

import msprime
import tskit

from . import lsbase
import lshmm as ls
import lshmm.core as core
import lshmm.fb_diploid as fbd
import lshmm.fb_haploid as fbh
import lshmm.vit_diploid as vd
import lshmm.vit_haploid as vh


class TestMethodsHaploid(lsbase.FBAlgorithmBase):
"""Test that the computed likelihood is the same across all implementations."""

def test_simple_n_10_no_recombination(self):
ts = self.get_simple_n_10_no_recombination()
self.verify(ts)
Expand Down
32 changes: 32 additions & 0 deletions tests/test_API_multiallelic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@


class TestMethodsHaploid(lsbase.FBAlgorithmBase):
def test_multiallelic_n_10_no_recombination(self):
ts = self.get_multiallelic_n_10_no_recombination()
return ts

def test_multiallelic_n_6(self):
ts = self.get_multiallelic_n_6()
return ts

def test_multiallelic_n_8(self):
ts = self.get_multiallelic_n_8()
return ts

def test_multiallelic_n_16(self):
ts = self.get_multiallelic_n_16()
return ts

def verify(self, ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_parameters_haploid(ts):
F_vs, c_vs, ll_vs = fbh.forwards_ls_hap(n, m, H_vs, s, e_vs, r)
Expand Down Expand Up @@ -34,6 +50,22 @@ def verify(self, ts):


class TestViterbiHaploid(lsbase.ViterbiAlgorithmBase):
def test_multiallelic_n_10_no_recombination(self):
ts = self.get_multiallelic_n_10_no_recombination()
return ts

def test_multiallelic_n_6(self):
ts = self.get_multiallelic_n_6()
return ts

def test_multiallelic_n_8(self):
ts = self.get_multiallelic_n_8()
return ts

def test_multiallelic_n_16(self):
ts = self.get_multiallelic_n_16()
return ts

def verify(self, ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_parameters_haploid(ts):
V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_lower_mem_rescaling(
Expand Down

0 comments on commit d944219

Please sign in to comment.