Skip to content
Snippets Groups Projects
Commit d881ceff authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Add steps and test

Former-commit-id: e793a1ff
parent a45b8868
No related branches found
No related tags found
No related merge requests found
class: CommandLineTool
cwlVersion: v1.0
id: filter_ms_group
baseCommand:
- python3
arguments:
- position: 0
valueFrom: script.py
inputs:
- id: group_id
type: string
- id: groups_specification
type: File
inputBinding:
position: 1
- id: measurement_sets
type: 'Directory[]'
inputBinding:
position: 2
outputs:
- id: output
type: 'Directory[]?'
outputBinding:
loadContents: true
glob: selected_ms.json
outputEval: '$(JSON.parse(self[0].contents))'
label: filter_ms_group
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: script.py
entry: |
import sys
import json
import os.path as path
group_id = "$(inputs.group_id)"
json_file = sys.argv[1]
ms_list = sys.argv[2:]
ms_by_name = { ms.split(path.sep)[-1]:
{'class':'Directory', 'path': ms} for ms in ms_list}
output_file = 'selected_ms.json'
with open(json_file, 'r') as f_stream:
selected_ms = json.load(f_stream)[group_id]
print(selected_ms, ms_by_name)
selected_ms = [ms_by_name[ms_name] for ms_name in selected_ms]
with open(output_file, 'w') as f_stream:
json.dump(selected_ms, f_stream)
{
"group_id": "1",
"groups_specification": {"class": "File", "path": "groups_spec.json"},
"measurement_sets": [
{"class": "Directory", "path": "empty_dirs/ms1"},
{"class": "Directory", "path": "empty_dirs/ms2"},
{"class": "Directory", "path": "empty_dirs/ms3"},
{"class": "Directory", "path": "empty_dirs/ms5"}]
}
{
"1": ["ms1", "ms2"],
"2": ["ms3", "ms5"]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment