add nextflow d30e48d

This commit is contained in:
2026-04-29 23:01:54 +02:00
parent d0b12d668d
commit 97cc9058d3
2840 changed files with 730250 additions and 0 deletions

2
nextflow/docs/snippets/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.nextflow*
work

View File

@@ -0,0 +1,12 @@
def criteria = branchCriteria { v ->
small: v < 10
large: v > 10
}
channel.of(1, 2, 30).branch(criteria).set { ch1 }
channel.of(10, 20, 3).branch(criteria).set { ch2 }
ch1.small.view { v -> "$v is small" }
ch1.large.view { v -> "$v is large" }
ch2.small.view { v -> "$v is small" }
ch2.large.view { v -> "$v is large" }

View File

@@ -0,0 +1,5 @@
1 is small
2 is small
3 is small
20 is large
30 is large

View File

@@ -0,0 +1,11 @@
channel.of(1, 2, 3, 40, 50)
.branch { v ->
small: v < 10
large: v < 50
other: true
}
.set { result }
result.small.view { v -> "$v is small" }
result.large.view { v -> "$v is large" }
result.other.view { v -> "$v is other" }

View File

@@ -0,0 +1,5 @@
1 is small
2 is small
3 is small
40 is large
50 is other

View File

@@ -0,0 +1,16 @@
channel.of(1, 2, 3, 40, 50)
.branch { v ->
alpha: v < 10
return v + 2
beta: v < 50
return v - 2
other: true
return 0
}
.set { result }
result.alpha.view { v -> "$v is alpha" }
result.beta.view { v -> "$v is beta" }
result.other.view { v -> "$v is other" }

View File

@@ -0,0 +1,5 @@
3 is alpha
4 is alpha
5 is alpha
38 is beta
0 is other

View File

@@ -0,0 +1,9 @@
channel.of(1, 2, 3, 40, 50)
.branch { v ->
small: v < 10
large: v > 10
}
.set { result }
result.small.view { v -> "$v is small" }
result.large.view { v -> "$v is large" }

View File

@@ -0,0 +1,5 @@
1 is small
2 is small
3 is small
40 is large
50 is large

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 1, 2, 3 )
.buffer { v -> v == 2 }
.view()

View File

@@ -0,0 +1,2 @@
[1, 2]
[3, 1, 2]

View File

@@ -0,0 +1,4 @@
// emits bundles starting with `2` and ending with `4`
channel.of( 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2 )
.buffer( 2, 4 )
.view()

View File

@@ -0,0 +1,2 @@
[2, 3, 4]
[2, 3, 4]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 1, 2, 3, 1 )
.buffer( size: 2, remainder: true )
.view()

View File

@@ -0,0 +1,4 @@
[1, 2]
[3, 1]
[2, 3]
[1]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2 )
.buffer( size: 3, skip: 2 )
.view()

View File

@@ -0,0 +1,2 @@
[3, 4, 5]
[3, 4, 5]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 1, 2, 3, 1 )
.buffer( size: 2 )
.view()

View File

@@ -0,0 +1,3 @@
[1, 2]
[3, 1]
[2, 3]

View File

@@ -0,0 +1,3 @@
channel.of(1, 2, 3, 1, 2, 3, 1)
.collate( 3, false )
.view()

View File

@@ -0,0 +1,2 @@
[1, 2, 3]
[1, 2, 3]

View File

@@ -0,0 +1,3 @@
channel.of(1, 2, 3, 4)
.collate( 3, 1 )
.view()

View File

@@ -0,0 +1,4 @@
[1, 2, 3]
[2, 3, 4]
[3, 4]
[4]

View File

@@ -0,0 +1,3 @@
channel.of(1, 2, 3, 1, 2, 3, 1)
.collate( 3 )
.view()

View File

@@ -0,0 +1,3 @@
[1, 2, 3]
[1, 2, 3]
[1]

View File

@@ -0,0 +1,3 @@
channel.of( 'hello', 'ciao', 'bonjour' )
.collect { v -> v.length() }
.view()

View File

@@ -0,0 +1 @@
[5, 4, 7]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 4 )
.collect()
.view()

View File

@@ -0,0 +1 @@
[1, 2, 3, 4]

View File

@@ -0,0 +1,8 @@
channel.of('Hola', 'Ciao', 'Hello', 'Bonjour', 'Halo')
.collectFile { item ->
[ "${item[0]}.txt", item + '\n' ]
}
.subscribe { file ->
println "File '${file.name}' contains:"
println file.text
}

View File

@@ -0,0 +1,11 @@
File 'B.txt' contains:
Bonjour
File 'C.txt' contains:
Ciao
File 'H.txt' contains:
Halo
Hola
Hello

View File

@@ -0,0 +1,6 @@
channel.of('alpha', 'beta', 'gamma')
.collectFile(name: 'sample.txt', newLine: true)
.subscribe { file ->
println "Entries are saved to file: $file"
println "File content is: ${file.text}"
}

View File

@@ -0,0 +1,4 @@
source = channel.of( [1, 'alpha'], [2, 'beta'] )
target = channel.of( [1, 'x'], [1, 'y'], [1, 'z'], [2, 'p'], [2, 'q'], [2, 't'] )
source.combine(target, by: 0).view()

View File

@@ -0,0 +1,6 @@
[1, alpha, x]
[1, alpha, y]
[1, alpha, z]
[2, beta, p]
[2, beta, q]
[2, beta, t]

View File

@@ -0,0 +1,6 @@
numbers = channel.of(1, 2, 3)
words = channel.of('hello', 'ciao')
numbers
.combine(words)
.view()

View File

@@ -0,0 +1,6 @@
[1, hello]
[2, hello]
[3, hello]
[1, ciao]
[2, ciao]
[3, ciao]

View File

@@ -0,0 +1,5 @@
a = channel.of( 'a', 'b', 'c' )
b = channel.of( 1, 2, 3 )
c = channel.of( 'p', 'q' )
c.concat( b, a ).view()

View File

@@ -0,0 +1,8 @@
p
q
1
2
3
a
b
c

View File

@@ -0,0 +1,3 @@
channel.of('a', 'c', 'c', 'q', 'b')
.count { v -> v <= 'c' }
.view()

View File

@@ -0,0 +1 @@
4

View File

@@ -0,0 +1,3 @@
channel.of(4, 1, 7, 1, 1)
.count(1)
.view()

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1,3 @@
channel.of('a', 'c', 'c', 'q', 'b')
.count( ~/c/ )
.view()

View File

@@ -0,0 +1 @@
2

View File

@@ -0,0 +1,3 @@
channel.of(9, 1, 7, 5)
.count()
.view()

View File

@@ -0,0 +1 @@
4

View File

@@ -0,0 +1,4 @@
source = channel.of( [1, 'alpha'], [2, 'beta'] )
target = channel.of( [1, 'a'], [1, 'b'], [2, 'a'], [2, 'b'] )
source .cross(target) { v -> v[1][0] } .view()

View File

@@ -0,0 +1,4 @@
[[1, alpha], [1, a]]
[[1, alpha], [2, a]]
[[2, beta], [1, b]]
[[2, beta], [2, b]]

View File

@@ -0,0 +1,4 @@
source = channel.of( [1, 'alpha'], [2, 'beta'] )
target = channel.of( [1, 'x'], [1, 'y'], [1, 'z'], [2, 'p'], [2, 'q'], [2, 't'] )
source.cross(target).view()

View File

@@ -0,0 +1,6 @@
[[1, alpha], [1, x]]
[[1, alpha], [1, y]]
[[1, alpha], [1, z]]
[[2, beta], [2, p]]
[[2, beta], [2, q]]
[[2, beta], [2, t]]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 1, 2, 2, 2, 3, 1, 1, 2, 4, 6 )
.distinct { v -> v % 2 }
.view()

View File

@@ -0,0 +1,4 @@
1
2
3
2

View File

@@ -0,0 +1,3 @@
channel.of( 1, 1, 2, 2, 2, 3, 1, 1, 2, 2, 3 )
.distinct()
.view()

View File

@@ -0,0 +1,6 @@
1
2
3
1
2
3

View File

@@ -0,0 +1,7 @@
channel.of( 1, 2, 3 )
.map { v -> v + 1 }
.dump(tag: 'plus1')
channel.of( 1, 2, 3 )
.map { v -> v ** 2 }
.dump(tag: 'exp2')

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 4, 5 )
.filter { v -> v % 2 == 1 }
.view()

View File

@@ -0,0 +1,3 @@
1
3
5

View File

@@ -0,0 +1,3 @@
channel.of( 'a', 'b', 'aa', 'bc', 3, 4.5 )
.filter( ~/^a.*/ )
.view()

View File

@@ -0,0 +1,2 @@
a
aa

View File

@@ -0,0 +1,3 @@
channel.of( 'a', 'b', 'aa', 'bc', 3, 4.5 )
.filter( Number )
.view()

View File

@@ -0,0 +1,2 @@
3
4.5

View File

@@ -0,0 +1,19 @@
// no condition is specified, emits the very first item: 1
channel.of( 1, 2, 3 )
.first()
.view()
// emits the first item matching the regular expression: 'aa'
channel.of( 'a', 'aa', 'aaa' )
.first( ~/aa.*/ )
.view()
// emits the first String value: 'a'
channel.of( 1, 2, 'a', 'b', 3 )
.first( String )
.view()
// emits the first item for which the predicate evaluates to true: 4
channel.of( 1, 2, 3, 4, 5 )
.first { v -> v > 3 }
.view()

View File

@@ -0,0 +1,4 @@
1
a
aa
4

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3 )
.flatMap { n -> [ n, n*2, n*3 ] }
.view()

View File

@@ -0,0 +1,9 @@
1
2
3
2
4
6
3
6
9

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3 )
.flatMap { n -> [ number: n, square: n*n, cube: n*n*n ] }
.view { entry -> "${entry.key}: ${entry.value}" }

View File

@@ -0,0 +1,9 @@
number: 1
square: 1
cube: 1
number: 2
square: 4
cube: 8
number: 3
square: 9
cube: 27

View File

@@ -0,0 +1,3 @@
channel.of( [1, [2, 3]], 4, [5, [6]] )
.flatten()
.view()

View File

@@ -0,0 +1,6 @@
1
2
3
4
5
6

View File

@@ -0,0 +1,13 @@
channel.of(
tuple('chr1', ['/path/to/region1_chr1.vcf', '/path/to/region2_chr1.vcf']),
tuple('chr2', ['/path/to/region1_chr2.vcf', '/path/to/region2_chr2.vcf', '/path/to/region3_chr2.vcf']),
)
.flatMap { chr, vcfs ->
vcfs.collect { vcf ->
tuple(chr, vcfs.size(), vcf) // preserve group size
}
}
.view { v -> "scattered: ${v}" }
.groupBy()
.map { key, values -> tuple(key, values.toSorted()) }
.view { v -> "gathered: ${v}" }

View File

@@ -0,0 +1,7 @@
scattered: [chr1, 2, /path/to/region1_chr1.vcf]
scattered: [chr1, 2, /path/to/region2_chr1.vcf]
scattered: [chr2, 3, /path/to/region1_chr2.vcf]
scattered: [chr2, 3, /path/to/region2_chr2.vcf]
scattered: [chr2, 3, /path/to/region3_chr2.vcf]
gathered: [chr1, [/path/to/region1_chr1.vcf, /path/to/region2_chr1.vcf]]
gathered: [chr2, [/path/to/region1_chr2.vcf, /path/to/region2_chr2.vcf, /path/to/region3_chr2.vcf]]

View File

@@ -0,0 +1,4 @@
channel.of( tuple(1, 'A'), tuple(1, 'B'), tuple(2, 'C'), tuple(3, 'B'), tuple(1, 'C'), tuple(2, 'A'), tuple(3, 'D') )
.groupBy()
.map { key, values -> tuple(key, values.toSorted()) }
.view()

View File

@@ -0,0 +1,3 @@
[1, [A, B, C]]
[2, [A, C]]
[3, [B, D]]

View File

@@ -0,0 +1,3 @@
channel.of( [1, 'A'], [1, 'B'], [2, 'C'], [3, 'B'], [1, 'C'], [2, 'A'], [3, 'D'] )
.groupTuple(by: 1)
.view()

View File

@@ -0,0 +1,4 @@
[[1, 2], A]
[[1, 3], B]
[[2, 1], C]
[[3], D]

View File

@@ -0,0 +1,13 @@
channel.of(
['chr1', ['/path/to/region1_chr1.vcf', '/path/to/region2_chr1.vcf']],
['chr2', ['/path/to/region1_chr2.vcf', '/path/to/region2_chr2.vcf', '/path/to/region3_chr2.vcf']],
)
.flatMap { chr, vcfs ->
vcfs.collect { vcf ->
tuple(groupKey(chr, vcfs.size()), vcf) // preserve group size with key
}
}
.view { v -> "scattered: ${v}" }
.groupTuple()
.map { key, vcfs -> tuple(key.getGroupTarget(), vcfs) } // unwrap group key
.view { v -> "gathered: ${v}" }

View File

@@ -0,0 +1,7 @@
scattered: [chr1, /path/to/region1_chr1.vcf]
scattered: [chr1, /path/to/region2_chr1.vcf]
scattered: [chr2, /path/to/region1_chr2.vcf]
scattered: [chr2, /path/to/region2_chr2.vcf]
scattered: [chr2, /path/to/region3_chr2.vcf]
gathered: [chr1, [/path/to/region1_chr1.vcf, /path/to/region2_chr1.vcf]]
gathered: [chr2, [/path/to/region1_chr2.vcf, /path/to/region2_chr2.vcf, /path/to/region3_chr2.vcf]]

View File

@@ -0,0 +1,3 @@
channel.of( [1, 'A'], [1, 'B'], [2, 'C'], [3, 'B'], [1, 'C'], [2, 'A'], [3, 'D'] )
.groupTuple()
.view()

View File

@@ -0,0 +1,3 @@
[1, [A, B, C]]
[2, [C, A]]
[3, [B, D]]

View File

@@ -0,0 +1 @@
channel.of(1, 2, 3).ifEmpty('Hello').view()

View File

@@ -0,0 +1,3 @@
1
2
3

View File

@@ -0,0 +1 @@
channel.empty().ifEmpty('Hello').view()

View File

@@ -0,0 +1 @@
Hello

View File

@@ -0,0 +1,4 @@
left = channel.of( record(id: 'X', a: 1), record(id: 'X', a: 3) )
right = channel.of( record(id: 'X', b: 2), record(id: 'X', b: 4) )
left.join(right, by: 'id').view()

View File

@@ -0,0 +1,4 @@
[id:X, a:1, b:2]
[id:X, a:1, b:4]
[id:X, a:3, b:2]
[id:X, a:3, b:4]

View File

@@ -0,0 +1,4 @@
left = channel.of( record(id: 'X', a: 1), record(id: 'Y', a: 2), record(id: 'Z', a: 3), record(id: 'P', a: 7) )
right = channel.of( record(id: 'Z', b: 6), record(id: 'Y', b: 5), record(id: 'X', b: 4), record(id: 'Q', b: 8) )
left.join(right, by: 'id', remainder: true).view()

View File

@@ -0,0 +1,5 @@
[id:Y, a:2, b:5]
[id:Z, a:3, b:6]
[id:X, a:1, b:4]
[id:P, a:7]
[id:Q, b:8]

View File

@@ -0,0 +1,4 @@
left = channel.of( record(id: 'X', a: 1), record(id: 'Y', a: 2), record(id: 'Z', a: 3), record(id: 'P', a: 7) )
right = channel.of( record(id: 'Z', b: 6), record(id: 'Y', b: 5), record(id: 'X', b: 4) )
left.join(right, by: 'id').view()

View File

@@ -0,0 +1,3 @@
[id:Z, a:3, b:6]
[id:Y, a:2, b:5]
[id:X, a:1, b:4]

View File

@@ -0,0 +1,4 @@
left = channel.of( ['X', 1], ['Y', 2], ['Z', 3], ['P', 7] )
right = channel.of( ['Z', 6], ['Y', 5], ['X', 4] )
left.join(right, remainder: true).view()

View File

@@ -0,0 +1,4 @@
[Y, 2, 5]
[Z, 3, 6]
[X, 1, 4]
[P, 7, null]

View File

@@ -0,0 +1,4 @@
left = channel.of( ['X', 1], ['Y', 2], ['Z', 3], ['P', 7] )
right = channel.of( ['Z', 6], ['Y', 5], ['X', 4] )
left.join(right).view()

View File

@@ -0,0 +1,3 @@
[Z, 3, 6]
[Y, 2, 5]
[X, 1, 4]

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 4, 5, 6 )
.last()
.view()

View File

@@ -0,0 +1 @@
6

View File

@@ -0,0 +1,3 @@
channel.of( 1, 2, 3, 4, 5 )
.map { v -> v * v }
.view()

View File

@@ -0,0 +1,5 @@
1
4
9
16
25

View File

@@ -0,0 +1,4 @@
// comparator function
channel.of( "hello", "hi", "hey" )
.max { a, b -> a.length() <=> b.length() }
.view()

View File

@@ -0,0 +1 @@
hello

View File

@@ -0,0 +1,4 @@
// mapping function
channel.of( "hello", "hi", "hey" )
.max { v -> v.length() }
.view()

Some files were not shown because too many files have changed in this diff Show More