Skip to content

Commit

Permalink
Merge pull request #901 from kedhammar/toulligqc
Browse files Browse the repository at this point in the history
Add ToulligQC reports to ONT
  • Loading branch information
kedhammar authored Dec 9, 2024
2 parents f011208 + b5551a4 commit 519f685
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
9 changes: 7 additions & 2 deletions run_dir/design/ont_flowcell.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ <h4 class = "mt-3 mb-2">MinKNOW arguments</h4>
<a class="nav-link {{ 'active' if not sample_data else '' }}" href="#tab_barcode_information" role="tab" data-toggle="tab">Barcode counts</a>
</li>
{% end %}
{% if flowcell.get('TACA_run_status') == "finished" %}
{% if has_minknow_report %}
<li class="nav-item">
<a class="nav-link" href="/flowcells_ont/{{ flowcell.get('run_name') }}/report" target="_blank">MinKNOW run report</a>
<a class="nav-link" href="/flowcells_ont/{{ flowcell.get('run_name') }}/minknow_report" target="_blank">MinKNOW report</a>
</li>
{% end %}
{% if has_toulligqc_report %}
<li class="nav-item">
<a class="nav-link" href="/flowcells_ont/{{ flowcell.get('run_name') }}/toulligqc_report" target="_blank">ToulligQC report</a>
</li>
{% end %}
<li class="nav-item">
Expand Down
23 changes: 21 additions & 2 deletions status/flowcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,27 @@ def fetch_ont_run_stats(
return run_dict


class ONTReportHandler(SafeHandler):
class ONTMinKNOWReportHandler(SafeHandler):
"""Serves a page showing the MinKNOW .html report of a given run"""

def __init__(self, application, request, **kwargs):
super(SafeHandler, self).__init__(application, request, **kwargs)

def get(self, name):
reports_dir = self.application.minknow_path
reports_dir = self.application.minknow_reports_path
report_path = os.path.join(reports_dir, f"report_{name}.html")

self.write(open(report_path).read())


class ONTToulligQCReportHandler(SafeHandler):
"""Serves a page showing the ToulligQC .html report of a given run"""

def __init__(self, application, request, **kwargs):
super(SafeHandler, self).__init__(application, request, **kwargs)

def get(self, name):
reports_dir = self.application.toulligqc_reports_path
report_path = os.path.join(reports_dir, f"report_{name}.html")

self.write(open(report_path).read())
Expand Down Expand Up @@ -744,6 +757,12 @@ def get(self, name):
flowcell=self.fetch_ont_flowcell(name),
barcodes=self.fetch_barcodes(name),
args=self.fetch_args(name),
has_minknow_report=os.path.exists(
f"{self.application.minknow_reports_path}/report_{name}.html"
),
has_toulligqc_report=os.path.exists(
f"{self.application.toulligqc_reports_path}/report_{name}.html"
),
user=self.get_current_user(),
)
)
Expand Down
21 changes: 17 additions & 4 deletions status_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
ElementFlowcellHandler,
FlowcellHandler,
ONTFlowcellHandler,
ONTReportHandler,
ONTMinKNOWReportHandler,
ONTToulligQCReportHandler,
)
from status.flowcells import (
FlowcellDemultiplexHandler,
Expand Down Expand Up @@ -182,6 +183,8 @@
WorksetsHandler,
)

ONT_RUN_PATTERN = r"\d{8}_\d{4}_[0-9a-zA-Z]+_[0-9a-zA-Z]+_[0-9a-zA-Z]+"


class Application(tornado.web.Application):
def __init__(self, settings):
Expand Down Expand Up @@ -354,8 +357,15 @@ def __init__(self, settings):
("/flowcells", FlowcellsHandler),
(r"/flowcells/(\d{6,8}_[^/]*)$", FlowcellHandler),
(r"/flowcells_element/([^/]*)$", ElementFlowcellHandler),
(r"/flowcells_ont/(\d{8}_[^/]*)$", ONTFlowcellHandler),
(r"/flowcells_ont/(\d{8}_[^/]*)/[^/]*$", ONTReportHandler),
(rf"/flowcells_ont/({ONT_RUN_PATTERN})$", ONTFlowcellHandler),
(
rf"/flowcells_ont/({ONT_RUN_PATTERN})/minknow_report$",
ONTMinKNOWReportHandler,
),
(
rf"/flowcells_ont/({ONT_RUN_PATTERN})/toulligqc_report$",
ONTToulligQCReportHandler,
),
("/flowcells_plot", FlowcellPlotHandler),
("/ont_flowcells_plot", ONTFlowcellPlotHandler),
("/data_delivered_plot", DeliveryPlotHandler),
Expand Down Expand Up @@ -518,7 +528,10 @@ def __init__(self, settings):
self.multiqc_path = settings.get("multiqc_path")

# MinKNOW reports
self.minknow_path = settings.get("minknow_path")
self.minknow_reports_path = settings.get("minknow_reports_path")

# ToulligQC reports
self.toulligqc_reports_path = settings.get("toulligqc_reports_path")

# lims backend credentials
limsbackend_cred_loc = Path(
Expand Down

0 comments on commit 519f685

Please sign in to comment.