Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 2132c47

Browse files
committed
remove id field from input and output and change order of attributes
1 parent a51680f commit 2132c47

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

cwlgen/__init__.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
CWL_VERSIONS = ['draft-2', 'draft-3.dev1', 'draft-3.dev2', 'draft-3.dev3',
2525
'draft-3.dev4', 'draft-3.dev5', 'draft-3', 'draft-4.dev1',
2626
'draft-4.dev2', 'draft-4.dev3', 'v1.0.dev4', 'v1.0', None]
27+
DEF_VERSION = 'v1.0'
2728
CWL_TYPE = ['null', 'boolean', 'int', 'long', 'float', 'double', 'string', 'File',
2829
'Directory', None]
2930

@@ -37,6 +38,8 @@ class CommandLineTool(object):
3738
Contain all informations to describe a CWL command line tool.
3839
'''
3940

41+
__CLASS__ = 'CommandLineTool'
42+
4043
def __init__(self, tool_id=None, base_command=None, label=None, doc=None,
4144
cwl_version=None, stdin=None, stderr=None, stdout=None):
4245
'''
@@ -63,22 +66,22 @@ def __init__(self, tool_id=None, base_command=None, label=None, doc=None,
6366
and requirements (:class:`cwlgen.Requirement` objects)
6467
are stored in lists which are initialized empty.
6568
'''
66-
self.id = tool_id
67-
self.baseCommand = base_command
68-
self.label = label
69-
self.doc = doc
7069
if cwl_version not in CWL_VERSIONS:
7170
LOGGER.warning("CWL version is not recognized as a valid version.")
72-
cwl_version = None
71+
cwl_version = DEF_VERSION
7372
self.cwlVersion = cwl_version
74-
self.stdin = stdin
75-
self.stderr = stderr
76-
self.stdout = stdout
73+
self.id = tool_id
74+
self.label = label
75+
self.requirements = [] # List of Several object inhereting from [Requirement]
76+
self.hints = []
7777
self.inputs = [] # List of [CommandInputParameter] objects
7878
self.outputs = [] # List of [CommandOutputParameter] objects
79+
self.baseCommand = base_command
7980
self.arguments = [] # List of [CommandLineBinding] objects
80-
self.requirements = [] # List of Several object inhereting from [Requirement]
81-
self.hints = []
81+
self.doc = doc
82+
self.stdin = stdin
83+
self.stderr = stderr
84+
self.stdout = stdout
8285
self.successCodes = []
8386
self.temporaryFailCodes = []
8487
self.permanentFailCodes = []
@@ -88,7 +91,7 @@ def export(self, outfile=None):
8891
Export the tool in CWL either on STDOUT or in outfile.
8992
'''
9093
cwl_tool = {k: v for k, v in vars(self).items() if v is not None and v != []}
91-
cwl_tool['class'] = 'CommandLineTool'
94+
cwl_tool['class'] = self.__CLASS__
9295
# Add Inputs
9396
if self.inputs:
9497
cwl_tool['inputs'] = {}
@@ -209,6 +212,7 @@ def get_dict(self):
209212
:rtype: DICT
210213
'''
211214
dict_in = Parameter.get_dict(self)
215+
del dict_in['id']
212216
if self.inputBinding:
213217
dict_in['inputBinding'] = self.inputBinding.get_dict()
214218
return dict_in
@@ -253,6 +257,7 @@ def get_dict(self):
253257
:rtype: DICT
254258
'''
255259
dict_out = Parameter.get_dict(self)
260+
del dict_out['id']
256261
if self.outputBinding:
257262
dict_out['outputBinding'] = self.outputBinding.get_dict()
258263
return dict_out

examples/example.cwl

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
#!/usr/bin/env cwl-runner
22

3-
cwlVersion: v1.0
43
id: my_tool
54
label: my_tool is magic
6-
baseCommand: run_my_tool
7-
class: CommandLineTool
8-
doc: Magic is no magic without secrets...
95
inputs:
106
config_file:
11-
type: File
12-
doc: config file
137
format: http://edamontology.org/format_2330
8+
doc: config file
9+
type: File
1410
inputBinding:
1511
position: 1
1612
threads:
17-
type: int
1813
doc: number of threads
14+
type: int
1915
inputBinding:
2016
prefix: -t
2117
outputs:
2218
result_file:
23-
type: File
24-
doc: magic results
2519
format: http://edamontology.org/format_2330
20+
doc: magic results
21+
type: File
2622
outputBinding:
2723
glob: counts.txt
24+
baseCommand: run_my_tool
25+
doc: Magic is no magic without secrets...
26+
class: CommandLineTool

0 commit comments

Comments
 (0)