From 99a6ccfeb6af4658685c86b641134736a1047e44 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Mon, 25 Nov 2024 17:17:42 -0600 Subject: [PATCH] Replace GPars channels with Channel interface Signed-off-by: Ben Sherman --- modules/compiler/build.gradle | 1 - .../src/main/java/script/dsl/WorkflowDsl.java | 84 ++-- .../src/main/java/script/types/Channel.java | 359 +++++++++++++++++- .../java/script/types/ChannelFactory.java | 24 +- .../src/main/java/script/types/Types.java | 8 +- 5 files changed, 399 insertions(+), 77 deletions(-) diff --git a/modules/compiler/build.gradle b/modules/compiler/build.gradle index 6df762b..5f379a8 100644 --- a/modules/compiler/build.gradle +++ b/modules/compiler/build.gradle @@ -7,7 +7,6 @@ dependencies { antlr 'org.antlr:antlr4:4.9.2' implementation 'com.google.guava:guava:33.3.1-jre' implementation 'org.apache.groovy:groovy:4.0.24' - implementation 'org.codehaus.gpars:gpars:1.2.1' testImplementation ('net.bytebuddy:byte-buddy:1.14.17') testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.apache.groovy' } diff --git a/modules/compiler/src/main/java/script/dsl/WorkflowDsl.java b/modules/compiler/src/main/java/script/dsl/WorkflowDsl.java index 8e770e3..22c77f0 100644 --- a/modules/compiler/src/main/java/script/dsl/WorkflowDsl.java +++ b/modules/compiler/src/main/java/script/dsl/WorkflowDsl.java @@ -19,8 +19,6 @@ import java.util.Map; import groovy.lang.Closure; -import groovyx.gpars.dataflow.DataflowReadChannel; -import groovyx.gpars.dataflow.DataflowWriteChannel; import nextflow.script.types.Channel; public interface WorkflowDsl extends DslScope { @@ -37,7 +35,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#branch) """) - Object branch(DataflowReadChannel source, Closure action); + Object branch(Channel source, Closure action); @Operator @Description(""" @@ -45,7 +43,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#buffer) """) - DataflowWriteChannel buffer(DataflowReadChannel source, Closure openingCondition, Closure closingCondition); + Channel buffer(Channel source, Closure openingCondition, Closure closingCondition); @Operator @Description(""" @@ -53,7 +51,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#collate) """) - DataflowWriteChannel collate(DataflowReadChannel source, int size, int step, boolean remainder); + Channel collate(Channel source, int size, int step, boolean remainder); @Operator @Description(""" @@ -61,7 +59,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#collect) """) - DataflowWriteChannel collect(DataflowReadChannel source, Closure action); + Channel collect(Channel source, Closure action); @Operator @Description(""" @@ -69,7 +67,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#collectfile) """) - DataflowWriteChannel collectFile(DataflowReadChannel source, Map opts, Closure closure); + Channel collectFile(Channel source, Map opts, Closure closure); @Operator @Description(""" @@ -77,7 +75,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#combine) """) - DataflowWriteChannel combine(DataflowReadChannel left, Map opts, Object right); + Channel combine(Channel left, Map opts, Object right); @Operator @Description(""" @@ -85,7 +83,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#concat) """) - DataflowWriteChannel concat(DataflowReadChannel source, DataflowReadChannel... others); + Channel concat(Channel source, Channel... others); @Operator @Description(""" @@ -93,7 +91,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#count) """) - DataflowWriteChannel count(DataflowReadChannel source); + Channel count(Channel source); @Operator @Description(""" @@ -101,7 +99,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#cross) """) - DataflowWriteChannel cross(DataflowReadChannel left, DataflowReadChannel right, Closure mapper); + Channel cross(Channel left, Channel right, Closure mapper); @Operator @Description(""" @@ -109,7 +107,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#distinct) """) - DataflowWriteChannel distinct(DataflowReadChannel source); + Channel distinct(Channel source); @Operator @Description(""" @@ -117,7 +115,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#dump) """) - DataflowWriteChannel dump(DataflowReadChannel source, Map opts); + Channel dump(Channel source, Map opts); @Operator @Description(""" @@ -125,7 +123,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#filter) """) - DataflowWriteChannel filter(DataflowReadChannel source, Closure closure); + Channel filter(Channel source, Closure closure); @Operator @Description(""" @@ -133,7 +131,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#first) """) - DataflowWriteChannel first(DataflowReadChannel source, Object criteria); + Channel first(Channel source, Object criteria); @Operator @Description(""" @@ -143,7 +141,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#flatmap) """) - DataflowWriteChannel flatMap(DataflowReadChannel source, Closure closure); + Channel flatMap(Channel source, Closure closure); @Operator @Description(""" @@ -151,7 +149,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#flatten) """) - DataflowWriteChannel flatten(DataflowReadChannel source); + Channel flatten(Channel source); @Operator @Description(""" @@ -159,7 +157,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#grouptuple) """) - DataflowWriteChannel groupTuple(DataflowReadChannel source, Map opts); + Channel groupTuple(Channel source, Map opts); @Operator @Description(""" @@ -167,7 +165,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#ifempty) """) - DataflowWriteChannel ifEmpty(DataflowReadChannel source, Object value); + Channel ifEmpty(Channel source, Object value); @Operator @Description(""" @@ -175,7 +173,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#join) """) - DataflowWriteChannel join(DataflowReadChannel left, DataflowReadChannel right); + Channel join(Channel left, Channel right); @Operator @Description(""" @@ -183,7 +181,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#last) """) - DataflowWriteChannel last(DataflowReadChannel source); + Channel last(Channel source); @Operator @Description(""" @@ -191,7 +189,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#map) """) - DataflowWriteChannel map(DataflowReadChannel source, Closure closure); + Channel map(Channel source, Closure closure); @Operator @Description(""" @@ -199,7 +197,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#max) """) - DataflowWriteChannel max(DataflowReadChannel source, Closure comparator); + Channel max(Channel source, Closure comparator); @Deprecated @Operator @@ -208,7 +206,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#merge) """) - DataflowWriteChannel merge(DataflowReadChannel source, DataflowReadChannel... others); + Channel merge(Channel source, Channel... others); @Operator @Description(""" @@ -216,7 +214,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#min) """) - DataflowWriteChannel min(DataflowReadChannel source, Closure comparator); + Channel min(Channel source, Closure comparator); @Operator @Description(""" @@ -224,7 +222,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#mix) """) - DataflowWriteChannel mix(DataflowReadChannel source, DataflowReadChannel... others); + Channel mix(Channel source, Channel... others); @Operator @Description(""" @@ -232,7 +230,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#multimap) """) - Object multiMap(DataflowReadChannel source, Closure action); + Object multiMap(Channel source, Closure action); @Operator @Description(""" @@ -240,7 +238,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#randomsample) """) - DataflowWriteChannel randomSample(DataflowReadChannel source, int n, Long seed); + Channel randomSample(Channel source, int n, Long seed); @Operator @Description(""" @@ -248,7 +246,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#reduce) """) - DataflowWriteChannel reduce(DataflowReadChannel source, Object seed, Closure closure); + Channel reduce(Channel source, Object seed, Closure closure); @Operator @Description(""" @@ -256,7 +254,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#set) """) - void set(DataflowReadChannel source, Closure holder); + void set(Channel source, Closure holder); @Operator @Description(""" @@ -264,7 +262,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitcsv) """) - DataflowWriteChannel splitCsv(DataflowReadChannel source, Map opts); + Channel splitCsv(Channel source, Map opts); @Operator @Description(""" @@ -272,7 +270,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitfasta) """) - DataflowWriteChannel splitFasta(DataflowReadChannel source, Map opts); + Channel splitFasta(Channel source, Map opts); @Operator @Description(""" @@ -280,7 +278,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitfastq) """) - DataflowWriteChannel splitFastq(DataflowReadChannel source, Map opts); + Channel splitFastq(Channel source, Map opts); @Operator @Description(""" @@ -288,7 +286,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#splittext) """) - DataflowWriteChannel splitText(DataflowReadChannel source, Map opts, Closure action); + Channel splitText(Channel source, Map opts, Closure action); @Operator @Description(""" @@ -296,7 +294,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#subscribe) """) - DataflowReadChannel subscribe(DataflowReadChannel source, Closure closure); + void subscribe(Channel source, Closure closure); @Operator @Description(""" @@ -304,7 +302,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#sum) """) - DataflowWriteChannel sum(DataflowReadChannel source, Closure closure); + Channel sum(Channel source, Closure closure); @Operator @Description(""" @@ -312,7 +310,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#take) """) - DataflowWriteChannel take(DataflowReadChannel source, int n); + Channel take(Channel source, int n); @Operator @Description(""" @@ -320,7 +318,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#to;ist) """) - DataflowWriteChannel toList(DataflowReadChannel source); + Channel toList(Channel source); @Operator @Description(""" @@ -328,7 +326,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#tosortedlist) """) - DataflowWriteChannel toSortedList(DataflowReadChannel source); + Channel toSortedList(Channel source); @Operator @Description(""" @@ -336,7 +334,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#transpose) """) - DataflowWriteChannel transpose(DataflowReadChannel source, Map opts); + Channel transpose(Channel source, Map opts); @Operator @Description(""" @@ -344,7 +342,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#unique) """) - DataflowWriteChannel unique(DataflowReadChannel source, Closure comparator); + Channel unique(Channel source, Closure comparator); @Operator @Description(""" @@ -352,7 +350,7 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#until) """) - DataflowWriteChannel until(DataflowReadChannel source, Closure closure); + Channel until(Channel source, Closure closure); @Operator @Description(""" @@ -360,6 +358,6 @@ public interface WorkflowDsl extends DslScope { [Read more](https://nextflow.io/docs/latest/reference/operator.html#view) """) - DataflowWriteChannel view(DataflowReadChannel source, Closure closure); + Channel view(Channel source, Closure closure); } diff --git a/modules/compiler/src/main/java/script/types/Channel.java b/modules/compiler/src/main/java/script/types/Channel.java index 3b5af78..67624c3 100644 --- a/modules/compiler/src/main/java/script/types/Channel.java +++ b/modules/compiler/src/main/java/script/types/Channel.java @@ -17,19 +17,19 @@ import java.nio.file.Path; import java.util.Collection; +import java.util.List; import java.util.Map; import groovy.lang.Closure; -import groovyx.gpars.dataflow.DataflowVariable; -import groovyx.gpars.dataflow.DataflowWriteChannel; import nextflow.script.dsl.Description; +import nextflow.script.dsl.Operator; @Description(""" The `Channel` type provides the channel factory methods. [Read more](https://nextflow.io/docs/latest/reference/channel.html) """) -public class Channel { +public abstract class Channel { protected static ChannelFactory instance; @@ -38,7 +38,7 @@ public class Channel { [Read more](https://nextflow.io/docs/latest/reference/channel.html#empty) """) - public static DataflowWriteChannel empty() { + public static Channel empty() { return instance.empty(); } @@ -48,7 +48,7 @@ public static DataflowWriteChannel empty() { [Read more](https://nextflow.io/docs/latest/reference/channel.html#from) """) - public static DataflowWriteChannel from(T... values) { + public static Channel from(T... values) { return instance.from(values); } @@ -58,7 +58,7 @@ public static DataflowWriteChannel from(T... values) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#from) """) - public static DataflowWriteChannel from(Collection values) { + public static Channel from(Collection values) { return instance.from(values); } @@ -69,7 +69,7 @@ public static DataflowWriteChannel from(Collection values) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#fromfilepairs) """) - public static DataflowWriteChannel fromFilePairs(Map opts, String pattern, Closure grouping) { + public static Channel fromFilePairs(Map opts, String pattern, Closure grouping) { return instance.fromFilePairs(opts, pattern, grouping); } @@ -78,7 +78,7 @@ public static DataflowWriteChannel fromFilePairs(Map opts, String patt [Read more](https://nextflow.io/docs/latest/reference/channel.html#fromlist) """) - public static DataflowWriteChannel fromList(Collection values) { + public static Channel fromList(Collection values) { return instance.fromList(values); } @@ -87,7 +87,7 @@ public static DataflowWriteChannel fromList(Collection values) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#frompath) """) - public static DataflowWriteChannel fromPath(Map opts, String pattern) { + public static Channel fromPath(Map opts, String pattern) { return instance.fromPath(opts, pattern); } @@ -96,7 +96,7 @@ public static DataflowWriteChannel fromPath(Map opts, String pat [Read more](https://nextflow.io/docs/latest/reference/channel.html#fromsra) """) - public static DataflowWriteChannel fromSRA(Map opts, String query) { + public static Channel fromSRA(Map opts, String query) { return instance.fromSRA(opts, query); } @@ -105,7 +105,7 @@ public static DataflowWriteChannel fromSRA(Map opts, String query) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#of) """) - public static DataflowWriteChannel of(T... values) { + public static Channel of(T... values) { return instance.of(values); } @@ -114,7 +114,7 @@ public static DataflowWriteChannel of(T... values) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#topic) """) - public static DataflowWriteChannel topic(String name) { + public static Channel topic(String name) { return instance.topic(name); } @@ -123,7 +123,7 @@ public static DataflowWriteChannel topic(String name) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#value) """) - public static DataflowVariable value(T value) { + public static Channel value(T value) { return instance.value(value); } @@ -132,8 +132,339 @@ public static DataflowVariable value(T value) { [Read more](https://nextflow.io/docs/latest/reference/channel.html#watchpath) """) - public static DataflowWriteChannel watchPath(String filePattern, String events) { + public static Channel watchPath(String filePattern, String events) { return instance.watchPath(filePattern, events); } + @Operator + @Description(""" + The `branch` operator forwards each value from a source channel to one of multiple output channels, based on a selection criteria. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#branch) + """) + public abstract Object branch(Closure action); + + @Operator + @Description(""" + The `buffer` operator collects values from a source channel into subsets and emits each subset separately. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#buffer) + """) + public abstract Channel buffer(Closure openingCondition, Closure closingCondition); + + @Operator + @Description(""" + The `collate` operator collects values from a source channel into groups of *N* values. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#collate) + """) + public abstract Channel collate(int size, int step, boolean remainder); + + @Operator + @Description(""" + The `collect` operator collects all values from a source channel into a list and emits it as a single value. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#collect) + """) + public abstract Channel collect(Closure action); + + @Operator + @Description(""" + The `collectFile` operator collects the values from a source channel and saves them to one or more files, emitting the collected file(s). + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#collectfile) + """) + public abstract Channel collectFile(Map opts, Closure closure); + + @Operator + @Description(""" + The `combine` operator produces the combinations (i.e. cross product, “Cartesian” product) of two source channels, or a channel and a list (as the right operand), emitting each combination separately. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#combine) + """) + public abstract Channel combine(Map opts, Object right); + + @Operator + @Description(""" + The `concat` operator emits the values from two or more source channels into a single output channel. Each source channel is emitted in the order in which it was specified. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#concat) + """) + public abstract Channel concat(Channel... others); + + @Operator + @Description(""" + The `count` operator computes the total number of values from a source channel and emits it. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#count) + """) + public abstract Channel count(); + + @Operator + @Description(""" + The `cross` operator emits every pairwise combination of two channels for which the pair has a matching key. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#cross) + """) + public abstract Channel cross(Channel right, Closure mapper); + + @Operator + @Description(""" + The `distinct` operator forwards a source channel with consecutively repeated values removed, such that each emitted value is different from the preceding one. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#distinct) + """) + public abstract Channel distinct(); + + @Operator + @Description(""" + When the pipeline is executed with the `-dump-channels` command-line option, the `dump` operator prints each value in a source channel, otherwise it does nothing. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#dump) + """) + public abstract Channel dump(Map opts); + + @Operator + @Description(""" + The `filter` operator emits the values from a source channel that satisfy a condition, discarding all other values. The filter condition can be a literal value, a regular expression, a type qualifier, or a boolean predicate. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#filter) + """) + public abstract Channel filter(Closure closure); + + @Operator + @Description(""" + The `first` operator emits the first value from a source channel, or the first value that satisfies a condition. The condition can be a regular expression, a type qualifier (i.e. Java class), or a boolean predicate. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#first) + """) + public abstract Channel first(Object criteria); + + @Operator + @Description(""" + The `flatMap` operator applies a mapping function to each value from a source channel. + + When the mapping function returns a list, each element in the list is emitted separately. When the mapping function returns a map, each key-value pair in the map is emitted separately. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#flatmap) + """) + public abstract Channel flatMap(Closure closure); + + @Operator + @Description(""" + The `flatten` operator flattens each value from a source channel that is a list or other collection, such that each element in each collection is emitted separately. Deeply nested collections are also flattened. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#flatten) + """) + public abstract Channel flatten(); + + @Operator + @Description(""" + The `groupTuple` operator collects tuples from a source channel into groups based on a grouping key. A new tuple is emitted for each distinct key. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#grouptuple) + """) + public abstract Channel groupTuple(Map opts); + + @Operator + @Description(""" + The `ifEmpty` operator emits a source channel, or a default value if the source channel is empty. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#ifempty) + """) + public abstract Channel ifEmpty(Object value); + + @Operator + @Description(""" + The `join` operator emits the inner product of two source channels using a matching key. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#join) + """) + public abstract Channel join(Channel right); + + @Operator + @Description(""" + The `last` operator emits the last value from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#last) + """) + public abstract Channel last(); + + @Operator + @Description(""" + The `map` operator applies a mapping function to each value from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#map) + """) + public abstract Channel map(Closure closure); + + @Operator + @Description(""" + The `max` operator emits the item with the greatest value from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#max) + """) + public abstract Channel max(Closure comparator); + + @Deprecated + @Operator + @Description(""" + The `merge` operator joins the values from two or more channels into a new channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#merge) + """) + public abstract Channel merge(Channel... others); + + @Operator + @Description(""" + The `min` operator emits the item with the lowest value from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#min) + """) + public abstract Channel min(Closure comparator); + + @Operator + @Description(""" + The `mix` operator emits the values from two or more source channels into a single output channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#mix) + """) + public abstract Channel mix(Channel... others); + + @Operator + @Description(""" + The `multiMap` operator applies a set of mapping functions to a source channel, producing a separate output channel for each mapping function. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#multimap) + """) + public abstract Object multiMap(Closure action); + + @Operator + @Description(""" + The `randomSample` operator emits a randomly-selected subset of values from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#randomsample) + """) + public abstract Channel randomSample(int n, Long seed); + + @Operator + @Description(""" + The `reduce` operator applies an accumulator function sequentially to each value from a source channel, and emits the accumulated value. The accumulator function takes two parameters -- the accumulated value and the *i*-th emitted value -- and it should return the accumulated result, which is passed to the next invocation with the *i+1*-th value. This process is repeated for each value in the source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#reduce) + """) + public abstract Channel reduce(Object seed, Closure closure); + + @Operator + @Description(""" + The `set` operator assigns a source channel to a variable, whose name is specified in a closure. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#set) + """) + public abstract void set(Closure holder); + + @Operator + @Description(""" + The `splitCsv` operator parses and splits [CSV-formatted](http://en.wikipedia.org/wiki/Comma-separated_values) text from a source channel into records, or groups of records with a given size. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitcsv) + """) + public abstract Channel splitCsv(Map opts); + + @Operator + @Description(""" + The `splitFasta` operator splits [FASTA formatted](http://en.wikipedia.org/wiki/FASTA_format) text from a source channel into individual sequences. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitfasta) + """) + public abstract Channel splitFasta(Map opts); + + @Operator + @Description(""" + The `splitFastq` operator splits [FASTQ formatted](http://en.wikipedia.org/wiki/FASTQ_format) text from a source channel into individual sequences. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#splitfastq) + """) + public abstract Channel splitFastq(Map opts); + + @Operator + @Description(""" + The `splitText` operator splits multi-line text content from a source channel into chunks of *N* lines. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#splittext) + """) + public abstract Channel splitText(Map opts, Closure action); + + @Operator + @Description(""" + The `subscribe` operator invokes a custom function for each value in a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#subscribe) + """) + public abstract void subscribe(Closure closure); + + @Operator + @Description(""" + The `sum` operator emits the sum of all values in a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#sum) + """) + public abstract Channel sum(Closure closure); + + @Operator + @Description(""" + The `take` operator takes the first *N* values from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#take) + """) + public abstract Channel take(int n); + + @Operator + @Description(""" + The `toList` operator collects all the values from a source channel into a list and emits the list as a single value. + + public abstract [Read more](https://nextflow.io/docs/latest/reference/operator.html#to;ist) + """) + public abstract Channel toList(); + + @Operator + @Description(""" + The `toSortedList` operator collects all the values from a source channel into a sorted list and emits the list as a single value. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#tosortedlist) + """) + public abstract Channel toSortedList(); + + @Operator + @Description(""" + The `transpose` operator transposes each tuple from a source channel by flattening any nested list in each tuple, emitting each nested value separately. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#transpose) + """) + public abstract Channel transpose(Map opts); + + @Operator + @Description(""" + The `unique` operator emits the unique values from a source channel. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#unique) + """) + public abstract Channel unique(Closure comparator); + + @Operator + @Description(""" + The `until` operator emits each value from a source channel until a stopping condition is satisfied. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#until) + """) + public abstract Channel until(Closure closure); + + @Operator + @Description(""" + The `view` operator prints each value from a source channel to standard output. + + [Read more](https://nextflow.io/docs/latest/reference/operator.html#view) + """) + public abstract Channel view(Closure closure); + } diff --git a/modules/compiler/src/main/java/script/types/ChannelFactory.java b/modules/compiler/src/main/java/script/types/ChannelFactory.java index 2ea570d..c103522 100644 --- a/modules/compiler/src/main/java/script/types/ChannelFactory.java +++ b/modules/compiler/src/main/java/script/types/ChannelFactory.java @@ -20,31 +20,29 @@ import java.util.Map; import groovy.lang.Closure; -import groovyx.gpars.dataflow.DataflowVariable; -import groovyx.gpars.dataflow.DataflowWriteChannel; public interface ChannelFactory { - DataflowWriteChannel empty(); + Channel empty(); - DataflowWriteChannel from(T... values); + Channel from(T... values); - DataflowWriteChannel from(Collection values); + Channel from(Collection values); - DataflowWriteChannel fromFilePairs(Map opts, String pattern, Closure grouping); + Channel fromFilePairs(Map opts, String pattern, Closure grouping); - DataflowWriteChannel fromList(Collection values); + Channel fromList(Collection values); - DataflowWriteChannel fromPath(Map opts, String pattern); + Channel fromPath(Map opts, String pattern); - DataflowWriteChannel fromSRA(Map opts, String query); + Channel fromSRA(Map opts, String query); - DataflowWriteChannel of(T... values); + Channel of(T... values); - DataflowWriteChannel topic(String name); + Channel topic(String name); - DataflowVariable value(T value); + Channel value(T value); - DataflowWriteChannel watchPath(String filePattern, String events); + Channel watchPath(String filePattern, String events); } diff --git a/modules/compiler/src/main/java/script/types/Types.java b/modules/compiler/src/main/java/script/types/Types.java index f6197bd..fc761a1 100644 --- a/modules/compiler/src/main/java/script/types/Types.java +++ b/modules/compiler/src/main/java/script/types/Types.java @@ -30,12 +30,8 @@ public class Types { ); public static String normalize(String name) { - if( "DataflowReadChannel".equals(name) ) - return "Channel"; - if( "DataflowWriteChannel".equals(name) ) - return "Channel"; - if( "DataflowVariable".equals(name) ) - return "Channel"; + if( "Object".equals(name) ) + return "?"; return name; }