Skip to content

Commit

Permalink
Handle cases where the WDL workflow output contains exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Jun 2, 2022
1 parent 2ae6ad9 commit 6f9e73e
Show file tree
Hide file tree
Showing 4 changed files with 550 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wdl2cwl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,11 @@ def get_workflow_outputs(
with WDLSourceLine(item.info, ConversionException):
output_name = item.name
item_expr = item.info.expr
output_source = item_expr.expr.name[::-1].replace(".", "/", 1)[::-1]
if isinstance(item_expr, WDL.Expr.Get):
output_source = item_expr.expr.name[::-1].replace(".", "/", 1)[::-1]
else:
output_source = f"$({self.get_expr(item_expr)})"

# replace just the last occurrence of a period with a slash
# by first reversing the string and the replace the first occurrence
# then reversing the result
Expand Down Expand Up @@ -1019,14 +1023,14 @@ def get_expr_get(self, wdl_get_expr: WDL.Expr.Get) -> str:

def get_expr_ident(self, wdl_ident_expr: WDL.Expr.Ident) -> str:
"""Translate WDL Ident Expressions."""
id_name = wdl_ident_expr.name
id_name: str = wdl_ident_expr.name
referee = wdl_ident_expr.referee
optional = wdl_ident_expr.type.optional
if referee:
with WDLSourceLine(referee, ConversionException):
if isinstance(referee, WDL.Tree.Call):
return id_name
if referee.expr and (
if hasattr(referee, 'expr') and referee.expr is not None and (
wdl_ident_expr.name in self.optional_cwl_null
or wdl_ident_expr.name not in self.non_static_values
):
Expand Down
217 changes: 217 additions & 0 deletions wdl2cwl/tests/cwl_files/blast.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
cwlVersion: v1.2
id: blast
class: Workflow
requirements:
- class: InlineJavascriptRequirement
inputs:
- id: blast_docker_override
type:
- string
- 'null'
- id: blast_docker
type:
- string
- 'null'
- id: queryfa
type: File
- id: fname
default: /sfs/blastdb/2019_ncov/nucl/v6/ncov
type: string
- id: method
default: blastn
type: string
- id: outfmt
default: 7
type: int
- id: evalue
default: 10.0
type: float
- id: Outfile
type:
- string
- 'null'
- id: threads
default: 8
type: int
- id: runblastp.max_target_seqs
default: 100
type: int
- id: runblastp.word_size
default: 6
type: int
- id: runblastp.seg
default: no
type: string
- id: runblastp.comp_based_stats
default: '2'
type: string
- id: runblastp.matrix
default: BLOSUM62
type: string
- id: runblastp.gapopen
default: 11
type: int
- id: runblastp.gapextend
default: 1
type: int
- id: runblastp.max_hsps
type:
- int
- 'null'
- id: runblastp.taxids
type:
- string
- 'null'
- id: runblastp.negative_taxids
type:
- string
- 'null'
- id: runblastp.lcase_masking
default: false
type: boolean
- id: runblastn.max_target_seqs
default: 100
type: int
- id: runblastn.word_size
default: 28
type: int
- id: runblastn.reward
default: 1
type: int
- id: runblastn.penalty
default: -2
type: int
- id: runblastn.strand
default: both
type: string
- id: runblastn.gapopen
default: 0
type: int
- id: runblastn.gapextend
default: 0
type: int
- id: runblastn.dust
default: "'20 64 1'"
type: string
- id: runblastn.max_hsps
type:
- int
- 'null'
- id: runblastn.tasks
default: megablast
type: string
- id: runblastn.taxids
type:
- string
- 'null'
- id: runblastn.negative_taxids
type:
- string
- 'null'
- id: runblastn.lcase_masking
default: false
type: boolean
- id: runblastx.max_target_seqs
default: 100
type: int
- id: runblastx.word_size
default: 6
type: int
- id: runblastx.seg
default: "'12 2.2 2.5'"
type: string
- id: runblastx.comp_based_stats
default: '2'
type: string
- id: runblastx.matrix
default: BLOSUM62
type: string
- id: runblastx.gapopen
default: 11
type: int
- id: runblastx.gapextend
default: 1
type: int
- id: runblastx.taxids
type:
- string
- 'null'
- id: runblastx.negative_taxids
type:
- string
- 'null'
- id: runblastx.max_hsps
type:
- int
- 'null'
- id: runblastx.lcase_masking
default: false
type: boolean
- id: runtblastn.max_target_seqs
default: 100
type: int
- id: runtblastn.word_size
default: 6
type: int
- id: runtblastn.seg
default: "'12 2.2 2.5'"
type: string
- id: runtblastn.comp_based_stats
default: '2'
type: string
- id: runtblastn.matrix
default: BLOSUM62
type: string
- id: runtblastn.gapopen
default: 11
type: int
- id: runtblastn.gapextend
default: 1
type: int
- id: runtblastn.lcase_masking
default: false
type: boolean
- id: runtblastn.max_hsps
type:
- int
- 'null'
- id: runtblastn.taxids
type:
- string
- 'null'
- id: runtblastn.negative_taxids
type:
- string
- 'null'
- id: runtblastx.taxids
type:
- string
- 'null'
- id: runtblastx.word_size
default: 3
type: int
- id: runtblastx.max_target_seqs
default: 100
type: int
- id: runtblastx.seg
default: "'12 2.2 2.5'"
type: string
- id: runtblastx.matrix
default: BLOSUM62
type: string
- id: runtblastx.lcase_masking
default: false
type: boolean
- id: runtblastx.negative_taxids
type:
- string
- 'null'
- id: runtblastx.max_hsps
type:
- int
- 'null'
steps: []
outputs:
- id: blast.fina_output
outputSource: '$([inputs["runtblastx.out"] === null '
type: File
1 change: 1 addition & 0 deletions wdl2cwl/tests/test_cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_meta(caplog: pytest.LogCaptureFixture) -> None:
("vt.wdl"),
("whatshap.wdl"),
("workflow_inputs.wdl"),
("blast.wdl"),
],
)
def test_wdls(description_name: str) -> None:
Expand Down
Loading

0 comments on commit 6f9e73e

Please sign in to comment.