From 0f756482a3ec645377967b29e9ffc5314a7aa32e Mon Sep 17 00:00:00 2001 From: chuan-wang Date: Thu, 12 Sep 2024 16:34:05 +0200 Subject: [PATCH 1/2] Fix bugs with EPP in the BCL conversion step --- VERSIONLOG.md | 4 ++ scripts/manage_demux_stats.py | 65 +++++++++++++----------- scripts/manage_demux_stats_thresholds.py | 2 +- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/VERSIONLOG.md b/VERSIONLOG.md index 0bedce79..cc989ac8 100644 --- a/VERSIONLOG.md +++ b/VERSIONLOG.md @@ -1,5 +1,9 @@ # Scilifelab_epps Version Log +## 20240912.3 + +Fix bugs with EPP in the BCL conversion step + ## 20240912.2 Support AVITI protocols for lobgook and comments_to_RN diff --git a/scripts/manage_demux_stats.py b/scripts/manage_demux_stats.py index af69aaf9..4cb88dd9 100644 --- a/scripts/manage_demux_stats.py +++ b/scripts/manage_demux_stats.py @@ -125,7 +125,7 @@ def get_process_stats(demux_process): elif "AVITI Run" in seq_process.type.name: try: - proc_stats["Chemistry"] = "AVITI" + seq_process.udf["Throughput Selection"] + proc_stats["Chemistry"] = "AVITI" + " " + seq_process.udf["Throughput Selection"] except Exception as e: problem_handler( "exit", f"No flowcell version set in sequencing step: {str(e)}" @@ -339,7 +339,11 @@ def set_sample_values(demux_process, parser_struct, process_stats): sample = entry["Sample"] # Finds name subset "P Anything Underscore Digits" if sample != "Undetermined": - sample = proj_pattern.search(sample).group(0) + try: + sample = proj_pattern.search(sample).group(0) + # PhiX cases for AVITI + except AttributeError: + pass if ( entry["Barcode sequence"] == "unknown" @@ -414,40 +418,41 @@ def set_sample_values(demux_process, parser_struct, process_stats): } for old_attr, attr in def_atr.items(): # Sets default value for unwritten fields - if entry[old_attr] == "" or entry[old_attr] == "NaN": - if old_attr == "% of Raw Clusters Per Lane": - default_value = 100.0 - else: - default_value = 0.0 - - samplesum[sample][attr] = ( - default_value - if attr not in samplesum[sample] - else samplesum[sample][attr] + default_value - ) - logger.info( - f"{attr} field not found. Setting default value: {default_value}" - ) + if old_attr in entry.keys(): + if entry[old_attr] == "" or entry[old_attr] == "NaN": + if old_attr == "% of Raw Clusters Per Lane": + default_value = 100.0 + else: + default_value = 0.0 - else: - # Yields needs division by 1K, is also non-percentage - if old_attr == "Yield (Mbases)": samplesum[sample][attr] = ( - my_float(entry[old_attr].replace(",", "")) - / 1000 + default_value if attr not in samplesum[sample] - else samplesum[sample][attr] - + my_float(entry[old_attr].replace(",", "")) - / 1000 + else samplesum[sample][attr] + default_value ) - else: - samplesum[sample][attr] = ( - my_float(entry[old_attr]) - if attr not in samplesum[sample] - else samplesum[sample][attr] - + my_float(entry[old_attr]) + logger.info( + f"{attr} field not found. Setting default value: {default_value}" ) + else: + # Yields needs division by 1K, is also non-percentage + if old_attr == "Yield (Mbases)": + samplesum[sample][attr] = ( + my_float(entry[old_attr].replace(",", "")) + / 1000 + if attr not in samplesum[sample] + else samplesum[sample][attr] + + my_float(entry[old_attr].replace(",", "")) + / 1000 + ) + else: + samplesum[sample][attr] = ( + my_float(entry[old_attr]) + if attr not in samplesum[sample] + else samplesum[sample][attr] + + my_float(entry[old_attr]) + ) + except Exception as e: problem_handler( "exit", diff --git a/scripts/manage_demux_stats_thresholds.py b/scripts/manage_demux_stats_thresholds.py index 977db5da..0567832a 100644 --- a/scripts/manage_demux_stats_thresholds.py +++ b/scripts/manage_demux_stats_thresholds.py @@ -166,7 +166,7 @@ def set_exp_lane_clust(self): # Preliminary values for AVITI elif self.instrument == "AVITI": if self.chemistry == "AVITI High": - self.exp_lane_clust = 100e6 + self.exp_lane_clust = 300e6 else: self.problem_handler("exit", "Unknown run type!") if not self.exp_lane_clust: From 8a32be1a1ef3c5cb75ffbc9e999432e569f0eb4a Mon Sep 17 00:00:00 2001 From: chuan-wang Date: Thu, 12 Sep 2024 16:35:15 +0200 Subject: [PATCH 2/2] ruff format --- scripts/manage_demux_stats.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/manage_demux_stats.py b/scripts/manage_demux_stats.py index 4cb88dd9..89e730d9 100644 --- a/scripts/manage_demux_stats.py +++ b/scripts/manage_demux_stats.py @@ -125,7 +125,9 @@ def get_process_stats(demux_process): elif "AVITI Run" in seq_process.type.name: try: - proc_stats["Chemistry"] = "AVITI" + " " + seq_process.udf["Throughput Selection"] + proc_stats["Chemistry"] = ( + "AVITI" + " " + seq_process.udf["Throughput Selection"] + ) except Exception as e: problem_handler( "exit", f"No flowcell version set in sequencing step: {str(e)}" @@ -419,7 +421,10 @@ def set_sample_values(demux_process, parser_struct, process_stats): for old_attr, attr in def_atr.items(): # Sets default value for unwritten fields if old_attr in entry.keys(): - if entry[old_attr] == "" or entry[old_attr] == "NaN": + if ( + entry[old_attr] == "" + or entry[old_attr] == "NaN" + ): if old_attr == "% of Raw Clusters Per Lane": default_value = 100.0 else: @@ -438,11 +443,15 @@ def set_sample_values(demux_process, parser_struct, process_stats): # Yields needs division by 1K, is also non-percentage if old_attr == "Yield (Mbases)": samplesum[sample][attr] = ( - my_float(entry[old_attr].replace(",", "")) + my_float( + entry[old_attr].replace(",", "") + ) / 1000 if attr not in samplesum[sample] else samplesum[sample][attr] - + my_float(entry[old_attr].replace(",", "")) + + my_float( + entry[old_attr].replace(",", "") + ) / 1000 ) else: