Skip to content

Commit

Permalink
Correct update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjcroucher committed Oct 10, 2024
1 parent 9feb957 commit 1079fea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
28 changes: 19 additions & 9 deletions test/rfile123.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
7 12673_8#24.contigs_velvet.fa
1 12673_8#34.contigs_velvet.fa
2 12673_8#43.contigs_velvet.fa
6 12754_4#79.contigs_velvet.fa
4 12754_4#85.contigs_velvet.fa
5 12754_4#89.contigs_velvet.fa
8 12754_5#73.contigs_velvet.fa
3 12754_5#78.contigs_velvet.fa
9 12754_5#71.contigs_velvet.fa
12754_5#73 12754_5#73.contigs_velvet.fa
12754_4#79 12754_4#79.contigs_velvet.fa
12754_4#71 12754_4#71.contigs_velvet.fa
19183_4#55 19183_4#55.contigs_velvet.fa
19183_4#59 19183_4#59.contigs_velvet.fa
12754_4#89 12754_4#89.contigs_velvet.fa
19183_4#48 19183_4#48.contigs_velvet.fa
12754_5#37 12754_5#37.contigs_velvet.fa
19183_4#63 19183_4#63.contigs_velvet.fa
12754_5#71 12754_5#71.contigs_velvet.fa
19183_4#67 19183_4#67.contigs_velvet.fa
19183_4#69 19183_4#69.contigs_velvet.fa
12754_5#55 12754_5#55.contigs_velvet.fa
12754_4#85 12754_4#85.contigs_velvet.fa
12673_8#34 12673_8#34.contigs_velvet.fa
19183_4#66 19183_4#66.contigs_velvet.fa
12754_5#57 12754_5#57.contigs_velvet.fa
12754_5#16 12754_5#16.contigs_velvet.fa
12754_5#88 12754_5#88.contigs_velvet.fa
13 changes: 7 additions & 6 deletions test/test-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ def run_regression(x, y, threshold = 0.99):
sys.stderr.write("Distance matrix order failed!\n")
sys.exit(1)

def compare_sparse_matrices(d1,d2,r1,r2):
def compare_sparse_matrices(d1,d2,r1,r2,flag):
d1_pairs = get_seq_tuples(d1.row,d1.col,r1)
d2_pairs = get_seq_tuples(d2.row,d2.col,r2)
d1_dists = []
d2_dists = []
if (len(d1_pairs) != len(d2_pairs)):
if (len(d1_pairs) != len(d2_pairs) and flag == " "): # May not be equal if reciprocal/unique count
sys.stderr.write("Distance matrix number of entries differ!\n")
print(d1_pairs)
print(d2_pairs)
sys.exit(1)

for (pair1,dist1) in zip(d1_pairs,d1.data):
for (pair2,dist2) in zip(d2_pairs,d2.data):
# print('Pair1: ' + str(pair1) + ' Dist1: ' + str(dist1) + 'Pair2: ' + str(pair2) + ' Dist2: ' + str(dist2))
if pair1 == pair2:
d1_dists.append(dist1)
d2_dists.append(dist2)
Expand Down Expand Up @@ -90,13 +91,13 @@ def old_get_seq_tuples(rows,cols):
S1 = scipy.sparse.load_npz("batch12/batch12_rank_2_fit.npz")
S2 = scipy.sparse.load_npz("batch2/batch2_rank_2_fit.npz")
sys.stderr.write("Comparing sparse matrices at rank 2 after first query calculated with options " + lineage_option_string + "\n")
compare_sparse_matrices(S1,S2,rlist1,rlist2)
compare_sparse_matrices(S1,S2,rlist1,rlist2,lineage_option_string)

# Check rank 1
S3 = scipy.sparse.load_npz("batch12/batch12_rank_1_fit.npz")
S4 = scipy.sparse.load_npz("batch2/batch2_rank_1_fit.npz")
sys.stderr.write("Comparing sparse matrices at rank 1 after first query calculated with options " + lineage_option_string + "\n")
compare_sparse_matrices(S3,S4,rlist1,rlist2)
compare_sparse_matrices(S3,S4,rlist1,rlist2,lineage_option_string)

# Check distances after second query

Expand All @@ -117,10 +118,10 @@ def old_get_seq_tuples(rows,cols):
S5 = scipy.sparse.load_npz("batch123/batch123_rank_2_fit.npz")
S6 = scipy.sparse.load_npz("batch3/batch3_rank_2_fit.npz")
sys.stderr.write("Comparing sparse matrices at rank 2 after second query calculated with options " + lineage_option_string + "\n")
compare_sparse_matrices(S5,S6,rlist3,rlist4)
compare_sparse_matrices(S5,S6,rlist3,rlist4,lineage_option_string)

# Check rank 1
S7 = scipy.sparse.load_npz("batch123/batch123_rank_1_fit.npz")
S8 = scipy.sparse.load_npz("batch3/batch3_rank_1_fit.npz")
sys.stderr.write("Comparing sparse matrices at rank 1 after second query calculated with options " + lineage_option_string + "\n")
compare_sparse_matrices(S7,S8,rlist3,rlist4)
compare_sparse_matrices(S7,S8,rlist3,rlist4,lineage_option_string)

0 comments on commit 1079fea

Please sign in to comment.