|
| 1 | +#!/usr/bin/env nextflow |
| 2 | + |
| 3 | +/* |
| 4 | + Copyright (C) 2021, Ontario Institute for Cancer Research |
| 5 | +
|
| 6 | + This program is free software: you can redistribute it and/or modify |
| 7 | + it under the terms of the GNU Affero General Public License as published by |
| 8 | + the Free Software Foundation, either version 3 of the License, or |
| 9 | + (at your option) any later version. |
| 10 | +
|
| 11 | + This program is distributed in the hope that it will be useful, |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + GNU Affero General Public License for more details. |
| 15 | +
|
| 16 | + You should have received a copy of the GNU Affero General Public License |
| 17 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | +
|
| 19 | + Authors: |
| 20 | + Linda Xiang |
| 21 | +*/ |
| 22 | + |
| 23 | +/* |
| 24 | + This is an auto-generated checker workflow to test the generated main template workflow, it's |
| 25 | + meant to illustrate how testing works. Please update to suit your own needs. |
| 26 | +*/ |
| 27 | + |
| 28 | +/********************************************************************/ |
| 29 | +/* this block is auto-generated based on info from pkg.json where */ |
| 30 | +/* changes can be made if needed, do NOT modify this block manually */ |
| 31 | +nextflow.enable.dsl = 2 |
| 32 | +version = '0.1.0' // package version |
| 33 | + |
| 34 | +container = [ |
| 35 | + 'ghcr.io': 'ghcr.io/icgc-argo-workflows/data-processing-utility-tools.payload-gen-qc' |
| 36 | +] |
| 37 | +default_container_registry = 'ghcr.io' |
| 38 | +/********************************************************************/ |
| 39 | + |
| 40 | +// universal params |
| 41 | +params.container_registry = "" |
| 42 | +params.container_version = "" |
| 43 | +params.container = "" |
| 44 | + |
| 45 | +// tool specific parmas go here, add / change as needed |
| 46 | +params.input_file = "" |
| 47 | +params.expected_output = "" |
| 48 | + |
| 49 | +include { payloadGenQc } from '../main' |
| 50 | + |
| 51 | + |
| 52 | +process file_smart_diff { |
| 53 | + container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}" |
| 54 | + |
| 55 | + input: |
| 56 | + path output_file |
| 57 | + path expected_file |
| 58 | + |
| 59 | + output: |
| 60 | + stdout() |
| 61 | + |
| 62 | + script: |
| 63 | + """ |
| 64 | + # Note: this is only for demo purpose, please write your own 'diff' according to your own needs. |
| 65 | + # in this example, we need to remove date field before comparison eg, <div id="header_filename">Tue 19 Jan 2021<br/>test_rg_3.bam</div> |
| 66 | + # sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#' |
| 67 | +
|
| 68 | + cat ${output_file[0]} \ |
| 69 | + | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' > normalized_output |
| 70 | +
|
| 71 | + ([[ '${expected_file}' == *.gz ]] && gunzip -c ${expected_file} || cat ${expected_file}) \ |
| 72 | + | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' > normalized_expected |
| 73 | +
|
| 74 | + diff normalized_output normalized_expected \ |
| 75 | + && ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 ) |
| 76 | + """ |
| 77 | +} |
| 78 | + |
| 79 | + |
| 80 | +workflow checker { |
| 81 | + take: |
| 82 | + input_file |
| 83 | + expected_output |
| 84 | + |
| 85 | + main: |
| 86 | + payloadGenQc( |
| 87 | + input_file |
| 88 | + ) |
| 89 | + |
| 90 | + file_smart_diff( |
| 91 | + payloadGenQc.out.output_file, |
| 92 | + expected_output |
| 93 | + ) |
| 94 | +} |
| 95 | + |
| 96 | + |
| 97 | +workflow { |
| 98 | + checker( |
| 99 | + file(params.input_file), |
| 100 | + file(params.expected_output) |
| 101 | + ) |
| 102 | +} |
0 commit comments