-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #556 from viash-io/develop
Viash 0.8.0-RC3
- Loading branch information
Showing
26 changed files
with
529 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name := "viash" | ||
|
||
version := "0.8.0-RC2" | ||
version := "0.8.0-RC3" | ||
|
||
scalaVersion := "2.13.10" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/resources/io/viash/platforms/nextflow/arguments/_processInputValues.nf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Map _processInputValues(Map inputs, Map config, String id, String key) { | ||
if (!workflow.stubRun) { | ||
config.functionality.allArguments.each { arg -> | ||
if (arg.required) { | ||
assert inputs.containsKey(arg.plainName) && inputs.get(arg.plainName) != null : | ||
"Error in module '${key}' id '${id}': required input argument '${arg.plainName}' is missing" | ||
} | ||
} | ||
|
||
inputs = inputs.collectEntries { name, value -> | ||
def par = config.functionality.allArguments.find { it.plainName == name && (it.direction == "input" || it.type == "file") } | ||
assert par != null : "Error in module '${key}' id '${id}': '${name}' is not a valid input argument" | ||
|
||
value = _checkArgumentType("input", par, value, id, key) | ||
|
||
[ name, value ] | ||
} | ||
} | ||
return inputs | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/io/viash/platforms/nextflow/arguments/_processOutputValues.nf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Map _processOutputValues(Map outputs, Map config, String id, String key) { | ||
if (!workflow.stubRun) { | ||
config.functionality.allArguments.each { arg -> | ||
if (arg.direction == "output" && arg.required) { | ||
assert outputs.containsKey(arg.plainName) && outputs.get(arg.plainName) != null : | ||
"Error in module '${key}' id '${id}': required output argument '${arg.plainName}' is missing" | ||
} | ||
} | ||
|
||
outputs = outputs.collectEntries { name, value -> | ||
def par = config.functionality.allArguments.find { it.plainName == name && it.direction == "output" } | ||
assert par != null : "Error in module '${key}' id '${id}': '${name}' is not a valid output argument" | ||
|
||
value = _checkArgumentType("output", par, value, id, key) | ||
|
||
[ name, value ] | ||
} | ||
} | ||
return outputs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/resources/io/viash/platforms/nextflow/channel/runEach.nf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Run a list of components on a stream of data. | ||
* | ||
* @param components: list of Viash VDSL3 modules to run | ||
* @param fromState: a closure, a map or a list of keys to extract from the input data. | ||
* If a closure, it will be called with the id, the data and the component itself. | ||
* @param toState: a closure, a map or a list of keys to extract from the output data | ||
* If a closure, it will be called with the id, the output data, the old state and the component itself. | ||
* @param filter: filter function to apply to the input. | ||
* It will be called with the id, the data and the component itself. | ||
* @param id: id to use for the output data | ||
* If a closure, it will be called with the id, the data and the component itself. | ||
* @param auto: auto options to pass to the components | ||
* | ||
* @return: a workflow that runs the components | ||
**/ | ||
def runEach(Map args) { | ||
assert args.components: "runEach should be passed a list of components to run" | ||
|
||
def components_ = args.components | ||
if (components_ !instanceof List) { | ||
components_ = [ components_ ] | ||
} | ||
assert components_.size() > 0: "pass at least one component to runEach" | ||
|
||
def fromState_ = args.fromState | ||
def toState_ = args.toState | ||
def filter_ = args.filter | ||
def id_ = args.id | ||
|
||
workflow runEachWf { | ||
take: input_ch | ||
main: | ||
|
||
// generate one channel per method | ||
out_chs = components_.collect{ comp_ -> | ||
filter_ch = filter_ | ||
? input_ch | filter{tup -> | ||
filter_(tup[0], tup[1], comp_) | ||
} | ||
: input_ch | ||
id_ch = id_ | ||
? filter_ch | map{tup -> | ||
// def new_id = id_(tup[0], tup[1], comp_) | ||
def new_id = tup[0] | ||
if (id_ instanceof String) { | ||
new_id = id_ | ||
} else if (id_ instanceof Closure) { | ||
new_id = id_(new_id, tup[1], comp_) | ||
} | ||
[new_id] + tup.drop(1) | ||
} | ||
: filter_ch | ||
data_ch = id_ch | map{tup -> | ||
def new_data = tup[1] | ||
if (fromState_ instanceof Map) { | ||
new_data = fromState_.collectEntries{ key0, key1 -> | ||
[key0, new_data[key1]] | ||
} | ||
} else if (fromState_ instanceof List) { | ||
new_data = fromState_.collectEntries{ key -> | ||
[key, new_data[key]] | ||
} | ||
} else if (fromState_ instanceof Closure) { | ||
new_data = fromState_(tup[0], new_data, comp_) | ||
} | ||
tup.take(1) + [new_data] + tup.drop(1) | ||
} | ||
out_ch = data_ch | ||
| comp_.run( | ||
auto: (args.auto ?: [:]) + [simplifyInput: false, simplifyOutput: false] | ||
) | ||
post_ch = toState_ | ||
? out_ch | map{tup -> | ||
def output = tup[1] | ||
def old_state = tup[2] | ||
if (toState_ instanceof Map) { | ||
new_state = old_state + toState_.collectEntries{ key0, key1 -> | ||
[key0, output[key1]] | ||
} | ||
} else if (toState_ instanceof List) { | ||
new_state = old_state + toState_.collectEntries{ key -> | ||
[key, output[key]] | ||
} | ||
} else if (toState_ instanceof Closure) { | ||
new_state = toState_(tup[0], output, old_state, comp_) | ||
} | ||
[tup[0], new_state] + tup.drop(3) | ||
} | ||
: out_ch | ||
|
||
post_ch | ||
} | ||
|
||
// mix all results | ||
output_ch = | ||
(out_chs.size == 1) | ||
? out_chs[0] | ||
: out_chs[0].mix(*out_chs.drop(1)) | ||
|
||
emit: output_ch | ||
} | ||
|
||
return runEachWf | ||
} |
Oops, something went wrong.