From 71d288d7b47bbe872263920d87f9ba27f541f437 Mon Sep 17 00:00:00 2001 From: veghp Date: Thu, 25 Apr 2024 17:57:57 +0100 Subject: [PATCH] Refactor to collect re-use count --- seqreport/SeqCollection.py | 10 ++++++---- seqreport/report_assets/seq_report.pug | 17 +++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/seqreport/SeqCollection.py b/seqreport/SeqCollection.py index 54fac8b..fe86a7f 100644 --- a/seqreport/SeqCollection.py +++ b/seqreport/SeqCollection.py @@ -146,7 +146,7 @@ def calculate_values(self): next(reader) # ignore header for row in reader: all_rows += row[1:] # first column is construct name - self.savings_list = [] + self.savings_dict = {} self.total_savings = 0 for record in self.sequences: count_in_plan = all_rows.count(record.id) @@ -154,7 +154,7 @@ def calculate_values(self): self.total_savings += len(record.seq) * ( count_in_plan - 1 ) # ignore first synthesis - self.savings_list += [record.id] + self.savings_dict[record.id] = count_in_plan # else we don't have any savings from the sequence. if count_in_plan < 1: # also find the ones not in the assembly plan self.not_in_plan += [record.id] @@ -165,10 +165,12 @@ def calculate_values(self): self.total_cost_savings ) # (in)accuracy is fine for our purposes # For the PDF report: - self.savings_list_text = " ; ".join(self.savings_list) self.not_in_plan_text = " ; ".join(self.not_in_plan) + self.savings_dict_text = " ; ".join( + [f"{key} (×{value})" for key, value in self.savings_dict.items()] + ) else: - self.savings_list_text = "" + self.savings_dict_text = "" self.not_in_plan_text = "" diff --git a/seqreport/report_assets/seq_report.pug b/seqreport/report_assets/seq_report.pug index d889225..bbc00ec 100644 --- a/seqreport/report_assets/seq_report.pug +++ b/seqreport/report_assets/seq_report.pug @@ -69,9 +69,9 @@ else if seqcollection.assembly_plan - if seqcollection.savings_list_text + if seqcollection.savings_dict_text p. - Re-used sequences in the provided assembly plan: {{ seqcollection.savings_list_text }}. + Sequences used more than once in the provided assembly plan: {{ seqcollection.savings_dict_text }}. p. Total savings: {{ seqcollection.total_savings }} bp or {{ seqcollection.currency_symbol }}{{ seqcollection.total_cost_savings }}. else @@ -94,10 +94,10 @@ div(style="margin-top:1cm; margin-bottom:1cm;") p strong Seq Report p. - The report was generated by Seq Report, - a software published by the Edinburgh Genome Foundry (EGF). - Seq Report is part of the EGF Codons - engineering biology software suite for DNA design, manufacturing and validation. + The sequence re-use section shows the basepair-savings, and also ignores + per-sequence cost. For example, savings for seq1 (×3) with length L is calculated as + 2 × L × {{ seqcollection.currency_symbol }}/base. + p. Parameters: @@ -106,6 +106,11 @@ p.
  • Cost per sequence = {{ seqcollection.currency_symbol }}{{ seqcollection.cost_per_seq }}
  • +p. + The report was generated by Seq Report, + a software published by the Edinburgh Genome Foundry (EGF). + Seq Report is part of the EGF Codons + engineering biology software suite for DNA design, manufacturing and validation. style.