-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import dnacauldron | ||
|
||
|
||
class SeqCollection: | ||
"""Class to store basic properties of a collection of sequences. | ||
**Parameters** | ||
**fasta** | ||
> The FASTA file of the sequences. | ||
**cost_per_base** | ||
> Cost per nucleotide base. | ||
**cost_per_seq** | ||
> Fix overhead cost for each sequence part (cloning, delivery costs etc). | ||
**currency_symbol** | ||
> The currency symbol to display in the report. | ||
""" | ||
|
||
def __init__(self, fasta, cost_per_base=0.25, cost_per_seq=0, currency_symbol="£"): | ||
self.fasta = fasta | ||
self.cost_per_base = cost_per_base | ||
self.cost_per_seq = cost_per_seq | ||
self.currency_symbol = currency_symbol | ||
self.sequences = dnacauldron.biotools.load_records_from_files( | ||
files=[self.fasta], use_file_names_as_ids=False | ||
) | ||
self.n_seq = len(self.sequences) | ||
n_bp = 0 | ||
for part in self.sequences: | ||
n_bp += len(part.seq) | ||
self.n_bp = n_bp | ||
self.cost = self.n_seq * self.cost_per_seq + self.n_bp * self.cost_per_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .SeqCollection import SeqCollection | ||
from .reports import write_pdf_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.logos { | ||
margin: 0 auto; | ||
} | ||
|
||
h1.appendix { | ||
page-break-before: always; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
} | ||
|
||
.ribbon { | ||
margin-left: -2.3em !important; | ||
} | ||
|
||
.description { | ||
margin-top: 1em; | ||
} | ||
|
||
table { | ||
font-size: 0.6em !important; | ||
} | ||
|
||
table img { | ||
width: 1.5em; | ||
/* height: 1em; */ | ||
margin-right: 1em | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#sidebar: p {{sidebar_text}} | ||
|
||
.logos | ||
img(src="file:https:///{{ egf_logo_url }}" style="height:40px; width: auto") | ||
|
||
hr | ||
h1 Sequence report | ||
hr | ||
|
||
p. | ||
This document reports basic sequence statistics. | ||
p. | ||
Number of sequences: <b>{{ seqcollection.n_seq }}</b> | ||
p. | ||
Number of basepairs: <b>{{ seqcollection.n_bp }}</b> bp | ||
p. | ||
Estimated cost: <b>{{ seqcollection.currency_symbol }} {{ seqcollection.cost }}</b> | ||
|
||
|
||
div(style="margin-top:1cm; margin-bottom:1cm;") | ||
|
||
<div style = "display:block; clear:both; page-break-after:always;"></div> | ||
|
||
p | ||
strong Seq Report | ||
p. | ||
The report was generated by <a href="https://edinburgh-genome-foundry.github.io/Ediacara/">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. | ||
.green { | ||
color: #86bf86 | ||
} | ||
.grey { | ||
color: #a9a9a9 | ||
} | ||
.red { | ||
color: #fd5a31 | ||
} | ||
.yellow { | ||
color: #f7b500 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from datetime import datetime | ||
import os | ||
|
||
from pdf_reports import ( | ||
add_css_class, | ||
dataframe_to_html, | ||
pug_to_html, | ||
style_table_rows, | ||
write_report, | ||
) | ||
import pdf_reports.tools as pdf_tools | ||
|
||
from .version import __version__ | ||
|
||
THIS_PATH = os.path.dirname(os.path.realpath(__file__)) | ||
ASSETS_PATH = os.path.join(THIS_PATH, "report_assets") | ||
SEQCOLLECTION_REPORT_TEMPLATE = os.path.join(ASSETS_PATH, "seq_report.pug") | ||
STYLESHEET = os.path.join(ASSETS_PATH, "report_style.css") | ||
|
||
|
||
def end_pug_to_html(template, **context): | ||
now = datetime.now().strftime("%Y-%m-%d") | ||
defaults = { | ||
"sidebar_text": "Generated on %s by Seq Report (version %s)" | ||
% (now, __version__), | ||
} | ||
for k in defaults: | ||
if k not in context: | ||
context[k] = defaults[k] | ||
return pug_to_html(template, **context) | ||
|
||
|
||
def write_pdf_report(target, seqcollection): | ||
"""Write a sequence collection report with a PDF summary. | ||
**Parameters** | ||
**target** | ||
> Path for PDF file. | ||
**seqcollection** | ||
> `SeqCollection` instance. | ||
""" | ||
|
||
html = end_pug_to_html(SEQCOLLECTION_REPORT_TEMPLATE, seqcollection=seqcollection) | ||
write_report(html, target, extra_stylesheets=(STYLESHEET,)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters