def test_get_dist_matrix(self): """Test dnadiff pairwise on multiple bins and get the resulting distance matrix""" names = [ "sample0_gt1000_bin0", "sample0_gt1000_bin10", "sample0_gt1000_bin11", "sample0_gt1000_bin1", "sample0_gt1000_bin2", "sample1_gt1000_bin51", "sample1_gt1000_bin67", "sample1_gt1000_bin6", ] files = [ospj(DATA_PATH, "{}.fa".format(n)) for n in names] dnadiff_dist_matrix.run_dnadiff_pairwise(files, names, TMP_BASENAME_DIR) for f in [ ospj(TMP_BASENAME_DIR, "{}_vs_{}".format(names[i], names[j]), "out.report") for i in range(len(names)) for j in range(i + 1, len(names))]: ok_(os.path.exists(f)) matrix = dnadiff_dist_matrix.get_dist_matrix(TMP_BASENAME_DIR, names, 50) matrix_exp = np.genfromtxt(ospj(DATA_PATH, "expected_dist_matrix.tsv"), delimiter="\t") np.testing.assert_almost_equal(matrix, matrix_exp, decimal=2)
def test_get_dist_matrix(self): """Test dnadiff pairwise on multiple bins and get the resulting distance matrix""" names = [ "sample0_gt1000_bin0", "sample0_gt1000_bin10", "sample0_gt1000_bin11", "sample0_gt1000_bin1", "sample0_gt1000_bin2", "sample1_gt1000_bin51", "sample1_gt1000_bin67", "sample1_gt1000_bin6", ] files = [ospj(DATA_PATH, "{}.fa".format(n)) for n in names] dnadiff_dist_matrix.run_dnadiff_pairwise(files, names, TMP_BASENAME_DIR) for f in [ ospj(TMP_BASENAME_DIR, "{}_vs_{}".format(names[i], names[j]), "out.report") for i in range(len(names)) for j in range(i + 1, len(names)) ]: ok_(os.path.exists(f)) matrix = dnadiff_dist_matrix.get_dist_matrix(TMP_BASENAME_DIR, names, 50) matrix_exp = np.genfromtxt(ospj(DATA_PATH, "expected_dist_matrix.tsv"), delimiter="\t") np.testing.assert_almost_equal(matrix, matrix_exp, decimal=2)
def test_run_dnadiff_pairwise(self): """Test dnadiff pairwise on multiple bins""" names = ["bin{0}".format(i) for i in range(3)] dnadiff_dist_matrix.run_dnadiff_pairwise( [ospj(DATA_PATH, b) for b in ["sample0_gt1000_bin0.fa", "sample0_gt1000_bin1.fa", "sample0_gt1000_bin2.fa"]], names, TMP_BASENAME_DIR) for f in [ ospj(TMP_BASENAME_DIR, "{}_vs_{}".format(names[i], names[j]), "out.report") for i in range(len(names)) for j in range(i + 1, len(names))]: ok_(os.path.exists(f))
def test_run_dnadiff_pairwise(self): """Test dnadiff pairwise on multiple bins""" names = ["bin{0}".format(i) for i in range(3)] dnadiff_dist_matrix.run_dnadiff_pairwise([ ospj(DATA_PATH, b) for b in [ "sample0_gt1000_bin0.fa", "sample0_gt1000_bin1.fa", "sample0_gt1000_bin2.fa" ] ], names, TMP_BASENAME_DIR) for f in [ ospj(TMP_BASENAME_DIR, "{}_vs_{}".format(names[i], names[j]), "out.report") for i in range(len(names)) for j in range(i + 1, len(names)) ]: ok_(os.path.exists(f))