-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool+cwl spec to flatten a list of lists of files
- Loading branch information
Janneke van der Zwaan
committed
Oct 9, 2018
1 parent
3c0c8b5
commit db01d3f
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python | ||
import click | ||
import json | ||
import codecs | ||
import itertools | ||
|
||
|
||
@click.command() | ||
def command(): | ||
with codecs.open('files.json', encoding='utf-8') as data: | ||
list_of_lists = json.load(data) | ||
|
||
flattened = list(itertools.chain(*list_of_lists)) | ||
|
||
stdout_text = click.get_text_stream('stdout') | ||
stdout_text.write(json.dumps({'out_files': flattened})) | ||
|
||
|
||
if __name__ == '__main__': | ||
command() |
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,27 @@ | ||
#!/usr/bin/env cwlrunner | ||
cwlVersion: v1.0 | ||
class: CommandLineTool | ||
baseCommand: ["python", "-m", "nlppln.commands.flatten_list"] | ||
requirements: | ||
InlineJavascriptRequirement: {} | ||
InitialWorkDirRequirement: | ||
listing: | ||
- entryname: files.json | ||
entry: $(JSON.stringify(inputs.list)) | ||
|
||
inputs: | ||
list: | ||
type: | ||
type: array | ||
items: | ||
type: array | ||
items: File | ||
|
||
|
||
stdout: cwl.output.json | ||
|
||
outputs: | ||
out_files: | ||
type: File[] | ||
outputBinding: | ||
glob: "*" |