-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.nf
More file actions
87 lines (71 loc) · 3.05 KB
/
main.nf
File metadata and controls
87 lines (71 loc) · 3.05 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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { WHISPER } from './modules/local/whisper/main'
include { LINGUALAB_AUDIO } from './subworkflows/local/lingualab_audio/main'
include { LINGUALAB_TEXT } from './subworkflows/local/lingualab_text/main'
include { UHMOMETER } from './subworkflows/local/uhmometer/main'
include { OPENSMILE } from './modules/local/opensmile/main'
// Header info
def summary = [:]
summary['Pipeline Name'] = workflow.manifest.name
summary['Version'] = workflow.manifest.version
summary['Input'] = params.input
summary['Audio folder'] = params.audio_folder
summary['Text folder'] = params.text_folder
summary['Working dir'] = workflow.workDir
summary['Execution'] = workflow.commandLine
log.info """
===============================================================================
${summary.collect { key, value -> "${key.padRight(15)}: $value" }.join("\n")}
===============================================================================
"""
workflow get_data {
main:
// Input validation
if (!params.input) {
error "Input path not specified!"
}
// Read participants meta informations
participants_meta = Channel
.fromPath(params.input)
.splitCsv(header: true)
.map{ it -> tuple(it.participant_id, it)}
// Glob text files
text_folder = file(params.text_folder)
text_channel = Channel.fromPath("$text_folder/**$params.text_extension")
.map{ it -> tuple(it.name.split("_")[0], it)} // Extract participant_id from filename
.combine(participants_meta, by: 0) // Keep only participants from participants_meta
.map{ participant_id, filename, meta ->
def new_meta = meta + [filename: filename.name]
tuple(new_meta, filename)
}
// Glob audio files
audio_folder = file(params.audio_folder)
audio_channel = Channel.fromPath("$audio_folder/**$params.audio_extension")
.map{ it -> tuple(it.name.split("_")[0], it)} // Extract participant_id from filename
.combine(participants_meta, by: 0) // Keep only participants from participants_meta
.map{ participant_id, filename, meta ->
def new_meta = meta + [filename: filename.name]
tuple(new_meta, filename)
}
emit:
text = text_channel // channel: [ val(meta), text_file ]
audio = audio_channel // channel: [ val(meta), audio_file ]
}
workflow {
data = get_data()
WHISPER(data.audio)
UHMOMETER(data.audio)
OPENSMILE(
data.audio.collect { it[1] },
params.population_dir,
Channel.from(params.opensmile.feature_sets)
)
LINGUALAB_AUDIO(data.audio)
LINGUALAB_TEXT(data.text.mix(WHISPER.out.transcription))
}
workflow.onComplete {
log.info "Pipeline completed at: $workflow.complete"
log.info "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
log.info "Execution duration: $workflow.duration"
}