|
2 | 2 | from unittest.mock import MagicMock |
3 | 3 | from projman_filler.interop_run_stats_parser import InteropRunStatsParser |
4 | 4 | from interop import py_interop_run, py_interop_run_metrics, py_interop_summary |
| 5 | +import pandas as pd |
5 | 6 | import interop |
| 7 | +from projman_filler.lane import Lane |
| 8 | + |
6 | 9 |
|
7 | 10 | class TestRunStatsParsers(unittest.TestCase): |
8 | 11 | def test_interop_standardize_read_numbers(self): |
9 | 12 | runfolder = "tests/resources/200624_A00834_0183_BHMTFYTINY" |
10 | 13 |
|
11 | | - non_index_reads = [0, 2, 3] |
| 14 | + non_index_reads = [0] |
12 | 15 | iop = InteropRunStatsParser(runfolder, non_index_reads) |
13 | 16 | remapped = iop._standardize_read_numbers() |
14 | | - expected = {1: 0, 2: 2, 3: 3} |
| 17 | + expected = {1: 0} |
15 | 18 | self.assertEqual(remapped, expected) |
16 | 19 |
|
17 | 20 | reads = iop.get_reads() |
18 | | - expected = [1, 2, 3] |
| 21 | + expected = [1] |
19 | 22 | self.assertEqual(reads, expected) |
20 | 23 |
|
21 | 24 | def test_lanes_total_clusters(self): |
22 | | - non_index_reads = [0, 2, 3] |
| 25 | + non_index_reads = [0] |
23 | 26 | runfolder = "tests/resources/200624_A00834_0183_BHMTFYTINY" |
24 | 27 | iop = InteropRunStatsParser(runfolder, non_index_reads) |
25 | 28 | for lane in iop._conversion_results: |
26 | 29 | assert lane._total_clusters_pf is not None and lane._total_clusters_pf != 0 |
27 | 30 | assert lane._total_clusters_raw is not None and lane._total_clusters_raw != 0 |
28 | 31 |
|
| 32 | + def test_clusters_same_across_lanes(self): |
| 33 | + """ |
| 34 | + Verify that 'Reads' and 'Reads Pf' are consistently the same across all reads within the same lane |
| 35 | + """ |
| 36 | + non_index_reads = [0] |
| 37 | + runfolder = "tests/resources/200624_A00834_0183_BHMTFYTINY" |
| 38 | + iop = InteropRunStatsParser(runfolder, non_index_reads) |
| 39 | + |
| 40 | + interop_lane_summary = interop.summary(iop._run_metrics, 'Lane') |
| 41 | + df = pd.DataFrame(interop_lane_summary) |
| 42 | + |
| 43 | + for lane_index, (lane, rows) in enumerate(df.groupby('Lane')): |
| 44 | + rows = rows.reset_index() |
| 45 | + # Assert all 'Reads' and 'Reads Pf' values are consistent within the lane |
| 46 | + assert rows['Reads'].nunique() == 1, ( |
| 47 | + f"Inconsistent 'Reads' in lane {lane}" |
| 48 | + ) |
| 49 | + assert rows['Reads Pf'].nunique() == 1, ( |
| 50 | + f"Inconsistent 'Reads Pf' in lane {lane}" |
| 51 | + ) |
| 52 | + |
| 53 | + # These are the same for the lane across all reads |
| 54 | + total_clusters_pf = rows.at[0, 'Reads Pf'] |
| 55 | + total_clusters_raw = rows.at[0, 'Reads'] |
| 56 | + |
| 57 | + |
| 58 | + # Compare with InteropRunStatsParser results |
| 59 | + lane_results = iop._conversion_results[lane_index] |
| 60 | + assert lane_results._total_clusters_pf == total_clusters_pf, ( |
| 61 | + f"Mismatch in total_clusters_pf for lane {lane}" |
| 62 | + ) |
| 63 | + assert lane_results._total_clusters_raw == total_clusters_raw, ( |
| 64 | + f"Mismatch in total_clusters_raw for lane {lane}" |
| 65 | + ) |
| 66 | + |
29 | 67 | if __name__ == '__main__': |
30 | 68 | unittest.main() |
| 69 | + |
0 commit comments