Skip to content

Commit

Permalink
Hello Channels COMPLETE
Browse files Browse the repository at this point in the history
Managed to get map() in there after all! Thanks Rob for the feedback that got me there
  • Loading branch information
vdauwera committed Jan 21, 2025
1 parent 745f709 commit b20c55c
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 171 deletions.
467 changes: 296 additions & 171 deletions docs/hello_nextflow/02_hello_channels.md

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions hello-nextflow/hello-channels.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path 'output.txt'

script:
"""
echo '$greeting' > output.txt
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'Holà mundo!'

workflow {

// emit a greeting
sayHello(params.greeting)
}
36 changes: 36 additions & 0 deletions hello-nextflow/hello-workflow.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path "${greeting}-output.txt"

script:
"""
echo '$greeting' > '$greeting-output.txt'
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'greetings.csv'

workflow {

// create a channel for inputs from a CSV file
greeting_ch = Channel.fromPath(params.greeting)
.splitCsv()
.map { line -> line[0] }

// emit a greeting
sayHello(greeting_ch)
}
3 changes: 3 additions & 0 deletions hello-nextflow/solutions/2-hello-channels/greetings-4.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hello,English
Bonjour,French
Holà,Spanish
34 changes: 34 additions & 0 deletions hello-nextflow/solutions/2-hello-channels/hello-channels-1.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path 'output.txt'

script:
"""
echo '$greeting' > output.txt
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'Holà mundo!'

workflow {

// create a channel for inputs
greeting_ch = Channel.of('Hello Channels!')

// emit a greeting
sayHello(greeting_ch)
}
34 changes: 34 additions & 0 deletions hello-nextflow/solutions/2-hello-channels/hello-channels-2.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path "${greeting}-output.txt"

script:
"""
echo '$greeting' > '$greeting-output.txt'
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'Holà mundo!'

workflow {

// create a channel for inputs
greeting_ch = Channel.of('Hello','Bonjour','Holà')

// emit a greeting
sayHello(greeting_ch)
}
39 changes: 39 additions & 0 deletions hello-nextflow/solutions/2-hello-channels/hello-channels-3.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path "${greeting}-output.txt"

script:
"""
echo '$greeting' > '$greeting-output.txt'
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'Holà mundo'

workflow {

greetings_array = ['Hello','Bonjour','Holà']

// create a channel for inputs
greeting_ch = Channel.of(greetings_array)
.view { "Before flatten: $it" }
.flatten()
.view { "After flatten: $it" }

// emit a greeting
sayHello(greeting_ch)
}
41 changes: 41 additions & 0 deletions hello-nextflow/solutions/2-hello-channels/hello-channels-4.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env nextflow

/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {

publishDir 'results', mode: 'copy'

input:
val greeting

output:
path "${greeting}-output.txt"

script:
"""
echo '$greeting' > '$greeting-output.txt'
"""
}

/*
* Pipeline parameters
*/
params.greeting = 'greetings.csv'

workflow {

greetings_array = ['Hello','Bonjour','Holà']

// create a channel for inputs from a CSV file
greeting_ch = Channel.fromPath(params.greeting)
.view { "Before splitCsv: $it" }
.splitCsv()
.view { "After splitCsv: $it" }
.map { line -> line[0] }
.view { "After map: $it" }

// emit a greeting
sayHello(greeting_ch)
}

0 comments on commit b20c55c

Please sign in to comment.