|
15 | 15 | from projman_filler.repositories.sample_results_repo import SampleResultRepo |
16 | 16 | from projman_filler.repositories.flowcell_lane_results_repo import FlowcellLaneResultsRepo |
17 | 17 | from projman_filler.repositories.flowcell_runfolder_repo import FlowcellRunfolderRepo |
18 | | - |
| 18 | +from checkQC.qc_data import QCData |
19 | 19 |
|
20 | 20 | class App(object): |
21 | 21 |
|
@@ -59,39 +59,61 @@ def insert_flowcell_runfolder_into_db(self, runfolder, flowcell_name): |
59 | 59 | run_date=runfolder_date) |
60 | 60 | self.flowcell_runfolder_repo.add(flowcell_runfolder) |
61 | 61 |
|
62 | | - def insert_runfolder_into_db(self, runfolder, bcl2fastq_stats_dir, force=False, atac_seq_mode=False, olink_mode=False): |
63 | | - if olink_mode: |
64 | | - print("Olink mode activated. Will read lane-level statistics from InterOp files instead of bcl2fastq Stats.json.") |
65 | | - return self.insert_olink_runfolder_into_db(runfolder, force) |
66 | | - |
67 | | - bcl2fastq_stats = Bcl2fastqRunStatsParser(os.path.join(runfolder, bcl2fastq_stats_dir)) |
68 | | - flowcell_name = bcl2fastq_stats.get_flowcell_name() |
69 | | - reads_and_cycles = bcl2fastq_stats.get_reads_and_cycles() |
70 | | - conversion_results = bcl2fastq_stats.get_conversion_results() |
71 | | - |
72 | | - # Check if flowcell exists and should be overriden |
73 | | - self.delete_existing_flowcell_from_db(flowcell_name, force) |
74 | | - |
75 | | - # For atac-seq we run bcl2fastq with special parameters declaring |
76 | | - # that the second index should be interpreted as a non-index read. |
77 | | - # So we allow overriding the Interop list of non-index-reads with |
78 | | - # a custom list obtained from bcl2fastq stats. /ML 2021-09 |
79 | | - non_index_reads = None |
80 | | - if atac_seq_mode: |
81 | | - print("ATAC-seq mode activated. Will re-map read numbers according to settings used by bcl2fastq.") |
82 | | - non_index_reads = bcl2fastq_stats.get_non_index_reads() |
83 | | - |
84 | | - interop = InteropRunStatsParser(runfolder, non_index_reads) |
85 | | - lane_stats = calculate_lane_statistics(interop, flowcell_name, conversion_results) |
86 | | - self.flowcell_lane_results_repo.add(list(lane_stats)) |
87 | | - |
88 | | - samplesheet_file = os.path.join(runfolder, "SampleSheet.csv") |
89 | | - samplesheet = Samplesheet(samplesheet_file) |
90 | | - |
91 | | - sample_stats = calculate_sample_statistics(flowcell_name, conversion_results, reads_and_cycles, samplesheet) |
92 | | - self.sample_results_repo.add(list(sample_stats)) |
93 | | - |
94 | | - self.insert_flowcell_runfolder_into_db(runfolder, flowcell_name) |
| 62 | + def insert_runfolder_into_db(self, runfolder, bcl2fastq_stats_dir, demultiplexer, force=False, atac_seq_mode=False, olink_mode=False): |
| 63 | + interop = InteropRunStatsParser(runfolder) |
| 64 | + if demultiplexer == "bclconvert": |
| 65 | + |
| 66 | + qc_data_constructor = getattr(QCData, f"from_{demultiplexer}") |
| 67 | + qc_data = qc_data_constructor( |
| 68 | + runfolder_path=runfolder, |
| 69 | + parser_config={ |
| 70 | + "reports_location": "Reports" |
| 71 | + } |
| 72 | + ) |
| 73 | + flowcell_lane_results, sample_results = \ |
| 74 | + interop.get_checkqc_interop_stats(qc_data, runfolder) |
| 75 | + |
| 76 | + flowcell_name = interop.get_flowcell_name() |
| 77 | + # Check if flowcell exists and should be overriden |
| 78 | + self.delete_existing_flowcell_from_db(flowcell_name, force) |
| 79 | + |
| 80 | + self.flowcell_lane_results_repo.add(flowcell_lane_results) |
| 81 | + self.sample_results_repo.add(sample_results) |
| 82 | + |
| 83 | + self.insert_flowcell_runfolder_into_db(runfolder, flowcell_name) |
| 84 | + |
| 85 | + else: |
| 86 | + if olink_mode: |
| 87 | + print("Olink mode activated. Will read lane-level statistics from InterOp files instead of bcl2fastq Stats.json.") |
| 88 | + return self.insert_olink_runfolder_into_db(runfolder, force) |
| 89 | + |
| 90 | + bcl2fastq_stats = Bcl2fastqRunStatsParser(os.path.join(runfolder, bcl2fastq_stats_dir)) |
| 91 | + flowcell_name = bcl2fastq_stats.get_flowcell_name() |
| 92 | + reads_and_cycles = bcl2fastq_stats.get_reads_and_cycles() |
| 93 | + conversion_results = bcl2fastq_stats.get_conversion_results() |
| 94 | + |
| 95 | + # Check if flowcell exists and should be overriden |
| 96 | + self.delete_existing_flowcell_from_db(flowcell_name, force) |
| 97 | + |
| 98 | + # For atac-seq we run bcl2fastq with special parameters declaring |
| 99 | + # that the second index should be interpreted as a non-index read. |
| 100 | + # So we allow overriding the Interop list of non-index-reads with |
| 101 | + # a custom list obtained from bcl2fastq stats. /ML 2021-09 |
| 102 | + non_index_reads = None |
| 103 | + if atac_seq_mode: |
| 104 | + print("ATAC-seq mode activated. Will re-map read numbers according to settings used by bcl2fastq.") |
| 105 | + non_index_reads = bcl2fastq_stats.get_non_index_reads() |
| 106 | + |
| 107 | + lane_stats = calculate_lane_statistics(interop, flowcell_name, conversion_results) |
| 108 | + self.flowcell_lane_results_repo.add(list(lane_stats)) |
| 109 | + |
| 110 | + samplesheet_file = os.path.join(runfolder, "SampleSheet.csv") |
| 111 | + samplesheet = Samplesheet(samplesheet_file) |
| 112 | + |
| 113 | + sample_stats = calculate_sample_statistics(flowcell_name, conversion_results, reads_and_cycles, samplesheet) |
| 114 | + self.sample_results_repo.add(list(sample_stats)) |
| 115 | + |
| 116 | + self.insert_flowcell_runfolder_into_db(runfolder, flowcell_name) |
95 | 117 |
|
96 | 118 |
|
97 | 119 | def insert_olink_runfolder_into_db(self, runfolder, force=False): |
|
0 commit comments