|
| 1 | +#!/usr/bin/env nextflow |
| 2 | + |
| 3 | +/* |
| 4 | + Copyright (c) 2021, ICGC ARGO |
| 5 | +
|
| 6 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + of this software and associated documentation files (the "Software"), to deal |
| 8 | + in the Software without restriction, including without limitation the rights |
| 9 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + copies of the Software, and to permit persons to whom the Software is |
| 11 | + furnished to do so, subject to the following conditions: |
| 12 | +
|
| 13 | + The above copyright notice and this permission notice shall be included in all |
| 14 | + copies or substantial portions of the Software. |
| 15 | +
|
| 16 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + SOFTWARE. |
| 23 | +
|
| 24 | + Authors: |
| 25 | + Junjun Zhang |
| 26 | +*/ |
| 27 | + |
| 28 | +/* |
| 29 | + This is an auto-generated checker workflow to test the generated main template workflow, it's |
| 30 | + meant to illustrate how testing works. Please update to suit your own needs. |
| 31 | +*/ |
| 32 | + |
| 33 | +/********************************************************************/ |
| 34 | +/* this block is auto-generated based on info from pkg.json where */ |
| 35 | +/* changes can be made if needed, do NOT modify this block manually */ |
| 36 | +nextflow.enable.dsl = 2 |
| 37 | +version = '0.1.0' // package version |
| 38 | + |
| 39 | +container = [ |
| 40 | + 'ghcr.io': 'ghcr.io/icgc-argo-workflows/argo-somatic-variant-calling.strelka2' |
| 41 | +] |
| 42 | +default_container_registry = 'ghcr.io' |
| 43 | +/********************************************************************/ |
| 44 | + |
| 45 | +// universal params |
| 46 | +params.container_registry = "" |
| 47 | +params.container_version = "" |
| 48 | +params.container = "" |
| 49 | + |
| 50 | +// tool specific parmas go here, add / change as needed |
| 51 | +params.tumourBam = "" |
| 52 | +params.normalBam = "" |
| 53 | +params.referenceFa = "" |
| 54 | +params.isExome = true |
| 55 | + |
| 56 | +params.expected_snv_output = "" |
| 57 | +params.expected_indel_output = "" |
| 58 | + |
| 59 | +include { strelka2 } from '../main' |
| 60 | +include { getSecondaryFiles as getSec } from './wfpr_modules/github.com/icgc-argo-workflows/data-processing-utility-tools/helper-functions@1.0.2/main' |
| 61 | + |
| 62 | + |
| 63 | +process file_smart_diff { |
| 64 | + container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}" |
| 65 | + |
| 66 | + input: |
| 67 | + path output_somaticSnvVcf |
| 68 | + path expected_snv_output |
| 69 | + path output_somaticIndelVcf |
| 70 | + path expected_indel_output |
| 71 | + |
| 72 | + output: |
| 73 | + stdout() |
| 74 | + |
| 75 | + script: |
| 76 | + """ |
| 77 | + gunzip -c ${output_somaticSnvVcf} \ |
| 78 | + | grep -v '^#' > normalized_output_somaticSnvVcf |
| 79 | +
|
| 80 | + gunzip -c ${expected_snv_output} \ |
| 81 | + | grep -v '^#' > normalized_expected_snv_output |
| 82 | +
|
| 83 | + diff normalized_output_somaticSnvVcf normalized_expected_snv_output \ |
| 84 | + && ( echo -n "SNV calls MATCH. " ) || ( echo "Test FAILED, output SNV calls mismatch." && exit 1 ) |
| 85 | +
|
| 86 | + gunzip -c ${output_somaticIndelVcf} \ |
| 87 | + | grep -v '^#' > normalized_output_somaticIndelVcf |
| 88 | +
|
| 89 | + gunzip -c ${expected_indel_output} \ |
| 90 | + | grep -v '^#' > normalized_expected_indel_output |
| 91 | +
|
| 92 | + diff normalized_output_somaticIndelVcf normalized_expected_indel_output \ |
| 93 | + && ( echo "Indel calls MATCH. Test PASSED" && exit 0 ) || ( echo "Test FAILED, output Indel calls mismatch." && exit 1 ) |
| 94 | +
|
| 95 | + """ |
| 96 | +} |
| 97 | + |
| 98 | + |
| 99 | +workflow checker { |
| 100 | + take: |
| 101 | + tumourBam |
| 102 | + tumourBai |
| 103 | + normalBam |
| 104 | + normalBai |
| 105 | + referenceFa |
| 106 | + referenceFai |
| 107 | + isExome |
| 108 | + expected_snv_output |
| 109 | + expected_indel_output |
| 110 | + |
| 111 | + main: |
| 112 | + strelka2( |
| 113 | + tumourBam, |
| 114 | + tumourBai, |
| 115 | + normalBam, |
| 116 | + normalBai, |
| 117 | + referenceFa, |
| 118 | + referenceFai, |
| 119 | + isExome |
| 120 | + ) |
| 121 | + |
| 122 | + file_smart_diff( |
| 123 | + strelka2.out.somaticSnvVcf, |
| 124 | + expected_snv_output, |
| 125 | + strelka2.out.somaticIndelVcf, |
| 126 | + expected_indel_output |
| 127 | + ) |
| 128 | +} |
| 129 | + |
| 130 | + |
| 131 | +workflow { |
| 132 | + tumourIdx = params.tumourBam.endsWith('.bam') ? params.tumourBam + '.bai' : params.tumourBam + '.crai' |
| 133 | + normalIdx = params.normalBam.endsWith('.bam') ? params.normalBam + '.bai' : params.normalBam + '.crai' |
| 134 | + referenceIdx = params.referenceFa.endsWith('.fa.gz') ? getSec(params.referenceFa, ['fai', 'gzi']) : getSec(params.referenceFa, ['fai']) |
| 135 | + |
| 136 | + checker( |
| 137 | + file(params.tumourBam), |
| 138 | + file(tumourIdx), |
| 139 | + file(params.normalBam), |
| 140 | + file(normalIdx), |
| 141 | + file(params.referenceFa), |
| 142 | + Channel.fromPath(referenceIdx, checkIfExists: true).collect(), |
| 143 | + params.isExome, |
| 144 | + file(params.expected_snv_output), |
| 145 | + file(params.expected_indel_output) |
| 146 | + ) |
| 147 | +} |
0 commit comments