-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
649 lines (578 loc) · 27 KB
/
main.nf
File metadata and controls
649 lines (578 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
def pipelineVersion = params.pipeline_version ?: "0.3.0"
def helpMessage = """
================================================================================
P i p e V a r P i p e l i n e
Version: ${pipelineVersion}
================================================================================
QUICK USAGE
Single sample mode:
nextflow run main.nf [--bam sample.bam | --vcf sample.vcf] [options]
CSV batch mode:
nextflow run main.nf --input_csv samples.csv --bam true [options]
nextflow run main.nf --input_csv samples.csv --vcf true [options]
--------------------------------------------------------------------------------
EXECUTION PROFILES (nextflow.config)
--------------------------------------------------------------------------------
-profile standard
Default. SLURM executor + Singularity backend.
-profile slurm_singularity
Explicit SLURM + Singularity.
-profile local_singularity
Local executor + Singularity.
-profile local_docker
Local executor + Docker.
Container mount paths (used by Singularity/Docker profiles):
--annovar_host_path <DIR> Host path mounted to /annovar
--phenosv_host_path <DIR> Host path mounted to /PhenoSV/train_data
--------------------------------------------------------------------------------
INPUT MODES
--------------------------------------------------------------------------------
1) Single sample BAM/CRAM mode
Required:
--bam <FILE>
--ref_fa <FILE>
One phenotype source:
--note <FILE> (clinical note; pipeline runs PhenoTagger)
--hpo <FILE> (HPO IDs; pipeline skips PhenoTagger)
2) Single sample VCF mode
Required:
--vcf <FILE>
--ref_fa <FILE>
--mode <snp|sv>
One phenotype source:
--note <FILE> or --hpo <FILE>
3) CSV batch BAM mode
Required:
--input_csv <FILE> --bam true --ref_fa <FILE>
CSV columns:
sample,file_path,note_path
Optional age field for CSV prioritization flows:
sample,file_path,note_path,age_of_onset
sample,file_path,note_path,age
Notes:
age_of_onset is preferred if both columns exist
age is interpreted per CSV row (per sample), not globally
empty age is allowed (treated as not provided)
non-empty age must be xd/xm/xy or integer years
examples: 10d, 9m, 7y, 7 (normalized to 7y)
Note handling:
default -> note_path treated as clinical note (PhenoTagger ON)
--note no -> note_path treated as HPO file (PhenoTagger OFF)
4) CSV batch VCF mode
Required:
--input_csv <FILE> --vcf true --ref_fa <FILE> --mode <snp|sv>
CSV columns:
sample,file_path,note_path
Optional age field for CSV prioritization flows:
sample,file_path,note_path,age_of_onset
sample,file_path,note_path,age
Notes:
age_of_onset is preferred if both columns exist
age is interpreted per CSV row (per sample), not globally
empty age is allowed (treated as not provided)
non-empty age must be xd/xm/xy or integer years
examples: 10d, 9m, 7y, 7 (normalized to 7y)
--------------------------------------------------------------------------------
CORE OPTIONS
--------------------------------------------------------------------------------
--mode <snp|sv> Run only SNP or SV branch. Omit to run both where applicable.
--type <ont|pacbio|short>
Sequencing type for BAM/CRAM flows. Default: ont
--light <yes|no> Use lightweight SNP/SV models where supported. Default: no
--genome <hg38|grch38> Genome build for ExpansionHunter catalog. Default: hg38
--------------------------------------------------------------------------------
FILTERING OPTIONS
--------------------------------------------------------------------------------
--gnomad <FLOAT> Max gnomAD AF filter for SNP prioritization. Default: 0.0001
--inheritance_mode <ml|omim|gnomad>
Dominant/recessive assignment mode. Default: ml (ML-first, OMIM fallback)
Note: gnomad uses gnomAD constraint (LOEUF) fallback lists.
--include_clinvar_report <yes|no>
Include ClinVar-only calls in final prioritized report outputs. Default: yes
--allow_unphased_comphet <yes|no>
Treat unphased 0/1 or 1/0 AR het pairs as compound het in final prioritization. Default: no
--rankscore <FLOAT> Minimum RankScore cutoff. Default: 0.50
--rankscore_softwares <CSV> Comma-separated RankScore software list. Default: all
--rankvar <FLOAT> Minimum RankVar score cutoff. Default: 0.05
--gq <INT> Minimum genotype quality. Default: 20
--ad <INT> Minimum allele depth. Default: 15
--phen2gene_filter <INT> Number of top Phen2Gene genes used for targeted mode. Default: 500
--target <yes|no> If yes, run targeted calling in phenotype-derived gene regions.
--------------------------------------------------------------------------------
OUTPUT / GENERAL
--------------------------------------------------------------------------------
--out_prefix <STRING> Output prefix. Default: PipeVar
--output_directory <DIR> Output directory. Default: launch directory
--help Print this help text and exit
--------------------------------------------------------------------------------
EXAMPLES
--------------------------------------------------------------------------------
1) SLURM + Singularity (default), single long-read BAM, full path:
nextflow run main.nf \\
-profile standard \\
--bam /data/sample.bam \\
--ref_fa /refs/hg38.fa \\
--note /data/note.txt \\
--out_prefix patient1 \\
--type ont
2) Local + Docker, single VCF SNP re-annotation:
nextflow run main.nf \\
-profile local_docker \\
--vcf /data/sample.vcf \\
--ref_fa /refs/hg38.fa \\
--mode snp \\
--hpo /data/hpo.txt \\
--out_prefix patient_vcf_snp
3) CSV batch BAM with HPO inputs in note_path (PhenoTagger off):
nextflow run main.nf \\
-profile slurm_singularity \\
--input_csv /data/samples.csv \\
--bam true \\
--ref_fa /refs/hg38.fa \\
--note no
4) Local + Singularity with custom mount sources:
nextflow run main.nf \\
-profile local_singularity \\
--annovar_host_path /project/annovar \\
--phenosv_host_path /project/train_data \\
--bam /data/sample.bam \\
--ref_fa /refs/hg38.fa \\
--note /data/note.txt
NOTES
- BAM mode requires index files (.bai for BAM, .crai for CRAM).
- Reference FASTA index (.fai) must exist.
- For VCF single-file mode, provide --mode snp or --mode sv.
- For single-file mode, at least one of --note <FILE> or --hpo <FILE> is required.
================================================================================
"""
if (params.help) {
println(helpMessage)
exit(0)
}
// ------------------------------------------------------------------
// 0. PARAMETER NORMALIZATION (Fixing Capitalization/Spaces)
// ------------------------------------------------------------------
// We use the Elvis operator (?:) to handle nulls safely, defaulting to empty string if null
// We apply .trim() to remove spaces " ont " -> "ont"
// We apply .toLowerCase() to fix caps "ONT" -> "ont"
def clean_mode = params.mode ? params.mode.trim().toLowerCase() : null
def clean_type = params.type ? params.type.trim().toLowerCase() : 'ont' // Default from params
def clean_light = params.light ? params.light.trim().toLowerCase() : 'no'
def clean_genome = params.genome ? params.genome.trim().toLowerCase() : 'hg38'
def raw_target_param = params.target ?: params.targeted
def clean_target = raw_target_param ? raw_target_param.trim().toLowerCase() : 'no'
def clean_note = params.note ? params.note.trim().toLowerCase() : 'no'
def clean_inheritance_mode = params.inheritance_mode ? params.inheritance_mode.trim().toLowerCase() : 'ml'
def clean_include_clinvar_report = params.include_clinvar_report ? params.include_clinvar_report.trim().toLowerCase() : 'yes'
def clean_allow_unphased_comphet = params.allow_unphased_comphet ? params.allow_unphased_comphet.trim().toLowerCase() : 'no'
def clean_rankscore_softwares = params.rankscore_softwares ? params.rankscore_softwares.toString().trim() : ""
// ------------------------------------------------------------------
// 1. INPUT VALIDATION (Catching Typos)
// ------------------------------------------------------------------
// Define allowed vocabularies
def valid_modes = ['snp', 'sv']
def valid_types = ['ont', 'pacbio', 'short']
def valid_genomes = ['hg38', 'grch38']
def valid_inheritance_modes = ['ml', 'omim', 'gnomad']
def valid_yes_no = ['yes', 'no']
// CHECK 1: Validate Mode
if (clean_mode && !valid_modes.contains(clean_mode)) {
error """
================================================================
ERROR: Invalid Mode Specified
================================================================
You provided: --mode "${params.mode}"
We detected a typo. The valid options are:
--mode snp
--mode sv
(Case insensitive, but spelling must match)
================================================================
"""
}
// CHECK 2: Validate Data Type
if (!valid_types.contains(clean_type)) {
error """
================================================================
ERROR: Invalid Data Type
================================================================
You provided: --type "${params.type}"
Valid options are:
--type ont
--type pacbio
--type short
================================================================
"""
}
// CHECK 3: Validate Genome
if (!valid_genomes.contains(clean_genome)) {
error """
================================================================
ERROR: Unsupported Genome Build
================================================================
You provided: --genome "${params.genome}"
This pipeline currently supports:
--genome hg38
--genome grch38
================================================================
"""
}
// CHECK 4: Validate Inheritance Assignment Mode
if (!valid_inheritance_modes.contains(clean_inheritance_mode)) {
error """
================================================================
ERROR: Invalid Inheritance Assignment Mode
================================================================
You provided: --inheritance_mode "${params.inheritance_mode}"
Valid options are:
--inheritance_mode ml
--inheritance_mode omim
--inheritance_mode gnomad
Notes:
- ml = ML-first with OMIM fallback (current script behavior)
- gnomad maps to LOEUF fallback lists
================================================================
"""
}
if (!valid_yes_no.contains(clean_include_clinvar_report)) {
error """
================================================================
ERROR: Invalid ClinVar Report Toggle
================================================================
You provided: --include_clinvar_report "${params.include_clinvar_report}"
Valid options are:
--include_clinvar_report yes
--include_clinvar_report no
================================================================
"""
}
if (!valid_yes_no.contains(clean_allow_unphased_comphet)) {
error """
================================================================
ERROR: Invalid Unphased CompHet Toggle
================================================================
You provided: --allow_unphased_comphet "${params.allow_unphased_comphet}"
Valid options are:
--allow_unphased_comphet yes
--allow_unphased_comphet no
================================================================
"""
}
if (clean_rankscore_softwares && clean_rankscore_softwares.split(",").every { it.trim().isEmpty() }) {
error """
================================================================
ERROR: Invalid RankScore Software List
================================================================
You provided: --rankscore_softwares "${params.rankscore_softwares}"
Provide a comma-separated software list, e.g.:
--rankscore_softwares "REVEL,AlphaMissense,CADD_raw"
================================================================
"""
}
// ------------------------------------------------------------------
// INPUT VALIDATION AND ERROR MESSAGES
// ------------------------------------------------------------------
// 1. Check for Missing Inputs
if (!params.input_csv && !params.bam && !params.vcf) {
error """
ERROR: No input data specified.
You must provide one of the following:
--input_csv <path> : Path to CSV manifest
--bam <path> : Path to single BAM/CRAM file
--vcf <path> : Path to single VCF file
"""
}
// 2. Check for Ambiguous CSV Logic (Silent Failure Prevention)
// Your current logic requires params.bam or params.vcf to be truthy to process a CSV.
if (params.input_csv && !params.bam && !params.vcf) {
error """
ERROR: Input CSV specified, but data type is undefined.
When using --input_csv, you must also specify the data type flag to trigger the correct logic:
--bam true (if CSV contains BAM/CRAM paths)
--vcf true (if CSV contains VCF paths)
"""
}
// 3. Check for Missing Reference (Mandatory for BAM/CRAM)
// Logic: If BAM is being processed (either single or via CSV), Ref is required.
def is_bam_mode = params.bam || (params.input_csv && params.bam)
if (is_bam_mode && !params.ref_fa) {
error """
ERROR: Reference FASTA missing.
Processing BAM/CRAM files requires a reference genome.
Please specify: --ref_fa <path/to/reference.fasta>
"""
}
// 5. Check for Ref Fasta Index (Optional but recommended)
// If ref is provided, ensure .fai exists to prevent downstream crashes
if (params.ref_fa) {
def ref_fai = file("${params.ref_fa}.fai")
if (!ref_fai.exists()) {
error """
ERROR: Reference index (.fai) not found.
Expected at: ${ref_fai}
Please index your reference: samtools faidx ${params.ref_fa}
"""
}
}
include { SINGLE_ALIGNMENT_ALL_LONGPHASE } from './subworkflows/single_alignment_all_longphase'
include { SINGLE_ALIGNMENT_ALL_NGS } from './subworkflows/single_alignment_all_ngs'
include { SINGLE_ALIGNMENT_LONG_SNP } from './subworkflows/single_alignment_long_snp'
include { SINGLE_ALIGNMENT_LONG_SV } from './subworkflows/single_alignment_long_sv'
include { SINGLE_ALIGNMENT_NGS_SNP } from './subworkflows/single_alignment_ngs_snp'
include { SINGLE_ALIGNMENT_NGS_SV } from './subworkflows/single_alignment_ngs_sv'
include { SINGLE_ALIGNMENT_VCF_SNP } from './subworkflows/single_alignment_vcf_snp'
include { SINGLE_ALIGNMENT_VCF_SV } from './subworkflows/single_alignment_vcf_sv'
include { INPUT_CSV_ALIGNMENT_ALL_LONGPHASE } from './subworkflows/input_csv_alignment_all_longphase'
include { INPUT_CSV_ALIGNMENT_ALL_NGS } from './subworkflows/input_csv_alignment_all_ngs'
include { INPUT_CSV_ALIGNMENT_LONG_SNP } from './subworkflows/input_csv_alignment_long_snp'
include { INPUT_CSV_ALIGNMENT_LONG_SV } from './subworkflows/input_csv_alignment_long_sv'
include { INPUT_CSV_ALIGNMENT_NGS_SV } from './subworkflows/input_csv_alignment_ngs_sv'
include { INPUT_CSV_NGS_SNP } from './subworkflows/input_csv_alignment_ngs_snp'
include { INPUT_CSV_ALIGNMENT_VCF_SNP } from './subworkflows/input_csv_alignment_vcf_snp'
include { INPUT_CSV_ALIGNMENT_VCF_SV } from './subworkflows/input_csv_alignment_vcf_sv'
workflow {
def input_age = null
if ( params.input_csv ) {
input_age = Channel
.fromPath( params.input_csv )
.splitCsv( header:true )
.map { row ->
def out_prefix = row.sample
def has_age_of_onset = row.containsKey('age_of_onset')
def has_age = row.containsKey('age')
def age_source = has_age_of_onset ? 'age_of_onset' : (has_age ? 'age' : null)
def age_value = ''
if (age_source != null) {
def raw_age = row[age_source]
age_value = raw_age == null ? '' : raw_age.toString().trim().toLowerCase()
def age_match = (age_value =~ /^(\d+)([dmy])?$/)
if (age_value && !age_match.matches()) {
error """
ERROR: Invalid age value in input CSV for sample '${out_prefix}'.
Column '${age_source}' must be empty or match one of:
- <integer>
- <integer><unit> where unit is d/m/y
Received: '${age_value}'
"""
}
if (age_value && !age_match.group(2)) {
age_value = "${age_match.group(1)}y"
}
}
return tuple(out_prefix, age_value)
}
if ( params.vcf ) {
input_vcf = Channel
.fromPath( params.input_csv )
.splitCsv( header:true )
.map { row ->
def vcf_file = file(row.file_path, checkIfExists: true)
def note_file = file(row.note_path, checkIfExists: true)
def out_prefix = row.sample
// Return a List/tuple in a specific order
return tuple(
row.sample,
vcf_file,
note_file,
)
}
input_bam=null
}
else if ( params.bam ) {
input_bam = Channel
.fromPath( params.input_csv )
.splitCsv( header:true )
.map { row ->
def bam_file = file(row.file_path, checkIfExists: true)
// FIX: Manipulate the full string path, avoiding 'parent' nullability issues
// and handle both .bam.bai and .bai conventions automatically.
def bai_path = bam_file.toString().replaceFirst(/\.bam$/, ".bai")
def bai = file(bai_path)
// If the standard .bai doesn't exist, try the .bam.bai convention
if (!bai.exists()) {
bai = file("${bam_file}.bai")
}
// CRAM override
if (bam_file.name.endsWith('.cram')) {
bai = file("${bam_file}.crai")
}
// Ensure index actually exists before returning tuple to avoid downstream staging errors
if (!bai.exists()) {
error "Index file not found for ${bam_file}. Looked for: ${bai_path} or ${bam_file}.bai"
}
def note_file = file(row.note_path, checkIfExists: true)
def out_prefix = row.sample
def bam_file_parent = bam_file.parent
def note_file_parent = note_file.parent
// Return the tuple
return tuple(
out_prefix,
bam_file,
bai,
note_file,
)
}
input_vcf=null
}
}
else if ( params.bam != null ) {
Channel
.fromPath(params.bam )
.map { file ->
def meta = [ id: file.simpleName ]
// Dynamic Logic: If it ends in cram, look for .crai, else .bai
// Note: Check if your index naming is file.cram.crai or file.crai
def index = file.name.endsWith('.cram')
? file.parent / "${file.name}.crai"
: file.parent / "${file.name}.bai"
return [ file, index ]
}
.set { bam }
out_prefix=Channel.value(params.out_prefix)
}
else if ( params.vcf != null ) {
vcf=Channel.value(params.vcf)
out_prefix=Channel.value(params.out_prefix)
}
//Need to add dict file in case there is we are running haplotypecaller!!!!
if (params.ref_fa != null && params.light == 'yes' && params.type == 'short' ) {
ref_fa = Channel
.fromPath(params.ref_fa)
.map { fa_file ->
def fai_file = file("${fa_file}.fai")
def dict_file = file("${fa_file.parent}/${fa_file.baseName}.dict")
return [ fa_file, fai_file, dict_file ]
}
.first()
}
else if ( params.ref_fa != null ) {
ref_fa = Channel
.fromPath(params.ref_fa)
.map { fa_file ->
def fai_file = file("${fa_file}.fai")
return [ fa_file, fai_file ]
}
.first()
}
// `is_note` controls whether subworkflows run phenotagger ("yes") or treat the input as HPO IDs ("no").
def is_note = "no"
if ( params.input_csv ) {
// CSV mode default: note_path is treated as clinical notes unless user explicitly sets --note no.
is_note = (clean_note == 'no') ? "no" : "yes"
}
else {
// Single-file mode: `note` must be a file path; `hpo` is used directly as HPO input.
if ( params.note != null && clean_note != 'yes' && clean_note != 'no' ) {
note=Channel.value(params.note)
is_note = "yes"
}
else if ( params.hpo != null ) {
note=Channel.value(params.hpo)
is_note = "no"
}
else {
error """
ERROR: Missing phenotype input for single-file mode.
Provide one of:
--note <clinical_note_file>
--hpo <hpo_id_file>
"""
}
}
output_directory_check=file(params.output_directory)
if ( !output_directory_check.exists() ) {
output_directory_check.mkdirs()
}
type=Channel.value(params.type)
def inheritance_mode_script = (clean_inheritance_mode == 'gnomad') ? 'LOEUF' : 'OMIM'
inheritance_mode=Channel.value(inheritance_mode_script)
include_clinvar_report=Channel.value(clean_include_clinvar_report)
allow_unphased_comphet=Channel.value(clean_allow_unphased_comphet)
gnomad=Channel.value(params.gnomad)
rankscore_filter=Channel.value(params.rankscore)
rankscore_softwares=Channel.value(clean_rankscore_softwares)
rankvar_filter=Channel.value(params.rankvar)
phen2gene_top_n=Channel.value(params.phen2gene_filter)
gq=Channel.value(params.gq)
ad=Channel.value(params.ad)
short_snp_caller = Channel.value(clean_light == 'yes' ? 'haplotypecaller' : 'deepvariant')
long_snp_caller = Channel.value(clean_light == 'yes' ? 'nanocaller' : 'clair3')
def target="null"
if ( clean_target == 'yes' ) {
target = "yes"
}
if ( params.input_csv ) {
if ( input_vcf != null ) {
if ( params.mode == 'sv' ) {
INPUT_CSV_ALIGNMENT_VCF_SV(input_vcf, input_age, ref_fa, phen2gene_top_n, is_note, target, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
INPUT_CSV_ALIGNMENT_VCF_SNP(input_vcf, input_age, ref_fa, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
else if ( input_bam != null ) {
if ( params.type == 'short' ) {
if ( params.mode == 'sv' ) {
INPUT_CSV_ALIGNMENT_NGS_SV(input_bam, input_age, ref_fa, is_note, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
INPUT_CSV_NGS_SNP(input_bam, input_age, ref_fa, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, short_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else {
INPUT_CSV_ALIGNMENT_ALL_NGS(input_bam, input_age, ref_fa, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, short_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
else { // Long reads
if ( params.mode == 'sv' ) {
INPUT_CSV_ALIGNMENT_LONG_SV(input_bam, input_age, ref_fa, is_note, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
INPUT_CSV_ALIGNMENT_LONG_SNP(input_bam, input_age, ref_fa, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, long_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else {
INPUT_CSV_ALIGNMENT_ALL_LONGPHASE(input_bam, input_age, ref_fa, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, long_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
}
}
else { // Single File Mode
if ( params.vcf ) {
if ( params.mode == 'sv' ) {
SINGLE_ALIGNMENT_VCF_SV(vcf, out_prefix, ref_fa, note, phen2gene_top_n, is_note, target, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
SINGLE_ALIGNMENT_VCF_SNP(vcf, out_prefix, ref_fa, note, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
else if ( params.bam != null ) {
if ( params.type == 'short' ) {
if ( params.mode == 'sv' ) {
SINGLE_ALIGNMENT_NGS_SV(bam, out_prefix, ref_fa, note, is_note, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
SINGLE_ALIGNMENT_NGS_SNP(bam, out_prefix, ref_fa, note, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, short_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else {
SINGLE_ALIGNMENT_ALL_NGS(bam, out_prefix, ref_fa, note, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, short_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
else { // Long reads
if ( params.mode == 'sv' ) {
SINGLE_ALIGNMENT_LONG_SV(bam, out_prefix, ref_fa, note, is_note, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else if ( params.mode == 'snp' ) {
SINGLE_ALIGNMENT_LONG_SNP(bam, out_prefix, ref_fa, note, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, long_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
else {
SINGLE_ALIGNMENT_ALL_LONGPHASE(bam, out_prefix, ref_fa, note, rankscore_filter, rankscore_softwares, phen2gene_top_n, gnomad, gq, ad, rankvar_filter, is_note, target, long_snp_caller, inheritance_mode, include_clinvar_report, allow_unphased_comphet)
}
}
}
}
}
workflow.onComplete {
println "Pipeline completed at: $workflow.complete"
println "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
}
workflow.onError {
println "Error: Pipeline execution stopped with the following message: ${workflow.errorMessage}"
}