-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
111 lines (93 loc) · 3.75 KB
/
main.nf
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
#!/usr/bin/env nextflow
nextflow.preview.output = true
include { validateParameters; paramsHelp; paramsSummaryLog; fromSamplesheet } from 'plugin/nf-validation'
include { showSchemaHelp; extractType } from './modules/config/schema_helper.nf'
log.info """
| #################################################
| # _ _ _ #
| # | \\| | ___ __ __ ___ _ __ (_) __ #
| # | .` | / -_) \\ \\ / / _ \\ | ' \\ | | (_-< #
| # |_|\\_| \\___| /_\\_\\ \\___/ |_|_|_| |_| /__/ #
| # #
| #################################################
|
| viral-variant: Calling variants with peptide impact and comparison between samples (via transfer annotation): From raw reads, ref genome (with its own annotation or with other sequence and annotation to transfert annotation about PSA) and mapping of reads.
|
|""".stripMargin()
if (params.help) {
log.info paramsHelp("nextflow run nexomis/viral-variant --input </path/to/samplesheet> [args]")
log.info showSchemaHelp("assets/input_schema.json")
log.info showSchemaHelp("assets/refs_schema.json")
// log.info showSchemaHelp("assets/ref_genomes_schema.json")
exit 0
}
validateParameters()
log.info paramsSummaryLog(workflow)
file(params.out_dir + "/nextflow").mkdirs()
// groovy fonction within nextflow script
def parse_sample_entry(it) {
def type = "SR"
def files = [file(it[1])]
if (it[2] && !it[2].isEmpty() ) {
files << file(it[2])
type = "PE"
} else {
if (it[1].toString().toLowerCase().endsWith("spring")) {
type = "spring"
}
}
meta = [
"id": it[0],
"read_type": type,
"batch_id": it[3],
"rank_in_batch": it[4]
]
return [meta, files]
}
// include
include {PRIMARY} from './modules/subworkflows/primary/main.nf'
include {VIRAL_VARIANT} from './modules/subworkflows/viral_variant/main.nf'
workflow {
Channel.fromSamplesheet("input")
| map {
return parse_sample_entry(it)
}
| set { parsedInputs }
if (params.skip_primary) {
inReads = parsedInputs
} else {
if ( params.kraken2_db == null ) {
error "kraken2_db argument required for primary analysis"
}
Channel.fromPath(params.kraken2_db, type: "dir", checkIfExists: true)
| map {[["id": "kraken_db"], it]}
| collect
| set {dbPathKraken2}
taxDir = Channel.fromPath(params.tax_dir, type: 'dir')
numReads = Channel.value(params.num_reads_sample_qc)
PRIMARY(parsedInputs, dbPathKraken2, taxDir, numReads)
PRIMARY.out.trimmed
| set { inReads }
}
inputRefs = Channel.fromSamplesheet("refs")
inRef = inputRefs.map {[[id: it[0]], it[3] == "" ? [file(it[1]), file(it[2])] : [file(it[1])]]}
inAnnot = inputRefs.filter{it[3] != ""}.map{[[id: it[0]],[file(it[3]), file(it[2])]]}
VIRAL_VARIANT(inReads, inRef, inAnnot, params.mapper, params.var_caller)
publish:
VIRAL_VARIANT.out.sav_call_snv >> 'sav_call/snv'
VIRAL_VARIANT.out.sav_call_snv_rev >> 'sav_call/details'
VIRAL_VARIANT.out.sav_call_snv_fwd >> 'sav_call/details'
VIRAL_VARIANT.out.sav_call_snv_indel >> 'sav_call/details'
VIRAL_VARIANT.out.sav_call_snv_base >> 'sav_call/details'
VIRAL_VARIANT.out.summary_ivar_by_batch >> 'summary_ivar_by_batch/global'
VIRAL_VARIANT.out.summary_ivar_by_batch_light >> 'summary_ivar_by_batch/light'
VIRAL_VARIANT.out.summary_ivar_by_batch_long_frmt >> 'summary_ivar_by_batch/long_frmt'
VIRAL_VARIANT.out.transfered_gff >> 'transfered_annot'
VIRAL_VARIANT.out.psa_algn >> 'transfered_annot'
VIRAL_VARIANT.out.flagstat >> 'mapping/flagstat'
VIRAL_VARIANT.out.aln_bam >> 'mapping'
}
output {
directory "$params.out_dir"
mode "$params.publish_dir_mode"
}