Skip to content

Commit

Permalink
Merge pull request #489 from oicr-gsi/GCGI-1413_move-failed-report-pl…
Browse files Browse the repository at this point in the history
…ugin-to-summary

Gcgi 1413 move failed report plugin to summary
  • Loading branch information
AqsaAlam authored Jan 22, 2025
2 parents f2840f5 + c299f5e commit f092d00
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 169 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- GCGI-1481: Fix raw coverage auto-population to exclude normal samples before selection in TAR assay
- GCGI-1478: More informative logger name for plugin/helper/merger components
- GCGI-1479: New `--pre-populate` option in `djerba.py` setup mode
- GCGI-1413: Remove failed report plugin and allow summary plugin to handle failed reports
- GCGI-1482: Updated total genome segment length constant in percent genome altered calculation
- GCGI-1480: Updated CGI manager name and email
- GCGI-1490: Remove input paths from pwgs.analysis results
Expand Down
9 changes: 7 additions & 2 deletions src/lib/djerba/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,17 +576,22 @@ def update(self, config_path, json_path, out_dir, archive, pdf, summary_only, fo
# 1. INI config with core + plugins to update
# 2. Text file to update summary only
# The 'summary_only' argument controls which one is used
with open(json_path, encoding=cc.TEXT_ENCODING) as in_file:
data = json.loads(in_file.read())
if summary_only:
# get failed/not-failed status from input data
failed = data[cc.PLUGINS]['summary'][cc.RESULTS]['failed']
failed_opt = 'true' if failed else 'false'
self.logger.debug('Found report failure status: '+failed_opt)
# make an appropriate ConfigParser on-the-fly
config_in = ConfigParser()
config_in.add_section(cc.CORE)
config_in.add_section('summary')
config_in.set('summary', 'summary_file', config_path)
config_in.set('summary', 'failed', failed_opt)
config = self.configure_from_parser(config_in)
else:
config = self.configure(config_path)
with open(json_path, encoding=cc.TEXT_ENCODING) as in_file:
data = json.loads(in_file.read())
data_new = self.base_extract(config)
data = self.update_data_from_file(data_new, json_path, force)
if archive:
Expand Down
Empty file.
15 changes: 0 additions & 15 deletions src/lib/djerba/plugins/failed_report/failed_report_template.html

This file was deleted.

87 changes: 0 additions & 87 deletions src/lib/djerba/plugins/failed_report/plugin.py

This file was deleted.

Empty file.
3 changes: 0 additions & 3 deletions src/lib/djerba/plugins/failed_report/test/failed_report.ini

This file was deleted.

16 changes: 0 additions & 16 deletions src/lib/djerba/plugins/failed_report/test/failed_report.json

This file was deleted.

31 changes: 0 additions & 31 deletions src/lib/djerba/plugins/failed_report/test/plugin_test.py

This file was deleted.

16 changes: 12 additions & 4 deletions src/lib/djerba/plugins/summary/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,34 @@ class main(plugin_base):
PRIORITY = 400
PLUGIN_VERSION = '0.1'
MAKO_TEMPLATE_NAME = 'summary_report_template.html'
SUMMARY_TEMPLATE_FILE = 'summary_template.txt'
SUMMARY_TEMPLATE_FILE = 'templates/summary_template.txt'
FAILED_TEMPLATE_FILE = 'templates/failed_template.txt'
SUMMARY_FILE = 'summary_file'
SUMMARY_TEXT = 'summary_text'
FAILED = 'failed'

def configure(self, config):
config = self.apply_defaults(config)
wrapper = self.get_config_wrapper(config)
failed = wrapper.get_my_boolean(self.FAILED)
if wrapper.my_param_is_null(self.SUMMARY_FILE):
summary_template_path = \
os.path.join(os.path.dirname(__file__), self.SUMMARY_TEMPLATE_FILE)
wrapper.set_my_param(self.SUMMARY_FILE, summary_template_path)
if not failed:
template_path = os.path.join(os.path.dirname(__file__), self.SUMMARY_TEMPLATE_FILE)
elif failed:
template_path = os.path.join(os.path.dirname(__file__), self.FAILED_TEMPLATE_FILE)
wrapper.set_my_param(self.SUMMARY_FILE, template_path)
return wrapper.get_config()

def extract(self, config):
wrapper = self.get_config_wrapper(config)
summary_path = wrapper.get_my_string(self.SUMMARY_FILE)
failed = wrapper.get_my_boolean(self.FAILED)
with open(summary_path, encoding=core_constants.TEXT_ENCODING) as in_file:
summary_text = in_file.read()
self.logger.debug('Read summary from {0}: "{1}"'.format(summary_path, summary_text))
data = self.get_starting_plugin_data(wrapper, self.PLUGIN_VERSION)
data[core_constants.RESULTS][self.SUMMARY_TEXT] = summary_text
data[core_constants.RESULTS][self.FAILED] = failed
filename = 'results_summary.txt'
self.workspace.write_string(filename, summary_text)
self.logger.debug('Wrote summary to {0}'.format(self.workspace.abs_path(filename)))
Expand All @@ -49,6 +56,7 @@ def specify_params(self):
for key in discovered:
self.add_ini_discovered(key)
self.set_ini_default(core_constants.ATTRIBUTES, 'clinical')
self.set_ini_default(self.FAILED, False)
self.set_priority_defaults(self.PRIORITY)

def render(self, data):
Expand Down
12 changes: 9 additions & 3 deletions src/lib/djerba/plugins/summary/summary_report_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
from djerba.util.html import html_builder
from djerba.plugins.summary.plugin import main as summary
SUMMARY_TEXT = results.get(summary.SUMMARY_TEXT)
FAILED = results.get(summary.FAILED)
%>

<!-- results summary -->
${html_builder().section_cells_begin("<h2>Results Summary</h2>","main")}

${html_builder().markdown_to_html(SUMMARY_TEXT)}


% if not FAILED:
${html_builder().markdown_to_html(SUMMARY_TEXT)}
% elif FAILED:
<p style="border-width:3px; border-style:solid; border-color:#FF0000; padding: 1em;" ${html_builder().markdown_to_html(SUMMARY_TEXT)}</p>
% endif

${html_builder().section_cells_end()}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The patient has been diagnosed with ... and has been referred for the OICR Genomics ... assay through the ... study. A quality failure report for this sample is being issued due to the informatically inferred tumour purity of ...% which is below the reportable threshold of 30% for the assay \ is being issued due to failed extraction \ is being issued as the quantity of extracted DNA/RNA from tissue material was below the lower quantifiable range and therefore below the minimum input amount for this assay (minimums of 25ng for DNA and 50ng for RNA)...
4 changes: 4 additions & 0 deletions src/lib/djerba/plugins/summary/test/failed.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[core]

[summary]
failed = True
15 changes: 13 additions & 2 deletions src/lib/djerba/plugins/summary/test/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ def testSummary(self):
params = {
self.INI: 'summary.ini',
self.JSON: json_location,
self.MD5: '155e22cc02a45e04dc9058112354367c'
self.MD5: '1599ec66c80c2607e71a1dea9d53aacf'
}
self.run_basic_test(test_source_dir, params)

def testFailedSummary(self):
test_source_dir = os.path.realpath(os.path.dirname(__file__))
json_location = os.path.join(self.data_dir_root, "plugins", "summary", "report_json", "failed.json")
params = {
self.INI: 'failed.ini',
self.JSON: json_location,
self.MD5: 'abf18dc395150bf990a0b24b1cf9b422'
}
self.run_basic_test(test_source_dir, params)


def testSummaryWithCustomText(self):
test_source_dir = os.path.realpath(os.path.dirname(__file__))
summary_path = os.path.join(test_source_dir, 'custom_summary.txt')
Expand All @@ -43,7 +54,7 @@ def testSummaryWithCustomText(self):
params = {
self.INI: ini_path,
self.JSON: json_location,
self.MD5: 'cebbb53b9b074131e309dca71704a896'
self.MD5: 'b58589404184cd4b8d1a88f276f096b7'
}
self.run_basic_test(test_source_dir, params)

Expand Down
1 change: 1 addition & 0 deletions src/test/core/simple_report_for_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
],
"merge_inputs": {},
"results": {
"failed": false,
"summary_text": "Summary text goes here"
}
}
Expand Down
Loading

0 comments on commit f092d00

Please sign in to comment.