|
| 1 | +#!/usr/bin/env nextflow |
| 2 | + |
| 3 | +/* |
| 4 | + Copyright (c) 2020-2021, Ontario Institute for Cancer Research |
| 5 | +
|
| 6 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + you may not use this file except in compliance with the License. |
| 8 | + You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | +
|
| 18 | + Authors: |
| 19 | + Junjun Zhang |
| 20 | +*/ |
| 21 | + |
| 22 | +/* |
| 23 | + This is an auto-generated checker workflow to test the generated main template workflow, it's |
| 24 | + meant to illustrate how testing works. Please update to suit your own needs. |
| 25 | +*/ |
| 26 | + |
| 27 | +nextflow.enable.dsl = 2 |
| 28 | +version = '0.2.6' // package version |
| 29 | + |
| 30 | +// universal params |
| 31 | +params.publish_dir = "" |
| 32 | +params.container = "" |
| 33 | +params.container_registry = "" |
| 34 | +params.container_version = "" |
| 35 | + |
| 36 | +// tool specific parmas go here, add / change as needed |
| 37 | +params.input_file = "" |
| 38 | +params.expected_output = "" |
| 39 | +params.cleanup = false |
| 40 | + |
| 41 | +include { SongScoreUpload } from '../main' |
| 42 | +// include section starts |
| 43 | +// include section ends |
| 44 | + |
| 45 | + |
| 46 | +process file_smart_diff { |
| 47 | + input: |
| 48 | + path output_file |
| 49 | + path expected_file |
| 50 | + |
| 51 | + output: |
| 52 | + stdout() |
| 53 | + |
| 54 | + script: |
| 55 | + """ |
| 56 | + # Note: this is only for demo purpose, please write your own 'diff' according to your own needs. |
| 57 | + # remove date field before comparison eg, <div id="header_filename">Tue 19 Jan 2021<br/>test_rg_3.bam</div> |
| 58 | + # sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#' |
| 59 | +
|
| 60 | + diff <( cat ${output_file} | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \ |
| 61 | + <( ([[ '${expected_file}' == *.gz ]] && gunzip -c ${expected_file} || cat ${expected_file}) | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \ |
| 62 | + && ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 ) |
| 63 | + """ |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | +workflow checker { |
| 68 | + take: |
| 69 | + input_file |
| 70 | + expected_output |
| 71 | + |
| 72 | + main: |
| 73 | + SongScoreUpload( |
| 74 | + input_file |
| 75 | + ) |
| 76 | + |
| 77 | + file_smart_diff( |
| 78 | + SongScoreUpload.out.output_file, |
| 79 | + expected_output |
| 80 | + ) |
| 81 | +} |
| 82 | + |
| 83 | + |
| 84 | +workflow { |
| 85 | + checker( |
| 86 | + file(params.input_file), |
| 87 | + file(params.expected_output) |
| 88 | + ) |
| 89 | +} |
0 commit comments