def test_huddinge_upperlower(x, y): import pyhuddinge as ph h_dist_ll = ph.huddinge_distance(x, y) h_dist_lu = ph.huddinge_distance(x, y.upper()) h_dist_uu = ph.huddinge_distance(x.upper(), y.upper()) h_dist_ul = ph.huddinge_distance(x.upper(), y) assert h_dist_ll == h_dist_lu assert h_dist_ll == h_dist_ul assert h_dist_ll == h_dist_uu
def test_huddingepair_rc_closer(x, y): import pyhuddinge as ph h_dist = ph.huddinge_distance(x, y, False) h_dist_rc = ph.huddinge_distance(y, x, True) assert (h_dist >= h_dist_rc) if min(len(x.strip("n")), len(y.strip("n"))) > 0: assert (h_dist == 0 and x.strip("n") == y.strip("n")) or h_dist > 0 assert h_dist <= max(len(x.strip("n")), len(y.strip("n"))), h_dist
def test_huddingepair_rev_comp(x, y): import pyhuddinge as ph h_dist = ph.huddinge_distance(x, y) h_dist_rc = ph.huddinge_distance(x, y, True) h_dist_rcx = ph.huddinge_distance(reverse_complement(x), y) h_dist_rcy = ph.huddinge_distance(x, reverse_complement(y)) h_dist_rcxy = ph.huddinge_distance(reverse_complement(x), reverse_complement(y)) assert h_dist == h_dist_rcxy assert h_dist_rc <= h_dist assert h_dist_rc == min(h_dist_rcx, h_dist) assert h_dist_rcx == h_dist_rcy
def test_ungapkmers_PMC4362205_figS1B_ACnGT(): import pyhuddinge as ph A = "ACGT" ex = {"ACCT": 1, "CGTT": 1} for B, d in ex.items(): print(A, B) assert ph.huddinge_distance(A, B) == d, (A, B, d)
def test_huddingepair1(): import pyhuddinge as ph x, y = "AAAAAAA", "AAATAAA" h_dist = ph.huddinge_distance(x, y) assert h_dist == 1
def test_huddingepair_symmetry(x, y, reverse_complements): import pyhuddinge as ph h_dist = ph.huddinge_distance(x, y, reverse_complements) if reverse_complements: assert (h_dist == 0 and (x.strip("n") == y.strip("n") or x.strip("n") == reverse_complement(y).strip("n")) or min(len(x.strip("n")), len(y.strip("n"))) == 0) or (h_dist > 0 and x != y and x != reverse_complement(y)) else: assert (h_dist == 0 and x.strip("n") == y.strip("n") or min(len(x.strip("n")), len(y.strip("n"))) == 0) or (h_dist > 0 and x.strip("n") != y.strip("n")) assert h_dist <= max(len(x), len(y)), h_dist h_dist_v = ph.huddinge_distance(y, x, reverse_complements) assert h_dist_v == h_dist
def test_all_huddinge_pairs_concordance(kmers, reverse_complements): import pyhuddinge as ph print(repr(kmers), file=open("dump.py", "w")) D = ph.all_pairs_huddinge_distance(kmers, reverse_complements) assert len(D) == len(kmers) * (len(kmers) - 1) / 2 Dsq = ph.squareform(D, kmers) for i in Dsq.index: for j in Dsq.columns: if i < j: assert Dsq.loc[i, j] == ph.huddinge_distance( i, j, reverse_complements)
def test_huddingepair_nonbase(x, y): import pyhuddinge as ph with pytest.raises(ValueError): h_dist = ph.huddinge_distance(x, y)