add nextflow d30e48d
This commit is contained in:
2
nextflow/docs/snippets/.gitignore
vendored
Normal file
2
nextflow/docs/snippets/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.nextflow*
|
||||
work
|
||||
12
nextflow/docs/snippets/branch-criteria.nf
Normal file
12
nextflow/docs/snippets/branch-criteria.nf
Normal 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" }
|
||||
5
nextflow/docs/snippets/branch-criteria.out
Normal file
5
nextflow/docs/snippets/branch-criteria.out
Normal file
@@ -0,0 +1,5 @@
|
||||
1 is small
|
||||
2 is small
|
||||
3 is small
|
||||
20 is large
|
||||
30 is large
|
||||
11
nextflow/docs/snippets/branch-with-fallback.nf
Normal file
11
nextflow/docs/snippets/branch-with-fallback.nf
Normal 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" }
|
||||
5
nextflow/docs/snippets/branch-with-fallback.out
Normal file
5
nextflow/docs/snippets/branch-with-fallback.out
Normal file
@@ -0,0 +1,5 @@
|
||||
1 is small
|
||||
2 is small
|
||||
3 is small
|
||||
40 is large
|
||||
50 is other
|
||||
16
nextflow/docs/snippets/branch-with-mapper.nf
Normal file
16
nextflow/docs/snippets/branch-with-mapper.nf
Normal 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" }
|
||||
5
nextflow/docs/snippets/branch-with-mapper.out
Normal file
5
nextflow/docs/snippets/branch-with-mapper.out
Normal file
@@ -0,0 +1,5 @@
|
||||
3 is alpha
|
||||
4 is alpha
|
||||
5 is alpha
|
||||
38 is beta
|
||||
0 is other
|
||||
9
nextflow/docs/snippets/branch.nf
Normal file
9
nextflow/docs/snippets/branch.nf
Normal 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" }
|
||||
5
nextflow/docs/snippets/branch.out
Normal file
5
nextflow/docs/snippets/branch.out
Normal file
@@ -0,0 +1,5 @@
|
||||
1 is small
|
||||
2 is small
|
||||
3 is small
|
||||
40 is large
|
||||
50 is large
|
||||
3
nextflow/docs/snippets/buffer-with-closing.nf
Normal file
3
nextflow/docs/snippets/buffer-with-closing.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 1, 2, 3 )
|
||||
.buffer { v -> v == 2 }
|
||||
.view()
|
||||
2
nextflow/docs/snippets/buffer-with-closing.out
Normal file
2
nextflow/docs/snippets/buffer-with-closing.out
Normal file
@@ -0,0 +1,2 @@
|
||||
[1, 2]
|
||||
[3, 1, 2]
|
||||
4
nextflow/docs/snippets/buffer-with-opening-closing.nf
Normal file
4
nextflow/docs/snippets/buffer-with-opening-closing.nf
Normal 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()
|
||||
2
nextflow/docs/snippets/buffer-with-opening-closing.out
Normal file
2
nextflow/docs/snippets/buffer-with-opening-closing.out
Normal file
@@ -0,0 +1,2 @@
|
||||
[2, 3, 4]
|
||||
[2, 3, 4]
|
||||
3
nextflow/docs/snippets/buffer-with-size-remainder.nf
Normal file
3
nextflow/docs/snippets/buffer-with-size-remainder.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 1, 2, 3, 1 )
|
||||
.buffer( size: 2, remainder: true )
|
||||
.view()
|
||||
4
nextflow/docs/snippets/buffer-with-size-remainder.out
Normal file
4
nextflow/docs/snippets/buffer-with-size-remainder.out
Normal file
@@ -0,0 +1,4 @@
|
||||
[1, 2]
|
||||
[3, 1]
|
||||
[2, 3]
|
||||
[1]
|
||||
3
nextflow/docs/snippets/buffer-with-size-skip.nf
Normal file
3
nextflow/docs/snippets/buffer-with-size-skip.nf
Normal 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()
|
||||
2
nextflow/docs/snippets/buffer-with-size-skip.out
Normal file
2
nextflow/docs/snippets/buffer-with-size-skip.out
Normal file
@@ -0,0 +1,2 @@
|
||||
[3, 4, 5]
|
||||
[3, 4, 5]
|
||||
3
nextflow/docs/snippets/buffer-with-size.nf
Normal file
3
nextflow/docs/snippets/buffer-with-size.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 1, 2, 3, 1 )
|
||||
.buffer( size: 2 )
|
||||
.view()
|
||||
3
nextflow/docs/snippets/buffer-with-size.out
Normal file
3
nextflow/docs/snippets/buffer-with-size.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[1, 2]
|
||||
[3, 1]
|
||||
[2, 3]
|
||||
3
nextflow/docs/snippets/collate-with-no-remainder.nf
Normal file
3
nextflow/docs/snippets/collate-with-no-remainder.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of(1, 2, 3, 1, 2, 3, 1)
|
||||
.collate( 3, false )
|
||||
.view()
|
||||
2
nextflow/docs/snippets/collate-with-no-remainder.out
Normal file
2
nextflow/docs/snippets/collate-with-no-remainder.out
Normal file
@@ -0,0 +1,2 @@
|
||||
[1, 2, 3]
|
||||
[1, 2, 3]
|
||||
3
nextflow/docs/snippets/collate-with-step.nf
Normal file
3
nextflow/docs/snippets/collate-with-step.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of(1, 2, 3, 4)
|
||||
.collate( 3, 1 )
|
||||
.view()
|
||||
4
nextflow/docs/snippets/collate-with-step.out
Normal file
4
nextflow/docs/snippets/collate-with-step.out
Normal file
@@ -0,0 +1,4 @@
|
||||
[1, 2, 3]
|
||||
[2, 3, 4]
|
||||
[3, 4]
|
||||
[4]
|
||||
3
nextflow/docs/snippets/collate.nf
Normal file
3
nextflow/docs/snippets/collate.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of(1, 2, 3, 1, 2, 3, 1)
|
||||
.collate( 3 )
|
||||
.view()
|
||||
3
nextflow/docs/snippets/collate.out
Normal file
3
nextflow/docs/snippets/collate.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[1, 2, 3]
|
||||
[1, 2, 3]
|
||||
[1]
|
||||
3
nextflow/docs/snippets/collect-with-mapper.nf
Normal file
3
nextflow/docs/snippets/collect-with-mapper.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 'hello', 'ciao', 'bonjour' )
|
||||
.collect { v -> v.length() }
|
||||
.view()
|
||||
1
nextflow/docs/snippets/collect-with-mapper.out
Normal file
1
nextflow/docs/snippets/collect-with-mapper.out
Normal file
@@ -0,0 +1 @@
|
||||
[5, 4, 7]
|
||||
3
nextflow/docs/snippets/collect.nf
Normal file
3
nextflow/docs/snippets/collect.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 4 )
|
||||
.collect()
|
||||
.view()
|
||||
1
nextflow/docs/snippets/collect.out
Normal file
1
nextflow/docs/snippets/collect.out
Normal file
@@ -0,0 +1 @@
|
||||
[1, 2, 3, 4]
|
||||
8
nextflow/docs/snippets/collectfile-closure.nf
Normal file
8
nextflow/docs/snippets/collectfile-closure.nf
Normal 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
|
||||
}
|
||||
11
nextflow/docs/snippets/collectfile-closure.out
Normal file
11
nextflow/docs/snippets/collectfile-closure.out
Normal file
@@ -0,0 +1,11 @@
|
||||
File 'B.txt' contains:
|
||||
Bonjour
|
||||
|
||||
File 'C.txt' contains:
|
||||
Ciao
|
||||
|
||||
File 'H.txt' contains:
|
||||
Halo
|
||||
Hola
|
||||
Hello
|
||||
|
||||
6
nextflow/docs/snippets/collectfile.nf
Normal file
6
nextflow/docs/snippets/collectfile.nf
Normal 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}"
|
||||
}
|
||||
4
nextflow/docs/snippets/combine-by.nf
Normal file
4
nextflow/docs/snippets/combine-by.nf
Normal 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()
|
||||
6
nextflow/docs/snippets/combine-by.out
Normal file
6
nextflow/docs/snippets/combine-by.out
Normal file
@@ -0,0 +1,6 @@
|
||||
[1, alpha, x]
|
||||
[1, alpha, y]
|
||||
[1, alpha, z]
|
||||
[2, beta, p]
|
||||
[2, beta, q]
|
||||
[2, beta, t]
|
||||
6
nextflow/docs/snippets/combine.nf
Normal file
6
nextflow/docs/snippets/combine.nf
Normal file
@@ -0,0 +1,6 @@
|
||||
numbers = channel.of(1, 2, 3)
|
||||
words = channel.of('hello', 'ciao')
|
||||
|
||||
numbers
|
||||
.combine(words)
|
||||
.view()
|
||||
6
nextflow/docs/snippets/combine.out
Normal file
6
nextflow/docs/snippets/combine.out
Normal file
@@ -0,0 +1,6 @@
|
||||
[1, hello]
|
||||
[2, hello]
|
||||
[3, hello]
|
||||
[1, ciao]
|
||||
[2, ciao]
|
||||
[3, ciao]
|
||||
5
nextflow/docs/snippets/concat.nf
Normal file
5
nextflow/docs/snippets/concat.nf
Normal 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()
|
||||
8
nextflow/docs/snippets/concat.out
Normal file
8
nextflow/docs/snippets/concat.out
Normal file
@@ -0,0 +1,8 @@
|
||||
p
|
||||
q
|
||||
1
|
||||
2
|
||||
3
|
||||
a
|
||||
b
|
||||
c
|
||||
3
nextflow/docs/snippets/count-with-filter-closure.nf
Normal file
3
nextflow/docs/snippets/count-with-filter-closure.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of('a', 'c', 'c', 'q', 'b')
|
||||
.count { v -> v <= 'c' }
|
||||
.view()
|
||||
1
nextflow/docs/snippets/count-with-filter-closure.out
Normal file
1
nextflow/docs/snippets/count-with-filter-closure.out
Normal file
@@ -0,0 +1 @@
|
||||
4
|
||||
3
nextflow/docs/snippets/count-with-filter-number.nf
Normal file
3
nextflow/docs/snippets/count-with-filter-number.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of(4, 1, 7, 1, 1)
|
||||
.count(1)
|
||||
.view()
|
||||
1
nextflow/docs/snippets/count-with-filter-number.out
Normal file
1
nextflow/docs/snippets/count-with-filter-number.out
Normal file
@@ -0,0 +1 @@
|
||||
3
|
||||
3
nextflow/docs/snippets/count-with-filter-regex.nf
Normal file
3
nextflow/docs/snippets/count-with-filter-regex.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of('a', 'c', 'c', 'q', 'b')
|
||||
.count( ~/c/ )
|
||||
.view()
|
||||
1
nextflow/docs/snippets/count-with-filter-regex.out
Normal file
1
nextflow/docs/snippets/count-with-filter-regex.out
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
3
nextflow/docs/snippets/count.nf
Normal file
3
nextflow/docs/snippets/count.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of(9, 1, 7, 5)
|
||||
.count()
|
||||
.view()
|
||||
1
nextflow/docs/snippets/count.out
Normal file
1
nextflow/docs/snippets/count.out
Normal file
@@ -0,0 +1 @@
|
||||
4
|
||||
4
nextflow/docs/snippets/cross-with-mapper.nf
Normal file
4
nextflow/docs/snippets/cross-with-mapper.nf
Normal 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()
|
||||
4
nextflow/docs/snippets/cross-with-mapper.out
Normal file
4
nextflow/docs/snippets/cross-with-mapper.out
Normal file
@@ -0,0 +1,4 @@
|
||||
[[1, alpha], [1, a]]
|
||||
[[1, alpha], [2, a]]
|
||||
[[2, beta], [1, b]]
|
||||
[[2, beta], [2, b]]
|
||||
4
nextflow/docs/snippets/cross.nf
Normal file
4
nextflow/docs/snippets/cross.nf
Normal 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()
|
||||
6
nextflow/docs/snippets/cross.out
Normal file
6
nextflow/docs/snippets/cross.out
Normal 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]]
|
||||
3
nextflow/docs/snippets/distinct-with-mapper.nf
Normal file
3
nextflow/docs/snippets/distinct-with-mapper.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 1, 2, 2, 2, 3, 1, 1, 2, 4, 6 )
|
||||
.distinct { v -> v % 2 }
|
||||
.view()
|
||||
4
nextflow/docs/snippets/distinct-with-mapper.out
Normal file
4
nextflow/docs/snippets/distinct-with-mapper.out
Normal file
@@ -0,0 +1,4 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
3
nextflow/docs/snippets/distinct.nf
Normal file
3
nextflow/docs/snippets/distinct.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 1, 2, 2, 2, 3, 1, 1, 2, 2, 3 )
|
||||
.distinct()
|
||||
.view()
|
||||
6
nextflow/docs/snippets/distinct.out
Normal file
6
nextflow/docs/snippets/distinct.out
Normal file
@@ -0,0 +1,6 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
7
nextflow/docs/snippets/dump.nf
Normal file
7
nextflow/docs/snippets/dump.nf
Normal 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')
|
||||
3
nextflow/docs/snippets/filter-closure.nf
Normal file
3
nextflow/docs/snippets/filter-closure.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 4, 5 )
|
||||
.filter { v -> v % 2 == 1 }
|
||||
.view()
|
||||
3
nextflow/docs/snippets/filter-closure.out
Normal file
3
nextflow/docs/snippets/filter-closure.out
Normal file
@@ -0,0 +1,3 @@
|
||||
1
|
||||
3
|
||||
5
|
||||
3
nextflow/docs/snippets/filter-regex.nf
Normal file
3
nextflow/docs/snippets/filter-regex.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 'a', 'b', 'aa', 'bc', 3, 4.5 )
|
||||
.filter( ~/^a.*/ )
|
||||
.view()
|
||||
2
nextflow/docs/snippets/filter-regex.out
Normal file
2
nextflow/docs/snippets/filter-regex.out
Normal file
@@ -0,0 +1,2 @@
|
||||
a
|
||||
aa
|
||||
3
nextflow/docs/snippets/filter-type.nf
Normal file
3
nextflow/docs/snippets/filter-type.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 'a', 'b', 'aa', 'bc', 3, 4.5 )
|
||||
.filter( Number )
|
||||
.view()
|
||||
2
nextflow/docs/snippets/filter-type.out
Normal file
2
nextflow/docs/snippets/filter-type.out
Normal file
@@ -0,0 +1,2 @@
|
||||
3
|
||||
4.5
|
||||
19
nextflow/docs/snippets/first.nf
Normal file
19
nextflow/docs/snippets/first.nf
Normal 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()
|
||||
4
nextflow/docs/snippets/first.out
Normal file
4
nextflow/docs/snippets/first.out
Normal file
@@ -0,0 +1,4 @@
|
||||
1
|
||||
a
|
||||
aa
|
||||
4
|
||||
3
nextflow/docs/snippets/flatmap-list.nf
Normal file
3
nextflow/docs/snippets/flatmap-list.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3 )
|
||||
.flatMap { n -> [ n, n*2, n*3 ] }
|
||||
.view()
|
||||
9
nextflow/docs/snippets/flatmap-list.out
Normal file
9
nextflow/docs/snippets/flatmap-list.out
Normal file
@@ -0,0 +1,9 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
4
|
||||
6
|
||||
3
|
||||
6
|
||||
9
|
||||
3
nextflow/docs/snippets/flatmap-map.nf
Normal file
3
nextflow/docs/snippets/flatmap-map.nf
Normal 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}" }
|
||||
9
nextflow/docs/snippets/flatmap-map.out
Normal file
9
nextflow/docs/snippets/flatmap-map.out
Normal file
@@ -0,0 +1,9 @@
|
||||
number: 1
|
||||
square: 1
|
||||
cube: 1
|
||||
number: 2
|
||||
square: 4
|
||||
cube: 8
|
||||
number: 3
|
||||
square: 9
|
||||
cube: 27
|
||||
3
nextflow/docs/snippets/flatten.nf
Normal file
3
nextflow/docs/snippets/flatten.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( [1, [2, 3]], 4, [5, [6]] )
|
||||
.flatten()
|
||||
.view()
|
||||
6
nextflow/docs/snippets/flatten.out
Normal file
6
nextflow/docs/snippets/flatten.out
Normal file
@@ -0,0 +1,6 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
13
nextflow/docs/snippets/groupby-size.nf
Normal file
13
nextflow/docs/snippets/groupby-size.nf
Normal 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}" }
|
||||
7
nextflow/docs/snippets/groupby-size.out
Normal file
7
nextflow/docs/snippets/groupby-size.out
Normal 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]]
|
||||
4
nextflow/docs/snippets/groupby.nf
Normal file
4
nextflow/docs/snippets/groupby.nf
Normal 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()
|
||||
3
nextflow/docs/snippets/groupby.out
Normal file
3
nextflow/docs/snippets/groupby.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[1, [A, B, C]]
|
||||
[2, [A, C]]
|
||||
[3, [B, D]]
|
||||
3
nextflow/docs/snippets/grouptuple-by.nf
Normal file
3
nextflow/docs/snippets/grouptuple-by.nf
Normal 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()
|
||||
4
nextflow/docs/snippets/grouptuple-by.out
Normal file
4
nextflow/docs/snippets/grouptuple-by.out
Normal file
@@ -0,0 +1,4 @@
|
||||
[[1, 2], A]
|
||||
[[1, 3], B]
|
||||
[[2, 1], C]
|
||||
[[3], D]
|
||||
13
nextflow/docs/snippets/grouptuple-groupkey.nf
Normal file
13
nextflow/docs/snippets/grouptuple-groupkey.nf
Normal 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}" }
|
||||
7
nextflow/docs/snippets/grouptuple-groupkey.out
Normal file
7
nextflow/docs/snippets/grouptuple-groupkey.out
Normal 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]]
|
||||
3
nextflow/docs/snippets/grouptuple.nf
Normal file
3
nextflow/docs/snippets/grouptuple.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( [1, 'A'], [1, 'B'], [2, 'C'], [3, 'B'], [1, 'C'], [2, 'A'], [3, 'D'] )
|
||||
.groupTuple()
|
||||
.view()
|
||||
3
nextflow/docs/snippets/grouptuple.out
Normal file
3
nextflow/docs/snippets/grouptuple.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[1, [A, B, C]]
|
||||
[2, [C, A]]
|
||||
[3, [B, D]]
|
||||
1
nextflow/docs/snippets/ifempty-1.nf
Normal file
1
nextflow/docs/snippets/ifempty-1.nf
Normal file
@@ -0,0 +1 @@
|
||||
channel.of(1, 2, 3).ifEmpty('Hello').view()
|
||||
3
nextflow/docs/snippets/ifempty-1.out
Normal file
3
nextflow/docs/snippets/ifempty-1.out
Normal file
@@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
1
nextflow/docs/snippets/ifempty-2.nf
Normal file
1
nextflow/docs/snippets/ifempty-2.nf
Normal file
@@ -0,0 +1 @@
|
||||
channel.empty().ifEmpty('Hello').view()
|
||||
1
nextflow/docs/snippets/ifempty-2.out
Normal file
1
nextflow/docs/snippets/ifempty-2.out
Normal file
@@ -0,0 +1 @@
|
||||
Hello
|
||||
4
nextflow/docs/snippets/join-record-duplicates.nf
Normal file
4
nextflow/docs/snippets/join-record-duplicates.nf
Normal 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()
|
||||
4
nextflow/docs/snippets/join-record-duplicates.out
Normal file
4
nextflow/docs/snippets/join-record-duplicates.out
Normal 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]
|
||||
4
nextflow/docs/snippets/join-record-remainder.nf
Normal file
4
nextflow/docs/snippets/join-record-remainder.nf
Normal 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()
|
||||
5
nextflow/docs/snippets/join-record-remainder.out
Normal file
5
nextflow/docs/snippets/join-record-remainder.out
Normal 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]
|
||||
4
nextflow/docs/snippets/join-record.nf
Normal file
4
nextflow/docs/snippets/join-record.nf
Normal 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()
|
||||
3
nextflow/docs/snippets/join-record.out
Normal file
3
nextflow/docs/snippets/join-record.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[id:Z, a:3, b:6]
|
||||
[id:Y, a:2, b:5]
|
||||
[id:X, a:1, b:4]
|
||||
4
nextflow/docs/snippets/join-tuple-remainder.nf
Normal file
4
nextflow/docs/snippets/join-tuple-remainder.nf
Normal 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()
|
||||
4
nextflow/docs/snippets/join-tuple-remainder.out
Normal file
4
nextflow/docs/snippets/join-tuple-remainder.out
Normal file
@@ -0,0 +1,4 @@
|
||||
[Y, 2, 5]
|
||||
[Z, 3, 6]
|
||||
[X, 1, 4]
|
||||
[P, 7, null]
|
||||
4
nextflow/docs/snippets/join-tuple.nf
Normal file
4
nextflow/docs/snippets/join-tuple.nf
Normal 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()
|
||||
3
nextflow/docs/snippets/join-tuple.out
Normal file
3
nextflow/docs/snippets/join-tuple.out
Normal file
@@ -0,0 +1,3 @@
|
||||
[Z, 3, 6]
|
||||
[Y, 2, 5]
|
||||
[X, 1, 4]
|
||||
3
nextflow/docs/snippets/last.nf
Normal file
3
nextflow/docs/snippets/last.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 4, 5, 6 )
|
||||
.last()
|
||||
.view()
|
||||
1
nextflow/docs/snippets/last.out
Normal file
1
nextflow/docs/snippets/last.out
Normal file
@@ -0,0 +1 @@
|
||||
6
|
||||
3
nextflow/docs/snippets/map.nf
Normal file
3
nextflow/docs/snippets/map.nf
Normal file
@@ -0,0 +1,3 @@
|
||||
channel.of( 1, 2, 3, 4, 5 )
|
||||
.map { v -> v * v }
|
||||
.view()
|
||||
5
nextflow/docs/snippets/map.out
Normal file
5
nextflow/docs/snippets/map.out
Normal file
@@ -0,0 +1,5 @@
|
||||
1
|
||||
4
|
||||
9
|
||||
16
|
||||
25
|
||||
4
nextflow/docs/snippets/max-with-comparator.nf
Normal file
4
nextflow/docs/snippets/max-with-comparator.nf
Normal file
@@ -0,0 +1,4 @@
|
||||
// comparator function
|
||||
channel.of( "hello", "hi", "hey" )
|
||||
.max { a, b -> a.length() <=> b.length() }
|
||||
.view()
|
||||
1
nextflow/docs/snippets/max-with-comparator.out
Normal file
1
nextflow/docs/snippets/max-with-comparator.out
Normal file
@@ -0,0 +1 @@
|
||||
hello
|
||||
4
nextflow/docs/snippets/max-with-mapper.nf
Normal file
4
nextflow/docs/snippets/max-with-mapper.nf
Normal 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
Reference in New Issue
Block a user