|
1 | 1 | #!/usr/bin/env nextflow |
2 | 2 |
|
3 | 3 | /* |
4 | | - Copyright (C) 2021, Ontario Institute for Cancer Research |
| 4 | + Copyright (c) 2019-2021, Ontario Institute for Cancer Research (OICR). |
5 | 5 |
|
6 | 6 | This program is free software: you can redistribute it and/or modify |
7 | 7 | it under the terms of the GNU Affero General Public License as published by |
@@ -42,56 +42,57 @@ params.container_registry = "" |
42 | 42 | params.container_version = "" |
43 | 43 | params.container = "" |
44 | 44 |
|
45 | | -// tool specific parmas go here, add / change as needed |
46 | | -params.input_file = "" |
47 | | -params.expected_output = "" |
| 45 | +bwaSecondaryExts = ['fai', 'sa', 'bwt', 'ann', 'amb', 'pac', 'alt'] |
48 | 46 |
|
49 | | -include { helperFunctions } from '../main' |
| 47 | +params.file_name = null |
| 48 | +params.file_size = null |
50 | 49 |
|
| 50 | +include { |
| 51 | + getSecondaryFiles; |
| 52 | + getBwaSecondaryFiles |
| 53 | +} from '../main.nf' |
51 | 54 |
|
52 | | -process file_smart_diff { |
53 | | - container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}" |
| 55 | +include { |
| 56 | + generateDummyFile as gFile1; |
| 57 | + generateDummyFile as gFile2; |
| 58 | +} from './generate-dummy-file.nf' |
54 | 59 |
|
55 | | - input: |
56 | | - path output_file |
57 | | - path expected_file |
| 60 | +include { |
| 61 | + filesExist as fExist1; |
| 62 | + filesExist as fExist2; |
| 63 | +} from './files-exist.nf' |
58 | 64 |
|
59 | | - output: |
60 | | - stdout() |
| 65 | +Channel.from(params.file_name).set{ file_name_ch } |
| 66 | +Channel.from(bwaSecondaryExts).set{ bwa_ext_ch } |
61 | 67 |
|
62 | | - script: |
63 | | - """ |
64 | | - # Note: this is only for demo purpose, please write your own 'diff' according to your own needs. |
65 | | - # 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 |
|
68 | | - diff <( cat ${output_file} | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \ |
69 | | - <( ([[ '${expected_file}' == *.gz ]] && gunzip -c ${expected_file} || cat ${expected_file}) | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \ |
70 | | - && ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 ) |
71 | | - """ |
72 | | -} |
73 | | - |
74 | | - |
75 | | -workflow checker { |
76 | | - take: |
77 | | - input_file |
78 | | - expected_output |
| 69 | +workflow { |
| 70 | + // generate the main file |
| 71 | + gFile1( |
| 72 | + file_name_ch.flatten(), |
| 73 | + params.file_size |
| 74 | + ) |
79 | 75 |
|
80 | | - main: |
81 | | - helperFunctions( |
82 | | - input_file |
| 76 | + // generate the BWA secondary files |
| 77 | + gFile2( |
| 78 | + file_name_ch.combine(bwa_ext_ch), |
| 79 | + params.file_size |
83 | 80 | ) |
84 | 81 |
|
85 | | - file_smart_diff( |
86 | | - helperFunctions.out.output_file, |
87 | | - expected_output |
| 82 | + // test 'getSecondaryFiles' for expected 'fai' file exists |
| 83 | + fExist1( |
| 84 | + getSecondaryFiles(params.file_name, ['fai']), |
| 85 | + 'exist', |
| 86 | + gFile2.out.file.collect(), |
| 87 | + true // no need to wait |
88 | 88 | ) |
89 | | -} |
90 | 89 |
|
| 90 | + // test 'getBwaSecondaryFiles' for all expected bwa secondary files exist |
| 91 | + fExist2( |
| 92 | + getBwaSecondaryFiles(params.file_name).collect(), |
| 93 | + 'exist', |
| 94 | + gFile2.out.file.collect(), |
| 95 | + true // no need to wait |
| 96 | + ) |
91 | 97 |
|
92 | | -workflow { |
93 | | - checker( |
94 | | - file(params.input_file), |
95 | | - file(params.expected_output) |
96 | | - ) |
97 | 98 | } |
0 commit comments