Skip to content

Commit 6f9e73e

Browse files
committed
Handle cases where the WDL workflow output contains exprs
1 parent 2ae6ad9 commit 6f9e73e

File tree

4 files changed

+550
-3
lines changed

4 files changed

+550
-3
lines changed

wdl2cwl/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,11 @@ def get_workflow_outputs(
722722
with WDLSourceLine(item.info, ConversionException):
723723
output_name = item.name
724724
item_expr = item.info.expr
725-
output_source = item_expr.expr.name[::-1].replace(".", "/", 1)[::-1]
725+
if isinstance(item_expr, WDL.Expr.Get):
726+
output_source = item_expr.expr.name[::-1].replace(".", "/", 1)[::-1]
727+
else:
728+
output_source = f"$({self.get_expr(item_expr)})"
729+
726730
# replace just the last occurrence of a period with a slash
727731
# by first reversing the string and the replace the first occurrence
728732
# then reversing the result
@@ -1019,14 +1023,14 @@ def get_expr_get(self, wdl_get_expr: WDL.Expr.Get) -> str:
10191023

10201024
def get_expr_ident(self, wdl_ident_expr: WDL.Expr.Ident) -> str:
10211025
"""Translate WDL Ident Expressions."""
1022-
id_name = wdl_ident_expr.name
1026+
id_name: str = wdl_ident_expr.name
10231027
referee = wdl_ident_expr.referee
10241028
optional = wdl_ident_expr.type.optional
10251029
if referee:
10261030
with WDLSourceLine(referee, ConversionException):
10271031
if isinstance(referee, WDL.Tree.Call):
10281032
return id_name
1029-
if referee.expr and (
1033+
if hasattr(referee, 'expr') and referee.expr is not None and (
10301034
wdl_ident_expr.name in self.optional_cwl_null
10311035
or wdl_ident_expr.name not in self.non_static_values
10321036
):

wdl2cwl/tests/cwl_files/blast.cwl

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
cwlVersion: v1.2
2+
id: blast
3+
class: Workflow
4+
requirements:
5+
- class: InlineJavascriptRequirement
6+
inputs:
7+
- id: blast_docker_override
8+
type:
9+
- string
10+
- 'null'
11+
- id: blast_docker
12+
type:
13+
- string
14+
- 'null'
15+
- id: queryfa
16+
type: File
17+
- id: fname
18+
default: /sfs/blastdb/2019_ncov/nucl/v6/ncov
19+
type: string
20+
- id: method
21+
default: blastn
22+
type: string
23+
- id: outfmt
24+
default: 7
25+
type: int
26+
- id: evalue
27+
default: 10.0
28+
type: float
29+
- id: Outfile
30+
type:
31+
- string
32+
- 'null'
33+
- id: threads
34+
default: 8
35+
type: int
36+
- id: runblastp.max_target_seqs
37+
default: 100
38+
type: int
39+
- id: runblastp.word_size
40+
default: 6
41+
type: int
42+
- id: runblastp.seg
43+
default: no
44+
type: string
45+
- id: runblastp.comp_based_stats
46+
default: '2'
47+
type: string
48+
- id: runblastp.matrix
49+
default: BLOSUM62
50+
type: string
51+
- id: runblastp.gapopen
52+
default: 11
53+
type: int
54+
- id: runblastp.gapextend
55+
default: 1
56+
type: int
57+
- id: runblastp.max_hsps
58+
type:
59+
- int
60+
- 'null'
61+
- id: runblastp.taxids
62+
type:
63+
- string
64+
- 'null'
65+
- id: runblastp.negative_taxids
66+
type:
67+
- string
68+
- 'null'
69+
- id: runblastp.lcase_masking
70+
default: false
71+
type: boolean
72+
- id: runblastn.max_target_seqs
73+
default: 100
74+
type: int
75+
- id: runblastn.word_size
76+
default: 28
77+
type: int
78+
- id: runblastn.reward
79+
default: 1
80+
type: int
81+
- id: runblastn.penalty
82+
default: -2
83+
type: int
84+
- id: runblastn.strand
85+
default: both
86+
type: string
87+
- id: runblastn.gapopen
88+
default: 0
89+
type: int
90+
- id: runblastn.gapextend
91+
default: 0
92+
type: int
93+
- id: runblastn.dust
94+
default: "'20 64 1'"
95+
type: string
96+
- id: runblastn.max_hsps
97+
type:
98+
- int
99+
- 'null'
100+
- id: runblastn.tasks
101+
default: megablast
102+
type: string
103+
- id: runblastn.taxids
104+
type:
105+
- string
106+
- 'null'
107+
- id: runblastn.negative_taxids
108+
type:
109+
- string
110+
- 'null'
111+
- id: runblastn.lcase_masking
112+
default: false
113+
type: boolean
114+
- id: runblastx.max_target_seqs
115+
default: 100
116+
type: int
117+
- id: runblastx.word_size
118+
default: 6
119+
type: int
120+
- id: runblastx.seg
121+
default: "'12 2.2 2.5'"
122+
type: string
123+
- id: runblastx.comp_based_stats
124+
default: '2'
125+
type: string
126+
- id: runblastx.matrix
127+
default: BLOSUM62
128+
type: string
129+
- id: runblastx.gapopen
130+
default: 11
131+
type: int
132+
- id: runblastx.gapextend
133+
default: 1
134+
type: int
135+
- id: runblastx.taxids
136+
type:
137+
- string
138+
- 'null'
139+
- id: runblastx.negative_taxids
140+
type:
141+
- string
142+
- 'null'
143+
- id: runblastx.max_hsps
144+
type:
145+
- int
146+
- 'null'
147+
- id: runblastx.lcase_masking
148+
default: false
149+
type: boolean
150+
- id: runtblastn.max_target_seqs
151+
default: 100
152+
type: int
153+
- id: runtblastn.word_size
154+
default: 6
155+
type: int
156+
- id: runtblastn.seg
157+
default: "'12 2.2 2.5'"
158+
type: string
159+
- id: runtblastn.comp_based_stats
160+
default: '2'
161+
type: string
162+
- id: runtblastn.matrix
163+
default: BLOSUM62
164+
type: string
165+
- id: runtblastn.gapopen
166+
default: 11
167+
type: int
168+
- id: runtblastn.gapextend
169+
default: 1
170+
type: int
171+
- id: runtblastn.lcase_masking
172+
default: false
173+
type: boolean
174+
- id: runtblastn.max_hsps
175+
type:
176+
- int
177+
- 'null'
178+
- id: runtblastn.taxids
179+
type:
180+
- string
181+
- 'null'
182+
- id: runtblastn.negative_taxids
183+
type:
184+
- string
185+
- 'null'
186+
- id: runtblastx.taxids
187+
type:
188+
- string
189+
- 'null'
190+
- id: runtblastx.word_size
191+
default: 3
192+
type: int
193+
- id: runtblastx.max_target_seqs
194+
default: 100
195+
type: int
196+
- id: runtblastx.seg
197+
default: "'12 2.2 2.5'"
198+
type: string
199+
- id: runtblastx.matrix
200+
default: BLOSUM62
201+
type: string
202+
- id: runtblastx.lcase_masking
203+
default: false
204+
type: boolean
205+
- id: runtblastx.negative_taxids
206+
type:
207+
- string
208+
- 'null'
209+
- id: runtblastx.max_hsps
210+
type:
211+
- int
212+
- 'null'
213+
steps: []
214+
outputs:
215+
- id: blast.fina_output
216+
outputSource: '$([inputs["runtblastx.out"] === null '
217+
type: File

wdl2cwl/tests/test_cwl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def test_meta(caplog: pytest.LogCaptureFixture) -> None:
6868
("vt.wdl"),
6969
("whatshap.wdl"),
7070
("workflow_inputs.wdl"),
71+
("blast.wdl"),
7172
],
7273
)
7374
def test_wdls(description_name: str) -> None:

0 commit comments

Comments
 (0)