Skip to content

Commit

Permalink
Refactor to collect re-use count
Browse files Browse the repository at this point in the history
  • Loading branch information
veghp committed Apr 25, 2024
1 parent 244e5a2 commit 71d288d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
10 changes: 6 additions & 4 deletions seqreport/SeqCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ 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)
if count_in_plan > 1: # we count re-use savings only
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]
Expand All @@ -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 = ""


Expand Down
17 changes: 11 additions & 6 deletions seqreport/report_assets/seq_report.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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: <b>{{ seqcollection.total_savings }}</b> bp or <b>{{ seqcollection.currency_symbol }}{{ seqcollection.total_cost_savings }}</b>.
else
Expand All @@ -94,10 +94,10 @@ div(style="margin-top:1cm; margin-bottom:1cm;")
p
strong Seq Report
p.
The report was generated by <a href="https://github.com/Edinburgh-Genome-Foundry/Seq_Report/">Seq Report</a>,
a software published by the Edinburgh Genome Foundry (EGF).
Seq Report is part of the <a href="https://edinburgh-genome-foundry.github.io/">EGF Codons</a>
engineering biology software suite for DNA design, manufacturing and validation.
The sequence re-use section shows the basepair-<i>savings</i>, 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:
Expand All @@ -106,6 +106,11 @@ p.
<li>Cost per sequence = <b>{{ seqcollection.currency_symbol }}{{ seqcollection.cost_per_seq }}</b> </li>
</ul>

p.
The report was generated by <a href="https://github.com/Edinburgh-Genome-Foundry/Seq_Report/">Seq Report</a>,
a software published by the Edinburgh Genome Foundry (EGF).
Seq Report is part of the <a href="https://edinburgh-genome-foundry.github.io/">EGF Codons</a>
engineering biology software suite for DNA design, manufacturing and validation.


style.
Expand Down

0 comments on commit 71d288d

Please sign in to comment.