Skip to content

Commit

Permalink
Remove as much as possible from state management code
Browse files Browse the repository at this point in the history
  • Loading branch information
tverbeiren committed Jan 5, 2024
1 parent 0926bc2 commit 24f41a4
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/workflows/demo_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,28 @@ workflow run_wf {

// Turn the Channel event with list of files
// into multiple Channel events with one file.
| expand.run(
fromState: { id, state -> state },
toState: {id, result, state ->
_mergeMap(state, [ expanded: result.output ])
}
)
| expand

// Remove comments from each TSV input file
| remove_comments.run(
fromState: { id, state -> [ input: state.expanded ] },
toState: { id, result, state ->
_mergeMap(state, [ remove_comments: result.output ] ) }
fromState: [ input: "output" ],
)

// Extract single column from each TSV
| take_column.run(
fromState: { id, state -> [ input: state.remove_comments ] },
toState: {id, result, state ->
_mergeMap(state, [ take_column: result.output ])
}
fromState: [ input: "output" ],
)

// Custom toSortedList
| vsh_toList.run (
fromState: { id, state -> [ id: "run", input: state.take_column ] },
toState: { id, result, state -> result }
| vsh_toList.run(
args: [ id: "run" ],
fromState: [ input: "output" ],
)

// Concatenate TSVs into one
| combine_columns.run(
auto: [ publish: true ],
fromState: { id, state -> [ input: state.output ] },
toState: { id, result, state -> result }
fromState: [ input: "output" ],
)

// View channel contents
Expand Down

0 comments on commit 24f41a4

Please sign in to comment.