Skip to content

Commit

Permalink
Change pipeline execution output filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjameskennedy committed Feb 3, 2025
1 parent 0e37f44 commit 1bca118
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
6 changes: 3 additions & 3 deletions assets/master_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ <h2 class="card-title mb-0">Sample Report</h2>
<td><a href="./nanoplot/{{ sample_id }}_T1_nanoplot_unprocessedWeightedHistogramReadlength.html">Weighted Histogram</a></td>
<td><a href="./nanoplot/{{ sample_id }}_T1_nanoplot_unprocessedWeightedLogTransformed_HistogramReadlength.html">Weighted Log-transformed Histogram</a></td>
<td><a href="./nanoplot/{{ sample_id }}_T1_nanoplot_unprocessedYield_By_Length.html">Yield by Length</a></td>
<td><a href="./pipeline_info/execution_report_{{ date_id }}.html">Execution Report</a></td>
<td><a href="./pipeline_info/execution_timeline_{{ date_id }}.html">Execution Timeline</a></td>
<td><a href="./pipeline_info/pipeline_dag_{{ date_id }}.html">Pipeline DAG</a></td>
<td><a href="./pipeline_info/execution_report.html">Execution Report</a></td>
<td><a href="./pipeline_info/execution_timeline.html">Execution Timeline</a></td>
<td><a href="./pipeline_info/pipeline_dag.html">Pipeline DAG</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down
21 changes: 3 additions & 18 deletions bin/generate_master_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,6 @@

args = parser.parse_args()

def get_date_id(samplesheet_csv_fpath):
date_ids = []
parent_dir = os.path.dirname(samplesheet_csv_fpath)
pipeline_info_dir = os.path.join(parent_dir, 'pipeline_info')
for filename in os.listdir(pipeline_info_dir):
if filename.startswith("execution_report"):
execution_report_fpath = os.path.join(pipeline_info_dir, filename)
date_id = find_date_in_string(execution_report_fpath, r'(\d{4}-\d{2}-\d{2}[^.]+)')
date_ids.append(date_id)
date_list = map(find_date_in_string, date_ids, [r'\b(\d{4}-\d{2}-\d{2})']*len(date_ids))
date_id_zipped = list(zip(date_ids, date_list))
sorted_date_ids = [date_id[0] for date_id in sorted(date_id_zipped, key=lambda date: datetime.strptime(date[1], "%Y-%m-%d"), reverse=True)]
return sorted_date_ids[0]

def find_date_in_string(input_string, date_pattern):
"""Searches for a date within a given string."""
date = ""
Expand All @@ -103,19 +89,18 @@ def get_sample_ids(samplesheet_csv):
sample_ids = df['sample'].tolist()
return sample_ids

def generate_master_html(template_html_fpath, sample_ids, seqrun_date, date_id):
def generate_master_html(template_html_fpath, sample_ids, seqrun_date):
"""Read the template from an HTML file."""
with open(template_html_fpath, "r") as file:
master_template = file.read()
template = Template(master_template)
rendered_html = template.render(sample_ids=sample_ids, seqrun_date=seqrun_date, date_id=date_id)
rendered_html = template.render(sample_ids=sample_ids, seqrun_date=seqrun_date)
return rendered_html

def main():
sample_ids = get_sample_ids(args.csv)
seqrun_date = find_date_in_string(args.csv, r'/(\d{8})_')
date_id = get_date_id(args.csv)
rendered_html = generate_master_html(args.html, sample_ids, seqrun_date, date_id)
rendered_html = generate_master_html(args.html, sample_ids, seqrun_date)
with open("master.html", "w") as fout:
fout.write(rendered_html)

Expand Down
13 changes: 8 additions & 5 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,25 @@ env {
// Capture exit codes from upstream processes when piping
process.shell = ['/bin/bash', '-euo', 'pipefail']

def trace_timestamp = new java.util.Date().format( 'yyyy-MM-dd_HH-mm-ss')
timeline {
enabled = true
file = "${params.tracedir}/execution_timeline_${trace_timestamp}.html"
overwrite = true
file = "${params.tracedir}/execution_timeline.html"
}
report {
enabled = true
file = "${params.tracedir}/execution_report_${trace_timestamp}.html"
overwrite = true
file = "${params.tracedir}/execution_report.html"
}
trace {
enabled = true
file = "${params.tracedir}/execution_trace_${trace_timestamp}.txt"
overwrite = true
file = "${params.tracedir}/execution_trace.txt"
}
dag {
enabled = true
file = "${params.tracedir}/pipeline_dag_${trace_timestamp}.html"
overwrite = true
file = "${params.tracedir}/pipeline_dag.html"
}

manifest {
Expand Down
3 changes: 1 addition & 2 deletions workflows/gmsemu.nf
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ workflow GMSEMU {
ch_input = GENERATE_INPUT.out.sample_sheet_merged
}

GENERATE_MASTER_HTML(GENERATE_INPUT.out.sample_sheet_merged)

// Validate and stage input files
INPUT_CHECK(ch_input)
ch_versions = ch_versions.mix(INPUT_CHECK.out.versions)
Expand Down Expand Up @@ -197,6 +195,7 @@ workflow GMSEMU {
)
multiqc_report = MULTIQC.out.report.toList()

GENERATE_MASTER_HTML(GENERATE_INPUT.out.sample_sheet_merged)

}
/*
Expand Down

0 comments on commit 1bca118

Please sign in to comment.