diff --git a/docs/snippets/process-out-eval.nf b/docs/snippets/process-out-eval.nf index 58081aafc7..86f326273d 100644 --- a/docs/snippets/process-out-eval.nf +++ b/docs/snippets/process-out-eval.nf @@ -2,6 +2,7 @@ process sayHello { output: eval('bash --version') + script: """ echo Hello world! """ diff --git a/docs/snippets/process-stdout.nf b/docs/snippets/process-stdout.nf index 803957c778..24a55b1126 100644 --- a/docs/snippets/process-stdout.nf +++ b/docs/snippets/process-stdout.nf @@ -2,6 +2,7 @@ process sayHello { output: stdout + script: """ echo Hello world! """ diff --git a/docs/snippets/your-first-script.nf b/docs/snippets/your-first-script.nf index 0217cae8fc..28db2c25bc 100644 --- a/docs/snippets/your-first-script.nf +++ b/docs/snippets/your-first-script.nf @@ -4,6 +4,7 @@ process splitLetters { output: path 'chunk_*' + script: """ printf '${params.str}' | split -b 6 - chunk_ """ @@ -16,6 +17,7 @@ process convertToUpper { output: stdout + script: """ cat $x | tr '[a-z]' '[A-Z]' """ diff --git a/tests/ampa-dsl2.nf b/tests/ampa-dsl2.nf index 2d26e42534..addde20483 100644 --- a/tests/ampa-dsl2.nf +++ b/tests/ampa-dsl2.nf @@ -15,7 +15,7 @@ process ampaTask { output: path 'result' - // The BASH script to be executed - for each - sequence + script: """ AMPA.pl -in=${seq} -noplot -rf=result -df=data """ @@ -23,9 +23,9 @@ process ampaTask { } workflow { - Channel.fromPath(params.in) | - splitFasta(file:true) | - ampaTask | - view { it.text } + Channel.fromPath(params.in) + | splitFasta(file:true) + | ampaTask + | view { file -> file.text } } diff --git a/tests/basic-dsl2.nf b/tests/basic-dsl2.nf index d180844fe3..4b6d72de24 100644 --- a/tests/basic-dsl2.nf +++ b/tests/basic-dsl2.nf @@ -17,6 +17,7 @@ process splitSequences { output: path 'seq_*' + script: """ awk '/^>/{f="seq_"++d} {print > f}' < input.fa """ @@ -34,6 +35,7 @@ process reverse { output: stdout + script: """ cat $x | rev """ diff --git a/tests/blast-dsl2.nf b/tests/blast-dsl2.nf index 7a8d96e25b..2d3aa3606f 100644 --- a/tests/blast-dsl2.nf +++ b/tests/blast-dsl2.nf @@ -4,17 +4,17 @@ params.db = "$baseDir/blast-db/tiny" params.query = "$baseDir/data/sample.fa" params.chunkSize = 1 -DB = file(params.db) - process blast { input: path 'seq.fa' + path db output: path 'out' + script: """ - blastp -db $DB -query seq.fa -outfmt 6 > out + blastp -db $db -query seq.fa -outfmt 6 > out """ } @@ -25,6 +25,7 @@ process sort { output: stdout + script: """ sort hits_* """ @@ -32,10 +33,11 @@ process sort { workflow { - Channel.fromPath(params.query) | - splitFasta( by: params.chunkSize, file:true ) | - blast | - collect | - sort | - subscribe { println it } + ch_fasta = Channel.fromPath(params.query) + | splitFasta( by: params.chunkSize, file:true ) + + blast(ch_fasta, file(params.db)) + | collect + | sort + | subscribe { hits -> println hits } } diff --git a/tests/blast-parallel-dsl2.nf b/tests/blast-parallel-dsl2.nf index a2b3addbd7..73cdebeef2 100644 --- a/tests/blast-parallel-dsl2.nf +++ b/tests/blast-parallel-dsl2.nf @@ -4,18 +4,18 @@ params.db = "$baseDir/blast-db/tiny" params.query = "$baseDir/data/sample.fa" params.chunk = 1 -db = file(params.db) - /* * Extends a BLAST query for each entry in the 'chunks' channel */ process blast { input: path 'query.fa' + path db output: - path top_hits + path 'top_hits' + script: """ blastp -db ${db} -query query.fa -outfmt 6 > blast_result cat blast_result | head -n 10 | cut -f 2 > top_hits @@ -28,11 +28,15 @@ process blast { process extract { input: path top_hits + path db output: path 'sequences' - "blastdbcmd -db ${db} -entry_batch top_hits | head -n 10 > sequences" + script: + """ + blastdbcmd -db ${db} -entry_batch top_hits | head -n 10 > sequences + """ } @@ -45,18 +49,24 @@ process align { input: path all_seq - "t_coffee $all_seq 2>/dev/null | tee align_result" + script: + """ + t_coffee $all_seq 2>/dev/null | tee align_result + """ } /* * main flow */ workflow { - Channel.fromPath(params.query) | - splitFasta(by: params.chunk, file:true) | - blast | - extract | - collectFile(name:'all_seq') | // Collect all hits to a single file called 'all_seq' - align + db = file(params.db) + + ch_fasta = Channel.fromPath(params.query) + | splitFasta(by: params.chunk, file:true) + + ch_sequences = blast(ch_fasta, db) + extract(ch_sequences, db) + | collectFile(name:'all_seq') // Collect all hits to a single file called 'all_seq' + | align } diff --git a/tests/buffer-dsl2.nf b/tests/buffer-dsl2.nf index b74469daff..3aaf9c5c6b 100644 --- a/tests/buffer-dsl2.nf +++ b/tests/buffer-dsl2.nf @@ -6,6 +6,7 @@ process blastThemAll { input: path x + script: """ echo $x """ diff --git a/tests/cache-bak.nf b/tests/cache-bak.nf index 728c9b0779..c801ee629a 100644 --- a/tests/cache-bak.nf +++ b/tests/cache-bak.nf @@ -4,5 +4,7 @@ workflow { process foo { debug true + + script: /echo Hello world/ } \ No newline at end of file diff --git a/tests/chunk-dsl2.nf b/tests/chunk-dsl2.nf index c4d4709cf6..d642a7d832 100644 --- a/tests/chunk-dsl2.nf +++ b/tests/chunk-dsl2.nf @@ -8,11 +8,12 @@ process foo { input: stdin() + script: "cat -" } workflow { - Channel.from(stdin) \ + Channel.of(stdin) \ | splitFasta( by: params.chunkSize) \ | foo } diff --git a/tests/collect-file.nf b/tests/collect-file.nf index ed5dd20600..210104cb86 100644 --- a/tests/collect-file.nf +++ b/tests/collect-file.nf @@ -15,12 +15,11 @@ * limitations under the License. */ -Channel - .from('alpha', 'beta', 'gamma') +Channel.of('alpha', 'beta', 'gamma') .collectFile(name: 'sample.txt', newLine: true) - .subscribe { - println "Entries are saved to file: $it" - println "File content is: ${it.text}" + .subscribe { file -> + println "Entries are saved to file: file" + println "File content is: ${file.text}" } println 123 diff --git a/tests/collect_and_merge.nf b/tests/collect_and_merge.nf index b77a742373..694407777e 100644 --- a/tests/collect_and_merge.nf +++ b/tests/collect_and_merge.nf @@ -19,7 +19,7 @@ /* * fake alignment step producing a BAM and BAI files */ -process algn { +process align { debug true input: @@ -29,10 +29,10 @@ process algn { output: tuple val(barcode), val(seq_id), file('bam'), file('bai') + script: """ echo BAM $seq_id - $barcode > bam echo BAI $seq_id - $barcode > bai - """ } @@ -44,44 +44,48 @@ process merge { debug true input: - tuple val(barcode), val(seq_id), file(bam: 'bam?'), file(bai: 'bai?') + tuple val(barcode), val(seq_id), path(bam), path(bai) + script: """ echo barcode: $barcode echo seq_ids: $seq_id echo bam : $bam echo bai : $bai """ - } workflow { def ch1 = channel.of('alpha', 'gamma') def ch2 = channel.of('one', 'two', 'three') - aggregation = algn(ch1, ch2) + aggregation = align(ch1, ch2) /* * aggregation is made by using a 'reduce' operator * followed by 'flatMap' */ - aggregation = algn.out - .reduce([:]) { map, tuple -> // 'map' is used to collect all values; 'tuple' is the record containing four items: barcode, seqid, bam file and bai file - def barcode = tuple[0] // the first item is the 'barcode' - def group = map[barcode] // get the aggregation for current 'barcode' - if( !group ) group = [ barcode, [], [], [] ] // if new, create a new entry - group[1] << tuple[1] // append 'seq_id' to the aggregation list - group[2] << tuple[2] // append 'bam' file to the aggregation list - group[3] << tuple[3] // append 'bai' file to the aggregation list - map[barcode] = group // set back into the map - return map // return it so that it will be used in the next iteration - } - .flatMap { it.values() } // tricky part: get the list of values of in the map, each value is the - // aggregation build above - // the 'flatMap' emits each of these aggregation list as a single item - - .map { it.collect { it instanceof Collection ? it.sort() : it } } + aggregation = align.out + // 'map' is used to collect all values; 'tuple' is the record containing four items: barcode, seqid, bam file and bai file + .reduce([:]) { map, tuple -> + def barcode = tuple[0] // the first item is the 'barcode' + def group = map[barcode] // get the aggregation for current 'barcode' + if( !group ) group = [ barcode, [], [], [] ] // if new, create a new entry + group[1] << tuple[1] // append 'seq_id' to the aggregation list + group[2] << tuple[2] // append 'bam' file to the aggregation list + group[3] << tuple[3] // append 'bai' file to the aggregation list + map[barcode] = group // set back into the map + return map // return it so that it will be used in the next iteration + } + + // tricky part: get the list of values of in the map, each value is the + // aggregation build above + // the 'flatMap' emits each of these aggregation list as a single item + .flatMap { map -> map.values() } + .map { group -> + group.collect { v -> v instanceof Collection ? v.sort() : v } + } merge(aggregation) } diff --git a/tests/collect_tuple-dsl2.nf b/tests/collect_tuple-dsl2.nf index 7dbe3e69b1..ed5d110af4 100644 --- a/tests/collect_tuple-dsl2.nf +++ b/tests/collect_tuple-dsl2.nf @@ -13,6 +13,7 @@ process algn { output: tuple val(barcode), val(seq_id), path('bam'), path('bai') + script: """ echo BAM $seq_id - $barcode > bam echo BAI $seq_id - $barcode > bai @@ -30,6 +31,7 @@ process merge { input: tuple val(barcode), val(seq_id), path(bam, stageAs:'bam?'), path(bai, stageAs:'bai?') + script: """ echo barcode: $barcode echo seq_ids: $seq_id diff --git a/tests/complex-names-dsl2.nf b/tests/complex-names-dsl2.nf index 90e6cb0fa5..b7c16e7e60 100644 --- a/tests/complex-names-dsl2.nf +++ b/tests/complex-names-dsl2.nf @@ -3,6 +3,7 @@ process foo { publishDir 'foo', mode: 'copy' container 'debian:latest' + output: path '*.fa' path 'hello.txt' @@ -12,32 +13,33 @@ process foo { path '.alpha' script: - $/ + ''' echo A > hello.txt echo B > sample.zip echo C > sample.html - echo D > 01_A\(R1\).fastq - echo E > 01_A\(R2\).fastq - echo F > sample_\(1\ 2\).vcf + echo D > 01_A\\(R1\\).fastq + echo E > 01_A\\(R2\\).fastq + echo F > sample_\\(1\\ 2\\).vcf echo 1 > f1.fa echo 2 > f2.fa echo 3 > f3.fa mkdir .alpha echo "Hello world!" > .alpha/hello.txt - /$ + ''' } process bar { debug true container 'debian:latest' + input: path '*' script: - $/ + ''' cat .alpha/hello.txt [ `cat * | grep -c ''` == 9 ] || false - /$ + ''' } /* diff --git a/tests/config-labels.included b/tests/config-labels-included.config similarity index 100% rename from tests/config-labels.included rename to tests/config-labels-included.config diff --git a/tests/config-labels.config b/tests/config-labels.config index 294fa3900a..51af5f4f80 100644 --- a/tests/config-labels.config +++ b/tests/config-labels.config @@ -32,6 +32,6 @@ profiles { } test3 { - includeConfig 'config-labels.included' + includeConfig 'config-labels-included.config' } } diff --git a/tests/config-labels.nf b/tests/config-labels.nf index c152e9d76c..48ceb28449 100644 --- a/tests/config-labels.nf +++ b/tests/config-labels.nf @@ -23,30 +23,34 @@ workflow { process alpha { debug true - / + + script: + """ echo alpha memry: ${task.memory} echo alpha queue: ${task.queue} - / + """ } process beta { debug true label 'small' - / + script: + """ echo beta memry: ${task.memory} echo beta queue: ${task.queue} - / + """ } process delta { debug true label 'big' - / + script: + """ echo delta memry: ${task.memory} echo delta queue: ${task.queue} - / + """ } process gamma { @@ -55,8 +59,9 @@ process gamma { memory 40.MB queue 'foo' - / + script: + """ echo gamma memry: ${task.memory} echo gamma queue: ${task.queue} - / + """ } diff --git a/tests/copy-no-follow.nf b/tests/copy-no-follow.nf index 53a1578b59..327e2d74ef 100644 --- a/tests/copy-no-follow.nf +++ b/tests/copy-no-follow.nf @@ -21,6 +21,7 @@ process test { output: file '*' + script: """ echo "TEST" > testFile.txt ln -s testFile.txt testFileLink.txt diff --git a/tests/demo-dsl2.nf b/tests/demo-dsl2.nf index 1ff8692013..0ecfe91e10 100644 --- a/tests/demo-dsl2.nf +++ b/tests/demo-dsl2.nf @@ -5,6 +5,7 @@ process sayHello { input: val x + script: """ echo '$x world!' """ diff --git a/tests/dynamic-filename.nf b/tests/dynamic-filename.nf index 7a3b1c1346..aa8229ec53 100644 --- a/tests/dynamic-filename.nf +++ b/tests/dynamic-filename.nf @@ -16,9 +16,8 @@ */ params.prefix = 'my' - -data = 'Hello\n' -list = ['alpha', 'delta', 'gamma', 'omega'] +params.data = 'Hello\n' +params.list = ['alpha', 'delta', 'gamma', 'omega'] process foo { @@ -29,6 +28,7 @@ process foo { output: file "${params.prefix}_${x}.txt" + script: """ echo World >> ${params.prefix}_${x}.txt """ @@ -36,5 +36,5 @@ process foo { } workflow { - foo(list, data) | subscribe { println "~ Saving ${it.name}"; it.copyTo('.') } + foo(params.list, params.data) | subscribe { file -> println "~ Saving ${file.name}"; file.copyTo('.') } } diff --git a/tests/dynamic-storedir.nf b/tests/dynamic-storedir.nf index 4dbef7934d..755bc24049 100644 --- a/tests/dynamic-storedir.nf +++ b/tests/dynamic-storedir.nf @@ -27,6 +27,7 @@ process foo { output: tuple val(x), file('result.txt') + script: """ echo World >> result.txt """ diff --git a/tests/each-file-dsl2.nf b/tests/each-file-dsl2.nf index 0b3f81214c..44ceeb508b 100644 --- a/tests/each-file-dsl2.nf +++ b/tests/each-file-dsl2.nf @@ -22,6 +22,7 @@ process foo { input: each path(x) + script: """ grep '>' $x """ diff --git a/tests/env-out.nf b/tests/env-out.nf index e33b6e297d..c7acdf87fc 100644 --- a/tests/env-out.nf +++ b/tests/env-out.nf @@ -17,14 +17,19 @@ process foo { output: - env FOO + env 'FOO' + + script: /FOO=Hello/ } process bar { debug true + input: - env FOO + env 'FOO' + + script: 'echo "bar says $FOO"' } diff --git a/tests/env2.nf b/tests/env2.nf index 9f4cc8dfb4..c10c4d52e7 100644 --- a/tests/env2.nf +++ b/tests/env2.nf @@ -19,8 +19,9 @@ process printEnv { debug true input: - env HELLO + env 'HELLO' + script: ''' echo $HELLO world! ''' diff --git a/tests/error-finish.nf b/tests/error-finish.nf index 8f70d60605..88d2832fa1 100644 --- a/tests/error-finish.nf +++ b/tests/error-finish.nf @@ -42,12 +42,11 @@ process bar { ''' } - -workflow.onError { - println "success: $workflow.success" - println "exitStatus: $workflow.exitStatus" -} - workflow { foo([1,2,3]) | bar + + workflow.onError { + println "success: $workflow.success" + println "exitStatus: $workflow.exitStatus" + } } diff --git a/tests/escape-globs-dsl2.nf b/tests/escape-globs-dsl2.nf index 9cb319de03..1d4f8d4e82 100644 --- a/tests/escape-globs-dsl2.nf +++ b/tests/escape-globs-dsl2.nf @@ -10,6 +10,7 @@ process foo { path 'file-\\*.txt' path 'file-?.txt', glob: false + script: ''' touch file-\\*.txt touch file-\\?.txt @@ -20,8 +21,8 @@ process foo { workflow { Channel.fromPath("$baseDir/data/file\\[a-b\\].txt") | foo - foo.out[0].view { "match: ${it.name}" } - foo.out[1].view { "match: ${it.name}" } - foo.out[2].view { "match: ${it.name}" } + foo.out[0].view { file -> "match: ${file.name}" } + foo.out[1].view { file -> "match: ${file.name}" } + foo.out[2].view { file -> "match: ${file.name}" } } diff --git a/tests/eval-out.nf b/tests/eval-out.nf index 9a9ad80e68..b1046dd181 100644 --- a/tests/eval-out.nf +++ b/tests/eval-out.nf @@ -20,6 +20,7 @@ process foo { val shell output: eval "$shell --version | cat -", emit: shell_version + script: ''' echo Hello ''' @@ -28,5 +29,5 @@ process foo { workflow { foo('bash') - foo.out.shell_version.view{ it.readLines()[0] } + foo.out.shell_version.view { file -> file.readLines()[0] } } diff --git a/tests/file-with-blanks.nf b/tests/file-with-blanks.nf index 2a6414c676..7fa490962e 100644 --- a/tests/file-with-blanks.nf +++ b/tests/file-with-blanks.nf @@ -16,7 +16,7 @@ */ workflow { - foo | view{ it.text } + foo | view { file -> file.text } } process foo { @@ -24,6 +24,7 @@ process foo { debug true output: path "*/*.txt" + script: """ mkdir "a b" echo "Hello world" > "a b/hello.txt" diff --git a/tests/file-with-quote.nf b/tests/file-with-quote.nf index 629dd7fd4c..265e30b650 100644 --- a/tests/file-with-quote.nf +++ b/tests/file-with-quote.nf @@ -20,11 +20,12 @@ process foo { path 'a b.txt' output: path 'x z.txt' + script: ''' cat 'a b.txt' > 'x z.txt' ''' } workflow { - foo("$baseDir/data/data'3.txt") | view { it.text } + foo("$baseDir/data/data'3.txt") | view { file -> file.text } } diff --git a/tests/files.nf b/tests/files.nf index bda693dcd5..10c6e655eb 100644 --- a/tests/files.nf +++ b/tests/files.nf @@ -16,7 +16,6 @@ */ params.in = "$baseDir/data/sample.fa" -SPLIT = (System.properties['os.name'] == 'Mac OS X' ? 'gcsplit' : 'csplit') process split { input: @@ -25,6 +24,8 @@ process split { output: path 'seq_*' + script: + SPLIT = (System.properties['os.name'] == 'Mac OS X' ? 'gcsplit' : 'csplit') """ $SPLIT query.fa '%^>%' '/^>/' '{*}' -f seq_ """ @@ -38,11 +39,12 @@ process printTwo { path 'chunk' output: - file 'chunk1:chunk3' + tuple path('chunk1'), path('chunk3') - """ + script: + ''' cat chunk* | rev - """ + ''' } @@ -50,14 +52,15 @@ process printLast { debug true input: - file 'chunk' + path 'chunk' output: - file 'chunk' + path 'chunk' - """ + script: + ''' cat chunk - """ + ''' } workflow { diff --git a/tests/glob.nf b/tests/glob.nf index 36912f024d..7f90ecf2fe 100644 --- a/tests/glob.nf +++ b/tests/glob.nf @@ -21,6 +21,7 @@ process recurseDir { file 'folder/**.fa' file 'folder/**/*.txt' + script: """ mkdir -p folder/x mkdir -p folder/y @@ -34,6 +35,6 @@ process recurseDir { workflow { recurseDir() - recurseDir.out[0] | flatten | view { "result1: " + it.name } - recurseDir.out[1] | flatten | view { "result2: " + it.name } + recurseDir.out[0] | flatten | view { file -> "result1: ${file.name}" } + recurseDir.out[1] | flatten | view { file -> "result2: ${file.name}" } } diff --git a/tests/hello.nf b/tests/hello.nf index 03a882c530..99fe3d79f7 100644 --- a/tests/hello.nf +++ b/tests/hello.nf @@ -17,8 +17,9 @@ process sayhello { debug true + script: """ - echo 'Hello world!' + echo 'Hello world!' """ } diff --git a/tests/input.nf b/tests/input.nf index 5b0d3eb5a5..05f2600a2b 100644 --- a/tests/input.nf +++ b/tests/input.nf @@ -26,9 +26,10 @@ process foo { output: val y + script: "echo $x - $y" } workflow { - foo(1, channel.of('a','b')) | view { "foo out: $it" } + foo(1, channel.of('a','b')) | view { file -> "foo out: $file" } } diff --git a/tests/mixing-langs.nf b/tests/mixing-langs.nf index 25eeeb105e..9c18c01293 100644 --- a/tests/mixing-langs.nf +++ b/tests/mixing-langs.nf @@ -47,6 +47,7 @@ process pyTask { input: stdin + script: ''' #!/usr/bin/env python3 import sys diff --git a/tests/modules.nf b/tests/modules.nf index 8a8dd9b745..40afb335df 100644 --- a/tests/modules.nf +++ b/tests/modules.nf @@ -20,6 +20,7 @@ process dotModule { module 'y' beforeScript 'module purge' + script: ''' echo $PATH ''' diff --git a/tests/opt-file.nf b/tests/opt-file.nf index cfe3336530..6c5f25844b 100644 --- a/tests/opt-file.nf +++ b/tests/opt-file.nf @@ -19,6 +19,7 @@ process foo { output: path 'missing.txt', optional: true + script: ''' echo miao ''' @@ -28,6 +29,7 @@ process bar { input: file x + script: ''' echo bau ''' diff --git a/tests/output-file.nf b/tests/output-file.nf index 41c9df1c82..54543f75c3 100644 --- a/tests/output-file.nf +++ b/tests/output-file.nf @@ -16,16 +16,17 @@ */ process foo { - input: - file x + input: + file x - output: - file x + output: + file x - 'echo foo' + script: + 'echo foo' } workflow { - foo('dummy') | view { it.text } + foo('dummy') | view { file -> file.text } } diff --git a/tests/output-globs.nf b/tests/output-globs.nf index 836d3323a8..2e48c17379 100644 --- a/tests/output-globs.nf +++ b/tests/output-globs.nf @@ -1,19 +1,21 @@ -def CMD = """ - mkdir -p a/a b/b c/c - touch a/1.txt - touch b/1.txt - touch c/1.txt - touch a/a/2.txt - touch b/b/2.txt - touch c/c/2.txt - """ +def getCmd() { + """ + mkdir -p a/a b/b c/c + touch a/1.txt + touch b/1.txt + touch c/1.txt + touch a/a/2.txt + touch b/b/2.txt + touch c/c/2.txt + """ +} process foo { output: file("a/*/*.txt") script: - CMD + getCmd() } process bar { @@ -21,12 +23,12 @@ process bar { output: file("a/*/*.txt") script: - CMD + getCmd() } workflow { foo() - foo.out.view { "foo: $it" } + foo.out.view { file -> "foo: $file" } bar() - bar.out.view { "bar: $it" } + bar.out.view { file -> "bar: $file" } } diff --git a/tests/output-links.nf b/tests/output-links.nf index 8209973260..d2b79dbcc7 100644 --- a/tests/output-links.nf +++ b/tests/output-links.nf @@ -19,6 +19,7 @@ process foo { output: file 'link.txt' + script: ''' echo Hello > file.txt ln -s file.txt link.txt diff --git a/tests/output-val-dsl2.nf b/tests/output-val-dsl2.nf index e769f9e4d1..3b7a10e0d2 100644 --- a/tests/output-val-dsl2.nf +++ b/tests/output-val-dsl2.nf @@ -1,8 +1,5 @@ #!/usr/bin/env nextflow -x = 100 -y = 200 - process foo { input: path fastq @@ -14,6 +11,7 @@ process foo { val y script: + x = 100 y = 'two hundred' """ echo bar @@ -23,8 +21,8 @@ process foo { workflow { foo("$baseDir/data/prot.fa") - foo.out[0].view { "str: $it" } - foo.out[1].view { "exp: $it" } - foo.out[2].view { "x: $it" } - foo.out[3].view { "y: $it" } + foo.out[0].view { str -> "str: $str" } + foo.out[1].view { exp -> "exp: $exp" } + foo.out[2].view { x -> "x: $x" } + foo.out[3].view { y -> "y: $y" } } diff --git a/tests/profiles.config b/tests/profiles.config index b74a3f87ef..95f0ac4ee9 100644 --- a/tests/profiles.config +++ b/tests/profiles.config @@ -16,8 +16,7 @@ echo = true -def x = 'delta' -includeConfig "${x}.config" +includeConfig "${'delta'}.config" profiles { diff --git a/tests/profiles.nf b/tests/profiles.nf index 424636e600..1ca85aaf49 100644 --- a/tests/profiles.nf +++ b/tests/profiles.nf @@ -17,6 +17,7 @@ process foo { debug true + script: """ echo cpus: ${task.cpus} memory: ${task.memory} """ diff --git a/tests/property-out-vals.nf b/tests/property-out-vals.nf index 99c07b7ac7..64790b3819 100644 --- a/tests/property-out-vals.nf +++ b/tests/property-out-vals.nf @@ -29,6 +29,6 @@ process foo { workflow { foo() - foo.out[0].view { "exit_status=$it" } - foo.out[1].view { "record=${it[0]}_${it[1]}" } + foo.out[0].view { exit_status -> "exit_status=$exit_status" } + foo.out[1].view { v1, v2 -> "record=${v1}_${v2}" } } diff --git a/tests/publish-dir.nf b/tests/publish-dir.nf index 6d1031ab83..504377e999 100644 --- a/tests/publish-dir.nf +++ b/tests/publish-dir.nf @@ -26,6 +26,7 @@ process align { path("*.bam") path("${x}.bai") + script: """ echo ${x} > ${x}.bam echo ${x} | rev > ${x}.bai @@ -43,6 +44,7 @@ process my_combine { output: path 'result.txt' + script: """ cat $bamfile > result.txt cat $baifile >> result.txt @@ -54,6 +56,7 @@ process foo { output: file 'xxx' + script: ''' mkdir xxx touch xxx/A @@ -66,10 +69,10 @@ workflow { def input = Channel.of('alpha','beta','delta') align(input) - def bam = align.out[0].toSortedList { it.name } - def bai = align.out[1].toSortedList { it.name } + def bam = align.out[0].toSortedList { file -> file.name } + def bai = align.out[1].toSortedList { file -> file.name } my_combine( bam, bai ) - my_combine.out.view{ it.text } + my_combine.out.view { file -> file.text } foo() } diff --git a/tests/publish-saveas.nf b/tests/publish-saveas.nf index 7b760db1cb..87f330e5ad 100644 --- a/tests/publish-saveas.nf +++ b/tests/publish-saveas.nf @@ -23,15 +23,17 @@ def rule( file ) { return null if( file == 'file_3.txt' ) - return "$PWD/results/gamma/$file" + return "${env('PWD')}/results/gamma/$file" } process foo { - publishDir path: 'results', saveAs: this.&rule + publishDir path: 'results', saveAs: { file -> rule(file) } input: each x output: path '*.txt' + + script: """ touch file_${x}.txt """ diff --git a/tests/race.nf b/tests/race.nf index 090a90c842..5e705b3d83 100644 --- a/tests/race.nf +++ b/tests/race.nf @@ -15,9 +15,9 @@ * limitations under the License. */ -seqs = channel.fromList(file("$baseDir/data/seqs/*.fastq")) - workflow { + seqs = Channel.fromList(files("$baseDir/data/seqs/*.fastq")) + seqs | proc1 seqs | proc2 seqs | proc3 diff --git a/tests/repeaters.nf b/tests/repeaters.nf index 207adba29d..00e85b48b5 100644 --- a/tests/repeaters.nf +++ b/tests/repeaters.nf @@ -17,27 +17,29 @@ process hola { - debug true - input: - val x - each y - each z + debug true - """ - echo 'x: $x; y: $y; z: $z' - """ + input: + val x + each y + each z + script: + """ + echo 'x: $x; y: $y; z: $z' + """ } process foo { - debug true + debug true - input: - each v + input: + each v - """ - echo foo $v - """ + script: + """ + echo foo $v + """ } workflow { diff --git a/tests/retry-ignore.nf b/tests/retry-ignore.nf index c525968d20..a90e796db1 100644 --- a/tests/retry-ignore.nf +++ b/tests/retry-ignore.nf @@ -18,6 +18,7 @@ process foo { errorStrategy { task.exitStatus==1 && task.attempt==1 ? 'retry' : 'ignore' } + script: 'exit 1' } diff --git a/tests/rnaseq-toy-dsl2.nf b/tests/rnaseq-toy-dsl2.nf index 94e76aae20..9c8bc81139 100644 --- a/tests/rnaseq-toy-dsl2.nf +++ b/tests/rnaseq-toy-dsl2.nf @@ -18,6 +18,7 @@ process buildIndex { output: path 'genome.index*' + script: """ bowtie2-build ${genome} genome.index """ @@ -35,6 +36,7 @@ process mapping { output: tuple val(pair_id), path("tophat_out/accepted_hits.bam") + script: """ tophat2 genome.index ${reads} """ @@ -53,20 +55,18 @@ process makeTranscript { output: tuple val(pair_id), path('transcripts.gtf') + script: """ cufflinks ${bam_file} """ } -/* - * main flow - */ -read_pairs = Channel.fromFilePairs( params.reads, checkIfExists: true ) - /* * main flow */ workflow { + read_pairs = Channel.fromFilePairs( params.reads, checkIfExists: true ) + buildIndex(params.genome) mapping(params.genome, buildIndex.out, read_pairs) makeTranscript(mapping.out) diff --git a/tests/s3-files.nf b/tests/s3-files.nf index 69cb5031fb..f3a931207b 100644 --- a/tests/s3-files.nf +++ b/tests/s3-files.nf @@ -21,6 +21,7 @@ process foo { input: path(obj) + script: """ cat $obj | head """ @@ -31,6 +32,7 @@ process bar { input: tuple val(pair), path(obj) + script: """ cat $obj | head """ diff --git a/tests/sets.nf b/tests/sets.nf index 75bdeed69d..9fba9c3351 100644 --- a/tests/sets.nf +++ b/tests/sets.nf @@ -17,32 +17,33 @@ process touch { input: - tuple val(id), val(fileName) + tuple val(id), val(fileName) output: - tuple val(id), path('file*') + tuple val(id), path('file*') - / + script: + """ echo Creating $id touch $fileName - / + """ } process makeFiles { input: - tuple val(id), path('file_x') - + tuple val(id), path('file_x') output: - tuple val(id), path('*') + tuple val(id), path('*') - / - cp file_x copy_$id - touch beta_$id - / + script: + """ + cp file_x copy_$id + touch beta_$id + """ } workflow { - def x = Channel.from( ['a', 'file1'], ['b','file2'] ) + def x = Channel.of( ['a', 'file1'], ['b','file2'] ) touch(x) makeFiles(touch.out) makeFiles.out.view() diff --git a/tests/singleton.nf b/tests/singleton.nf index 70f4bde70a..b80203b225 100644 --- a/tests/singleton.nf +++ b/tests/singleton.nf @@ -17,8 +17,9 @@ process foo { output: - file x + file 'x' + script: ''' echo -n Hello > x ''' @@ -29,6 +30,7 @@ process bar { file x val y + script: """ cat $x echo $y diff --git a/tests/splitLetters.nf b/tests/splitLetters.nf index dc700d1173..12f119188d 100644 --- a/tests/splitLetters.nf +++ b/tests/splitLetters.nf @@ -18,12 +18,15 @@ params.str = 'Hello world!' process splitLetters { + input: + val str output: file 'chunk_*' + script: """ - printf '${params.str}' | split -b 6 - chunk_ + printf '${str}' | split -b 6 - chunk_ """ } @@ -35,15 +38,16 @@ process massage { output: stdout + script: """ cat $x | tr '[a-z]' '[A-Z]' """ } workflow { - splitLetters \ - | flatten \ - | massage \ - | view { it.trim() } + splitLetters(params.str) + | flatten + | massage + | view { v -> v.trim() } } diff --git a/tests/storeCache.nf b/tests/storeCache.nf index bd53e81e94..071cb6bec5 100644 --- a/tests/storeCache.nf +++ b/tests/storeCache.nf @@ -24,6 +24,7 @@ process storeCache { output: file "${cheers}.txt" + script: "printf $cheers > ${cheers}.txt" } diff --git a/tests/stress.nf b/tests/stress.nf index b11f4386d1..5bf7ce7af2 100644 --- a/tests/stress.nf +++ b/tests/stress.nf @@ -8,6 +8,7 @@ process stress_1cpu { process stress_2cpu { cpus 2 + script: """ stress -c 2 -t 10 """ @@ -15,6 +16,7 @@ process stress_2cpu { process stress_100mega { memory 150.MB + script: """ stress -m 1 --vm-bytes 100000000 -t 10 """ @@ -22,6 +24,7 @@ process stress_100mega { process stress_200mega { memory 250.MB + script: // note: mem usage should not be aggregated """ stress -m 1 --vm-bytes 200000000 -t 5 @@ -32,6 +35,7 @@ process stress_200mega { process stress_300mega { memory 350.MB cpus 2 + script: // note: two parallel workers of 150MB => 300 MB """ stress -m 2 --vm-bytes 150000000 -t 5 @@ -46,6 +50,7 @@ process io_write_100mega { process io_write_200mega { cpus 2 + script: """ write.pl file1.txt 104857600 & pid=\$! diff --git a/tests/subdirs.nf b/tests/subdirs.nf index 1f4947fa96..0fbab03e2c 100644 --- a/tests/subdirs.nf +++ b/tests/subdirs.nf @@ -24,6 +24,7 @@ process foo { output: file 'dir2/*' + script: ''' ls dir1 | sort mkdir dir2 @@ -33,9 +34,9 @@ process foo { } workflow { - Channel.fromPath("$baseDir/data/p{1,2,3}.fa") \ - | toList \ - | foo \ - | flatten \ - | view { it.name } + Channel.fromPath("$baseDir/data/p{1,2,3}.fa") + | toList + | foo + | flatten + | view { file -> file.name } } diff --git a/tests/subworkflow-dsl2.nf b/tests/subworkflow-dsl2.nf index 27d70ccc09..5aa3f48739 100644 --- a/tests/subworkflow-dsl2.nf +++ b/tests/subworkflow-dsl2.nf @@ -33,15 +33,16 @@ workflow flow2 { } workflow test1 { + main: flow1() flow2() ch1 = flow1.out.result ch2 = flow2.out.result - emit: ch1.mix(ch2).collectFile(name:"$PWD/test1.txt") + emit: ch1.mix(ch2).collectFile(name:"test1.txt") } workflow test2 { - emit: ( flow1 & flow2 ) | mix | collectFile(name:"$PWD/test2.txt") + emit: ( flow1 & flow2 ) | mix | collectFile(name:"test2.txt") } workflow { diff --git a/tests/subworkflow-take-dsl2.nf b/tests/subworkflow-take-dsl2.nf index 2e2956dc70..bb79690659 100644 --- a/tests/subworkflow-take-dsl2.nf +++ b/tests/subworkflow-take-dsl2.nf @@ -1,13 +1,15 @@ process foo { - input: val x + input: val x output: val x + script: /echo true/ } -process bar { - input: val x +process bar { + input: val x output: val x + script: /echo true/ } diff --git a/tests/tagging-lazy.nf b/tests/tagging-lazy.nf index 7915a72466..ded79f7166 100644 --- a/tests/tagging-lazy.nf +++ b/tests/tagging-lazy.nf @@ -24,6 +24,7 @@ process foo { input: each barcode + script: """ echo $barcode """ diff --git a/tests/tagging.nf b/tests/tagging.nf index 3f67f2c6b7..a63c715aaf 100644 --- a/tests/tagging.nf +++ b/tests/tagging.nf @@ -22,6 +22,7 @@ process foo { input: each barcode + script: """ echo $barcode """ diff --git a/tests/task-escape-path-dsl2.nf b/tests/task-escape-path-dsl2.nf index 29c89a7495..bf08cf6cbc 100644 --- a/tests/task-escape-path-dsl2.nf +++ b/tests/task-escape-path-dsl2.nf @@ -1,8 +1,10 @@ process foo1 { debug true - input: path x - input: path y + input: + path x + path y + script: """ echo "FOO1: ${x}; ${y}" """ @@ -10,8 +12,9 @@ process foo1 { process foo2 { debug true - input: path x - input: path y + input: + path x + path y script: """ echo "FOO2: ${x}; ${y}" @@ -20,20 +23,22 @@ process foo2 { process foo3 { debug true - input: path x - input: path y + input: + path x + path y shell: ''' - echo "FOO3: !{x}; !{y}" + echo "FOO3: !{x}; !{y}" ''' } process foo4 { debug true - input: path x - input: path y + input: + path x + path y script: - template("$baseDir/task-escape-path-dsl2.sh") + template("task-escape-path-dsl2.sh") } workflow { diff --git a/tests/task-retry.nf b/tests/task-retry.nf index 174db33737..05dbfdc32e 100644 --- a/tests/task-retry.nf +++ b/tests/task-retry.nf @@ -29,13 +29,13 @@ process foo { script: """ - if [[ -f $PWD/marker ]]; then + if [[ -f ${launchDir}/marker ]]; then echo DONE - mem: $task.memory - time: $task.time exit 0 else echo FAIL - touch $PWD/marker - exit 5; + touch ${launchDir}/marker + exit 5 fi """ diff --git a/tests/task-vars.nf b/tests/task-vars.nf index 3c93b8be8a..f00445772f 100644 --- a/tests/task-vars.nf +++ b/tests/task-vars.nf @@ -29,6 +29,7 @@ process printVars { input: each x + script: """ echo indx: ${task.index} echo proc: ${task.process} diff --git a/tests/template-dyn.nf b/tests/template-dyn.nf index fb738ab010..a3c0b053b0 100644 --- a/tests/template-dyn.nf +++ b/tests/template-dyn.nf @@ -15,9 +15,9 @@ * limitations under the License. */ -list = 'alpha,delta,gamma'.tokenize(',') - workflow { + list = 'alpha,delta,gamma'.tokenize(',') + foo(list) bar(list) } diff --git a/tests/template-shell.nf b/tests/template-shell.nf index adf3d72cca..6e9154cb2e 100644 --- a/tests/template-shell.nf +++ b/tests/template-shell.nf @@ -18,7 +18,9 @@ params.data = 'zzz' workflow { - channel.of('PF00389', 'PF03061', 'PF02826') | foo | view { it.text } + channel.of('PF00389', 'PF03061', 'PF02826') + | foo + | view { file -> file.text } } process foo { diff --git a/tests/template-simple.nf b/tests/template-simple.nf index b685d5e896..42d1382a77 100644 --- a/tests/template-simple.nf +++ b/tests/template-simple.nf @@ -16,7 +16,9 @@ */ workflow { - channel.of( 'PF00389', 'PF03061', 'PF02826') | foo | view { it.text } + channel.of( 'PF00389', 'PF03061', 'PF02826') + | foo + | view { file -> file.text } } process foo { diff --git a/tests/tuples-dsl2.nf b/tests/tuples-dsl2.nf index ceeb5e1d24..07b5916d81 100644 --- a/tests/tuples-dsl2.nf +++ b/tests/tuples-dsl2.nf @@ -7,11 +7,11 @@ process touch { output: tuple val(id), path('file*') - - / + script: + """ echo Creating $id touch $fileName - / + """ } process makeFiles { @@ -21,18 +21,17 @@ process makeFiles { output: tuple val(id), path('*') - / - cp file_x copy_$id - touch beta_$id - / + script: + """ + cp file_x copy_$id + touch beta_$id + """ } workflow { - - Channel - .from( ['a', 'file1'], ['b','file2'] ) \ - | touch \ - | makeFiles \ - | flatten \ - | subscribe { println it } + Channel.of( ['a', 'file1'], ['b','file2'] ) + | touch + | makeFiles + | flatten + | subscribe { v -> println v } } diff --git a/tests/watch-dsl2.nf b/tests/watch-dsl2.nf index 4718f9c85d..1f07bad89b 100644 --- a/tests/watch-dsl2.nf +++ b/tests/watch-dsl2.nf @@ -9,8 +9,9 @@ process align { path fasta output: - path aln + path 'aln' + script: """ t_coffee -in $fasta 1> aln """ @@ -22,12 +23,10 @@ process align { workflow { - Channel - .watchPath(params.files, params.events) \ - | align \ - | subscribe { - println '------' - println it.text - } - + Channel.watchPath(params.files, params.events) + | align + | subscribe { file -> + println '------' + println file.text + } } diff --git a/tests/when-block.nf b/tests/when-block.nf index 3b6e685b7f..edda552ec2 100644 --- a/tests/when-block.nf +++ b/tests/when-block.nf @@ -15,17 +15,20 @@ * limitations under the License. */ -items = [0,1,2,3,4] -decode = ['zero','one','two','three','fourth'] +def decode(i) { + ['zero','one','two','three','fourth'][i] +} workflow { + items = [0,1,2,3,4] + channel.fromList(items) | foo channel.fromList(items) | bar } process foo { debug true - tag "${decode[x]}" + tag "${decode(x)}" input: val x @@ -41,7 +44,7 @@ process foo { process bar { debug true - tag "${decode[x]}" + tag "${decode(x)}" input: val x diff --git a/tests/workdir-with-blank.nf b/tests/workdir-with-blank.nf index bfb6b99121..16d38cefb3 100644 --- a/tests/workdir-with-blank.nf +++ b/tests/workdir-with-blank.nf @@ -20,8 +20,9 @@ process foo { each x output: - file result_data + file 'result_data' + script: """ echo Hello $x > result_data """ diff --git a/tests/workflow-oncomplete.nf b/tests/workflow-oncomplete.nf index 74ba469ca7..25ddff83c1 100644 --- a/tests/workflow-oncomplete.nf +++ b/tests/workflow-oncomplete.nf @@ -26,9 +26,11 @@ params.command = 'echo' process sayHello { debug true + input: val x + script: """ ${params.command} '$x world!' """ diff --git a/validation/test-complexpaths.nf b/validation/test-complexpaths.nf index 2050313196..f3b66b2abd 100644 --- a/validation/test-complexpaths.nf +++ b/validation/test-complexpaths.nf @@ -1,5 +1,5 @@ workflow { - foo | mix | collect | bar + foo | mix | collect | bar } process foo { @@ -14,7 +14,7 @@ process foo { file '.alpha' script: - $/ + """ echo A > hello.txt echo B > sample.zip echo C > sample.html @@ -26,7 +26,7 @@ process foo { echo 3 > f3.fa mkdir .alpha echo "Hello world!" > .alpha/hello.txt - /$ + """ } process bar { @@ -36,8 +36,8 @@ process bar { file '*' script: - $/ + """ cat .alpha/hello.txt [ `cat * | grep -c ''` == 9 ] || false - /$ + """ } diff --git a/validation/test-overwrite.nf b/validation/test-overwrite.nf index db4ab02b00..60e6aa2ed2 100644 --- a/validation/test-overwrite.nf +++ b/validation/test-overwrite.nf @@ -3,11 +3,13 @@ workflow { } process foo { - container = 'quay.io/nextflow/bash' + container 'quay.io/nextflow/bash' publishDir "gs://rnaseq-nf/scratch/tests", overwrite: true + output: path 'hello.txt' + script: """ touch hello.txt """ diff --git a/validation/test-readspair.nf b/validation/test-readspair.nf index 4e12c7fda2..80cfb7b562 100644 --- a/validation/test-readspair.nf +++ b/validation/test-readspair.nf @@ -1,19 +1,20 @@ workflow { - reads_pair() - reads_pair - .out.view() - .collect() - .subscribe { assert it.name == ['test.R1.fastq','test.R2.fastq'] } + reads_pair() + reads_pair.out + .view() + .subscribe { files -> + assert files*.name == ['test.R1.fastq','test.R2.fastq'] + } } process reads_pair { - output: - file("reads/*") + output: + file("reads/*") - script: - """ - mkdir reads - touch reads/test.R1.fastq reads/test.R2.fastq - """ + script: + """ + mkdir reads + touch reads/test.R1.fastq reads/test.R2.fastq + """ } diff --git a/validation/test-subdirs.nf b/validation/test-subdirs.nf index 19762c11eb..327a1b6be7 100644 --- a/validation/test-subdirs.nf +++ b/validation/test-subdirs.nf @@ -13,6 +13,7 @@ process foo { path 'test7.txt' path 'gsfolder5/sub' + script: """ mkdir -p gsfolder/sub touch gsfolder/test1.txt @@ -47,6 +48,7 @@ process bar { path 'test7/foo/*' path 'test8/*' + script: """ set -x [[ -f $test_folder/test1.txt ]] || false diff --git a/validation/wave-tests/example1/demo.nf b/validation/wave-tests/example1/demo.nf index 4048c03dfe..adc34890a0 100644 --- a/validation/wave-tests/example1/demo.nf +++ b/validation/wave-tests/example1/demo.nf @@ -2,6 +2,7 @@ process foo { container 'docker.io/pditommaso/my-secret-container:latest' debug true + script: """ my-secret-script.sh """ diff --git a/validation/wave-tests/example2/modules/foo/main.nf b/validation/wave-tests/example2/modules/foo/main.nf index 5d8bf2e468..30e4faed59 100644 --- a/validation/wave-tests/example2/modules/foo/main.nf +++ b/validation/wave-tests/example2/modules/foo/main.nf @@ -1,5 +1,7 @@ process hello { debug true + + script: """ cowsay Hello Summit! """ diff --git a/validation/wave-tests/example3/demo.nf b/validation/wave-tests/example3/demo.nf index 5f1e9be8ab..079bca4973 100644 --- a/validation/wave-tests/example3/demo.nf +++ b/validation/wave-tests/example3/demo.nf @@ -2,6 +2,7 @@ process cow { debug true conda 'cowpy=1.1.5' + script: ''' echo cowpy 'Hello Spack' ''' diff --git a/validation/wave-tests/example4/demo.nf b/validation/wave-tests/example4/demo.nf index 3384b942cc..de91175a87 100644 --- a/validation/wave-tests/example4/demo.nf +++ b/validation/wave-tests/example4/demo.nf @@ -2,6 +2,7 @@ process cow { debug true conda 'https://prefix.dev/envs/pditommaso/wave/conda-lock.yml' + script: ''' echo cowpy 'Hello Spack' '''