Repository navigation
Expand file tree
/
Copy pathmain.nf
More file actions
104 lines (88 loc) · 3.38 KB
/
Copy pathmain.nf
File metadata and controls
104 lines (88 loc) · 3.38 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// Module imports
include { GFFREAD } from './modules/gffread.nf'
include { KOFAMSCAN } from './modules/kofamScan.nf'
include { INTERPROSCAN } from './modules/interproscan.nf'
include { PROKKA } from './modules/prokka.nf'
include { BAKTA } from './modules/bakta.nf'
include { EGGNOG } from './modules/eggnog.nf'
include { PGAP } from './modules/pgap.nf'
//===========
//PROKARYOTES
//===========
// Validate required parameters for prokaryotic annotation
def validateProkaryoticInputs() {
def required = ['bakta_db_dir', 'eggnog_db_dir', 'pgap_dir']
def missing = required.findAll { !params[it] }
if (missing) {
error "Missing required parameters: ${missing.collect { "--${it}" }.join(', ')}"
}
required.each { name ->
def location = file(params[name])
if (!location.exists() || !location.isDirectory()) {
error "Parameter --${name} must be an existing directory: ${params[name]}"
}
}
}
// Build all channels needed for prokaryotic annotation
def createProkaryoticChannels() {
validateProkaryoticInputs()
def fasta_ch = Channel.fromPath("$projectDir/data/genome_prokaryote/*.fna", checkIfExists: true)
def bakta_db_ch = Channel.value(params.bakta_db_dir)
def eggnog_db_ch = Channel.value(params.eggnog_db_dir)
def pgap_dir_ch = Channel.value(params.pgap_dir)
return [fasta_ch, bakta_db_ch, eggnog_db_ch, pgap_dir_ch]
}
//===========
//EUKARYOTES
//===========
// Pair each genome FASTA with its corresponding GFF annotation
def createEukaryoticGenomePairs() {
Channel
.fromPath("$projectDir/data/genome_eukaryote/*.fna", checkIfExists: true)
.map { fa ->
def id = fa.baseName
def ann = file("data/eukaryotes/${id}.gff") // use GFF
tuple(id, fa, ann)
}
.filter { id, fa, ann ->
if (!ann.exists()) {
log.warn "Missing GFF annotation for genome: '${id}'. (${ann}) excluded."
return false
}
return true
}
}
// KofamScan database eukaryote inputs
def createEukaryoticKofamChannels() {
def profiles = Channel.fromPath("$projectDir/data/eukaryotes/db/kofamscam/profiles/*", checkIfExists: true)
def ko_list = Channel.fromPath("$projectDir/data/eukaryotes/db/kofamscam/ko_list", checkIfExists: true)
return [profiles, ko_list]
}
workflow prokaryote_annotation {
// Create channels for prokaryotic annotation
(fasta_ch, bakta_db_ch, eggnog_db_ch, pgap_dir_ch) = createProkaryoticChannels()
// 1) Run Prokka on the genome FASTA files
PROKKA(fasta_ch)
// 2) Run BAKTA on the genome FASTA files
BAKTA(fasta_ch, bakta_db_ch)
// 3) Run eggNOG-mapper on the genome FASTA files
EGGNOG(fasta_ch, eggnog_db_ch)
// 4) Run PGAP on the genome FASTA files
PGAP(fasta_ch, pgap_dir_ch)
}
workflow eukaryote_annotation {
// Create channels for eukaryotic annotation
genome_pairs = createEukaryoticGenomePairs()
(profiles, ko_list) = createEukaryoticKofamChannels()
// 1) Build protein sequences from genome + GFF using gffread
proteins = GFFREAD(genome_pairs)
// 2) Run InterProScan on the protein sequences
INTERPROSCAN(proteins)
// 3) Run KofamScan on the protein sequences
KOFAMSCAN(proteins, profiles, ko_list)
// 4) Run eggNOG-mapper on the protein sequences
EGGNOG(proteins, eggnog_db_ch)
}
workflow.onComplete { println "Workflow completed successfully!" }