diff --git a/steps/create_workflow_input.cwl b/steps/create_workflow_input.cwl new file mode 100644 index 0000000000000000000000000000000000000000..386de100034cd8518db7639ce2a9a65a0c1b1693 --- /dev/null +++ b/steps/create_workflow_input.cwl @@ -0,0 +1,42 @@ +$namespaces: + sbg: 'https://www.sevenbridges.com/' +id: create_workflow_input +label: create_workflow_input +class: CommandLineTool +cwlVersion: v1.0 +inputs: + - id: msin + type: Directory[] + inputBinding: + position: 0 + +outputs: + - id: output + type: File + outputBinding: + glob: workflow_input.json + +baseCommand: + - python3 + - script.py +doc: '' +requirements: + InitialWorkDirRequirement: + listing: + - entryname: script.py + entry: | + #!/usr/bin/env python3 + + import sys + import json + import os + dir_list = sys.argv[1:] + rendered_leafs = [] + + for dir in dir_list: + file_name = dir.split(os.path.sep)[-1] + rendered_leaf = {'class': 'Directory', 'path': file_name} + rendered_leafs.append(rendered_leaf) + + with open('workflow_input.json', 'w') as fp: + json.dump({'msin': rendered_leafs}, fp) \ No newline at end of file diff --git a/steps/read_surl_list.cwl b/steps/read_surl_list.cwl new file mode 100644 index 0000000000000000000000000000000000000000..b1527d08845a46d2bc037dc98084d4fb8b7a85b3 --- /dev/null +++ b/steps/read_surl_list.cwl @@ -0,0 +1,23 @@ +class: ExpressionTool +cwlVersion: v1.0 +id: read_surl_file +inputs: + - id: surl_list + type: File + doc: input surl file + inputBinding: + loadContents: True +outputs: + - id: surls + type: string[] + +expression: | + ${ + var surl_list = inputs.surl_list.contents.split("\n"); + surl_list = surl_list.filter(function (el) { return el != ''; } ); + return {'surls': surl_list} + } +label: ReadSurlList + +requirements: + - class: InlineJavascriptRequirement diff --git a/steps/surl_copy.cwl b/steps/surl_copy.cwl new file mode 100644 index 0000000000000000000000000000000000000000..0f660b608fa225b630ec3ee68ed77eb4cb560a8f --- /dev/null +++ b/steps/surl_copy.cwl @@ -0,0 +1,19 @@ +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + sbg: 'https://www.sevenbridges.com/' +id: surl_copy +baseCommand: + - gfal-copy +inputs: + - id: surl + type: string + inputBinding: + position: 0 +outputs: + - id: output + type: File + outputBinding: + glob: '*' +doc: Download a file give a surl +label: surl_copy diff --git a/steps/untar.cwl b/steps/untar.cwl new file mode 100644 index 0000000000000000000000000000000000000000..55d02a9d7e4d3b154312c21c7ef6980d6410ccb8 --- /dev/null +++ b/steps/untar.cwl @@ -0,0 +1,30 @@ +id: untar +label: untar +class: CommandLineTool +cwlVersion: v1.0 +inputs: + - id: tar_file + type: File + inputBinding: + position: 0 + +outputs: + - id: uncompressed + type: Directory + outputBinding: + glob: 'out/*' +baseCommand: + - 'bash' + - 'untar.sh' +doc: 'Untar a compressed file' +requirements: + InitialWorkDirRequirement: + listing: + - entryname: 'untar.sh' + entry: | + #!/bin/bash + mkdir out + cd out + tar -xvf $1 + + diff --git a/workflows/dowload_surl_and_create_input_file-json.cwl b/workflows/dowload_surl_and_create_input_file-json.cwl new file mode 100644 index 0000000000000000000000000000000000000000..b5c945faf4f6609b5db5454067318fb8d07b2cf9 --- /dev/null +++ b/workflows/dowload_surl_and_create_input_file-json.cwl @@ -0,0 +1,72 @@ +class: Workflow +cwlVersion: v1.0 +id: dowload_surl_and_create_input_file_json +label: dowload_surl_and_create_input_file.json +$namespaces: + sbg: 'https://www.sevenbridges.com/' +inputs: + - id: surl_list + type: File + 'sbg:x': -329.7890625 + 'sbg:y': -35 +outputs: + - id: msin + outputSource: + - untar/uncompressed + type: Directory + 'sbg:x': 632 + 'sbg:y': -72 + - id: workflow_configuration + outputSource: + - create_workflow_input/output + type: File + 'sbg:x': 663 + 'sbg:y': 137 +steps: + - id: read_surl_list + in: + - id: surl_list + source: surl_list + out: + - id: surls + run: ../steps/read_surl_list.cwl + label: ReadSurlList + 'sbg:x': -90 + 'sbg:y': -13 + - id: surl_copy + in: + - id: surl + source: read_surl_list/surls + out: + - id: output + run: ../steps/surl_copy.cwl + label: surl_copy + scatter: + - surl + 'sbg:x': 170 + 'sbg:y': -10 + - id: untar + in: + - id: tar_file + source: surl_copy/output + out: + - id: uncompressed + run: ../steps/untar.cwl + label: untar + scatter: + - tar_file + 'sbg:x': 376 + 'sbg:y': -12 + - id: create_workflow_input + in: + - id: msin + source: + - untar/uncompressed + out: + - id: output + run: ../steps/create_workflow_input.cwl + label: create_workflow_input + 'sbg:x': 475 + 'sbg:y': 135 +requirements: + - class: ScatterFeatureRequirement