Skip to content

Commit

Permalink
Remove Channel.from in favor of Channel.of (#3670) [ci fast]
Browse files Browse the repository at this point in the history

Signed-off-by: Ben Sherman <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
bentsherman and pditommaso authored Apr 29, 2023
1 parent ebf42ca commit aa8b72f
Show file tree
Hide file tree
Showing 27 changed files with 209 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ class OperatorImpl {
* For example:
*
* <pre>
* Channel.from(...)
* Channel.of(...)
* .tap { newChannelName }
* .map { ... }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ class BranchOpTest extends Dsl2Spec {
bar: it>=5
}
bra1 = Channel.from(1,2,3).branch(criteria)
bra2 = Channel.from(6,7,8).branch(criteria)
bra1 = Channel.of(1,2,3).branch(criteria)
bra2 = Channel.of(6,7,8).branch(criteria)
bra1.foo.view { "foo:$it" }
bra2.bar.view { "bar:$it" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class BufferOpTest extends Specification {
def testBufferClose() {

when:
def r1 = Channel.from(1,2,3,1,2,3).buffer({ it == 2 })
def r1 = Channel.of(1,2,3,1,2,3).buffer({ it == 2 })
then:
r1.val == [1,2]
r1.val == [3,1,2]
r1.val == Channel.STOP

when:
def r2 = Channel.from('a','b','c','a','b','z').buffer(~/b/)
def r2 = Channel.of('a','b','c','a','b','z').buffer(~/b/)
then:
r2.val == ['a','b']
r2.val == ['c','a','b']
Expand All @@ -55,15 +55,15 @@ class BufferOpTest extends Specification {
def testBufferWithCount() {

when:
def r1 = Channel.from(1,2,3,1,2,3,1).buffer( size:2 )
def r1 = Channel.of(1,2,3,1,2,3,1).buffer( size:2 )
then:
r1.val == [1,2]
r1.val == [3,1]
r1.val == [2,3]
r1.val == Channel.STOP

when:
r1 = Channel.from(1,2,3,1,2,3,1).buffer( size:2, remainder: true )
r1 = Channel.of(1,2,3,1,2,3,1).buffer( size:2, remainder: true )
then:
r1.val == [1,2]
r1.val == [3,1]
Expand All @@ -73,14 +73,14 @@ class BufferOpTest extends Specification {


when:
def r2 = Channel.from(1,2,3,4,5,1,2,3,4,5,1,2,9).buffer( size:3, skip:2 )
def r2 = Channel.of(1,2,3,4,5,1,2,3,4,5,1,2,9).buffer( size:3, skip:2 )
then:
r2.val == [3,4,5]
r2.val == [3,4,5]
r2.val == Channel.STOP

when:
r2 = Channel.from(1,2,3,4,5,1,2,3,4,5,1,2,9).buffer( size:3, skip:2, remainder: true )
r2 = Channel.of(1,2,3,4,5,1,2,3,4,5,1,2,9).buffer( size:3, skip:2, remainder: true )
then:
r2.val == [3,4,5]
r2.val == [3,4,5]
Expand All @@ -103,14 +103,14 @@ class BufferOpTest extends Specification {
def testBufferOpenClose() {

when:
def r1 = Channel.from(1,2,3,4,5,1,2,3,4,5,1,2).buffer( 2, 4 )
def r1 = Channel.of(1,2,3,4,5,1,2,3,4,5,1,2).buffer( 2, 4 )
then:
r1.val == [2,3,4]
r1.val == [2,3,4]
r1.val == Channel.STOP

when:
def r2 = Channel.from('a','b','c','a','b','z').buffer(~/a/,~/b/)
def r2 = Channel.of('a','b','c','a','b','z').buffer(~/a/,~/b/)
then:
r2.val == ['a','b']
r2.val == ['a','b']
Expand All @@ -122,7 +122,7 @@ class BufferOpTest extends Specification {

when:
def sum = 0
def r1 = Channel.from(1,2,3,1,2,3).buffer(remainder: true, { sum+=it; sum==7 })
def r1 = Channel.of(1,2,3,1,2,3).buffer(remainder: true, { sum+=it; sum==7 })
then:
r1.val == [1,2,3,1]
r1.val == [2,3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CollectOpTest extends Specification {
def 'should collect items into a list'() {

when:
def source = Channel.from(1,2,3)
def source = Channel.of(1,2,3)
def result = source.collect()
then:
result.val == [1,2,3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class CombineOpTest extends Specification {
def 'should combine channels' () {

given:
def left = Channel.from('a','b','c')
def right = Channel.from(1,2,3)
def left = Channel.of('a','b','c')
def right = Channel.of(1,2,3)
def op = new CombineOp(left, right)

when:
Expand All @@ -79,8 +79,8 @@ class CombineOpTest extends Specification {

def 'should combine by a value' () {
given:
def left = Channel.from(['A', 10], ['A', 20], ['B', 30], ['B', 40])
def right = Channel.from(['A', 11], ['A', 22], ['B', 33])
def left = Channel.of(['A', 10], ['A', 20], ['B', 30], ['B', 40])
def right = Channel.of(['A', 11], ['A', 22], ['B', 33])

when:
def op = new CombineOp(left,right)
Expand All @@ -95,7 +95,7 @@ class CombineOpTest extends Specification {
def 'should combine a channel with a list' () {

given:
def left = Channel.from('a','b')
def left = Channel.of('a','b')
def right = [1,2,3,4]
def op = new CombineOp(left, right)

Expand Down Expand Up @@ -161,9 +161,9 @@ class CombineOpTest extends Specification {
def 'should chain combine ops flat default' () {

given:
def ch2 = Channel.from('a','b','c')
def ch3 = Channel.from('x','y')
def ch1 = Channel.from(1,2)
def ch2 = Channel.of('a','b','c')
def ch3 = Channel.of('x','y')
def ch1 = Channel.of(1,2)

when:
def result = new CombineOp(new CombineOp(ch1, ch2).apply(), ch3).apply()
Expand All @@ -190,9 +190,9 @@ class CombineOpTest extends Specification {
def 'should chain combine ops flat true' () {

given:
def ch1 = Channel.from(1,2)
def ch2 = Channel.from('a','b','c')
def ch3 = Channel.from('x','y')
def ch1 = Channel.of(1,2)
def ch2 = Channel.of('a','b','c')
def ch3 = Channel.of('x','y')

when:
def result = new CombineOp(new CombineOp(ch1, ch2).apply(), ch3).apply()
Expand All @@ -218,7 +218,7 @@ class CombineOpTest extends Specification {
def 'should combine with tuples' () {

when:
def left = Channel.from([1, 'x'], [2,'y'], [3, 'z'])
def left = Channel.of([1, 'x'], [2,'y'], [3, 'z'])
def right = ['alpha','beta','gamma']

def result = new CombineOp(left, right).apply()
Expand All @@ -244,7 +244,7 @@ class CombineOpTest extends Specification {
def 'should combine with map' () {

when:
def left = Channel.from([id:1, val:'x'], [id:2,val:'y'], [id:3, val:'z'])
def left = Channel.of([id:1, val:'x'], [id:2,val:'y'], [id:3, val:'z'])
def right = ['alpha','beta','gamma']
def result = left.combine(right)
def all = (List) ToListOp.apply(result).val
Expand All @@ -270,7 +270,7 @@ class CombineOpTest extends Specification {
def 'should combine items'() {

when:
def left = Channel.from(1,2,3)
def left = Channel.of(1,2,3)
def right = ['a','b']
def result = left.combine(right).toSortedList().val.iterator()
then:
Expand All @@ -282,8 +282,8 @@ class CombineOpTest extends Specification {
result.next() == [3, 'b']

when:
left = Channel.from(1,2)
right = Channel.from('a','b','c')
left = Channel.of(1,2)
right = Channel.of('a','b','c')
result = left.combine(right).toSortedList().val.iterator()
then:
result.next() == [1, 'a']
Expand All @@ -298,9 +298,9 @@ class CombineOpTest extends Specification {
def 'should chain combine'() {

when:
def str1 = Channel.from('a','b','c')
def str2 = Channel.from('x','y')
def result = Channel.from(1,2).combine(str1).combine(str2).toSortedList().val.iterator()
def str1 = Channel.of('a','b','c')
def str2 = Channel.of('x','y')
def result = Channel.of(1,2).combine(str1).combine(str2).toSortedList().val.iterator()
then:
result.next() == [1,'a','x']
result.next() == [1,'a','y']
Expand All @@ -316,9 +316,9 @@ class CombineOpTest extends Specification {
result.next() == [2,'c','y']

when:
str1 = Channel.from('a','b','c')
str2 = Channel.from('x','y')
result = Channel.from(1,2).combine(str1).combine(str2,flat:false).toSortedList().val.iterator()
str1 = Channel.of('a','b','c')
str2 = Channel.of('x','y')
result = Channel.of(1,2).combine(str1).combine(str2,flat:false).toSortedList().val.iterator()
then:
result.next() == [1,'a','x']
result.next() == [1,'a','y']
Expand All @@ -337,8 +337,8 @@ class CombineOpTest extends Specification {
def 'should combine by first element' () {

given:
def left = Channel.from( ['A',1], ['A',2], ['B',1], ['B',2] )
def right = Channel.from( ['A',1], ['A',2], ['B',1], ['B',2] )
def left = Channel.of( ['A',1], ['A',2], ['B',1], ['B',2] )
def right = Channel.of( ['A',1], ['A',2], ['B',1], ['B',2] )

when:
def op = new CombineOp(left, right)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class ConcatOp2Test extends Dsl2Spec {

when:
def result = dsl_eval('''
c1 = Channel.from(1,2,3)
c2 = Channel.from('a','b','c')
c1 = Channel.of(1,2,3)
c2 = Channel.of('a','b','c')
c1.concat(c2)
''')
then:
Expand All @@ -49,7 +49,7 @@ class ConcatOp2Test extends Dsl2Spec {
when:
def result = dsl_eval('''
ch1 = Channel.value(1)
ch2 = Channel.from(2,3)
ch2 = Channel.of(2,3)
ch1.concat(ch2)
''')
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CountFastaOpTest extends Specification {
.stripIndent()

when:
def result = Channel.from( str, str2 ).countFasta()
def result = Channel.of( str, str2 ).countFasta()
then:
result.val == 8

Expand Down Expand Up @@ -111,7 +111,7 @@ class CountFastaOpTest extends Specification {
.stripIndent()

when:
def result = Channel.from( file1, file2 ).countFasta()
def result = Channel.of( file1, file2 ).countFasta()
then:
result.val == 10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CountFastqOpTest extends Specification {


when:
def result = Channel.from( READS, READS2 ).countFastq()
def result = Channel.of( READS, READS2 ).countFastq()
then:
result.val == 7

Expand Down Expand Up @@ -122,7 +122,7 @@ class CountFastqOpTest extends Specification {


when:
def result = Channel.from(file1, file2).countFastq()
def result = Channel.of(file1, file2).countFastq()
then:
result.val == 9

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CountLinesOpTest extends Specification {
'''
.stripIndent().strip()

def result = Channel.from(str, str2, str3).countLines()
def result = Channel.of(str, str2, str3).countLines()
then:
result.val == 11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class DataflowMergeExtensionTest extends Specification {

def 'should merge with open array with custom closure'() {
when:
def alpha = Channel.from(1, 3, 5);
def beta = Channel.from(2, 4, 6);
def delta = Channel.from(7, 8, 1);
def alpha = Channel.of(1, 3, 5)
def beta = Channel.of(2, 4, 6)
def delta = Channel.of(7, 8, 1)
def result = alpha.merge( beta, delta ) { a,b,c -> [c,b,a] }
then:
result instanceof DataflowQueue
Expand All @@ -56,9 +56,9 @@ class DataflowMergeExtensionTest extends Specification {

def 'should merge with open array' () {
when:
def alpha = Channel.from(1, 3, 5);
def beta = Channel.from(2, 4, 6);
def delta = Channel.from(7, 8, 1);
def alpha = Channel.of(1, 3, 5)
def beta = Channel.of(2, 4, 6)
def delta = Channel.of(7, 8, 1)
def result = alpha.merge( beta, delta )
then:
result instanceof DataflowQueue
Expand All @@ -71,8 +71,8 @@ class DataflowMergeExtensionTest extends Specification {
def 'should merge with with default'() {

when:
def left = Channel.from(1, 3, 5);
def right = Channel.from(2, 4, 6);
def left = Channel.of(1, 3, 5)
def right = Channel.of(2, 4, 6)
def result = left.merge(right)
then:
result instanceof DataflowQueue
Expand All @@ -82,8 +82,8 @@ class DataflowMergeExtensionTest extends Specification {
result.val == Channel.STOP

when:
left = Channel.from(1, 2, 3);
right = Channel.from(['a','b'], ['p','q'], ['x','z']);
left = Channel.of(1, 2, 3)
right = Channel.of(['a','b'], ['p','q'], ['x','z'])
result = left.merge(right)
then:
result instanceof DataflowQueue
Expand All @@ -93,8 +93,8 @@ class DataflowMergeExtensionTest extends Specification {
result.val == Channel.STOP

when:
left = Channel.from('A','B','C');
right = Channel.from(['a',[1,2,3]], ['b',[3,4,5]], ['c',[6,7,8]]);
left = Channel.of('A','B','C')
right = Channel.of(['a',[1,2,3]], ['b',[3,4,5]], ['c',[6,7,8]])
result = left.merge(right)
then:
result instanceof DataflowQueue
Expand All @@ -108,9 +108,9 @@ class DataflowMergeExtensionTest extends Specification {
def 'should merge with list'() {

when:
def alpha = Channel.from(1, 3, 5);
def beta = Channel.from(2, 4, 6);
def delta = Channel.from(7, 8, 1);
def alpha = Channel.of(1, 3, 5)
def beta = Channel.of(2, 4, 6)
def delta = Channel.of(7, 8, 1)
def result = alpha.merge( [beta, delta] ) { a,b,c -> [c,b,a] }
then:
result instanceof DataflowQueue
Expand All @@ -124,8 +124,8 @@ class DataflowMergeExtensionTest extends Specification {
def 'should merge with queue'() {

when:
def alpha = Channel.from(1, 3, 5);
def beta = Channel.from(2, 4, 6);
def alpha = Channel.of(1, 3, 5)
def beta = Channel.of(2, 4, 6)

def result = alpha.merge(beta) { a,b -> [a, b+1] }

Expand Down
Loading

0 comments on commit aa8b72f

Please sign in to comment.