Skip to content

Commit c33df38

Browse files
committed
wire expressiontool in workflow conversion
1 parent 8a41055 commit c33df38

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

src/ARCtrl/CWLRunResolver.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ and private resolveWorkflowStepRunRecursiveWithResolver (workflowFilePath: strin
5454
let nextVisited =
5555
resolveWorkflowRunsRecursiveWithResolver resolvedRunPath visitedWithCurrent workflow tryResolveRunPath
5656
Some (CWL.WorkflowStepRunOps.fromWorkflow workflow, nextVisited)
57+
| Some (CWL.ExpressionTool expressionTool) ->
58+
Some (CWL.WorkflowStepRunOps.fromExpressionTool expressionTool, visited.Add key)
5759
| None ->
5860
None
5961
)
@@ -68,6 +70,8 @@ and private resolveWorkflowStepRunRecursiveWithResolver (workflowFilePath: strin
6870
run, visited
6971
| CWL.RunCommandLineTool _ ->
7072
run, visited
73+
| CWL.RunExpressionTool _ ->
74+
run, visited
7175

7276
/// Resolve CWL WorkflowStep `run` references for a processing unit via path lookup.
7377
let resolveRunReferencesFromLookup (workflowFilePath: string) (processingUnit: CWL.CWLProcessingUnit) (tryResolveRunPath: string -> CWL.CWLProcessingUnit option) : CWL.CWLProcessingUnit =
@@ -78,6 +82,8 @@ let resolveRunReferencesFromLookup (workflowFilePath: string) (processingUnit: C
7882
CWL.Workflow workflow
7983
| CWL.CommandLineTool _ ->
8084
processingUnit
85+
| CWL.ExpressionTool _ ->
86+
processingUnit
8187

8288
/// Resolve a single workflow step run value via path lookup.
8389
let resolveWorkflowStepRunFromLookup (workflowFilePath: string) (run: CWL.WorkflowStepRun) (tryResolveRunPath: string -> CWL.CWLProcessingUnit option) : CWL.WorkflowStepRun =

src/ARCtrl/Conversion/Workflow.fs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,24 @@ type WorkflowConversion =
182182
| None -> ResizeArray []
183183
| CWL.Workflow wf ->
184184
wf.Inputs |> ResizeArray.map (fun i -> i)
185+
| CWL.ExpressionTool et ->
186+
match et.Inputs with
187+
| Some inputs -> inputs |> ResizeArray.map (fun i -> i)
188+
| None -> ResizeArray []
185189

186190

187191
static member toolDescriptionTypeName = "ToolDescription"
188192

189193
static member workflowDescriptionTypeName = "WorkflowDescription"
190194

195+
static member expressionToolDescriptionTypeName = "ExpressionToolDescription"
196+
191197
static member private runToIdentifier (run : CWL.WorkflowStepRun) : string =
192198
match run with
193199
| CWL.RunString runPath -> runPath
194200
| CWL.RunCommandLineTool _ -> "inline:CommandLineTool"
195201
| CWL.RunWorkflow _ -> "inline:Workflow"
202+
| CWL.RunExpressionTool _ -> "inline:ExpressionTool"
196203

197204
static member private tryDecodeProcessingUnitFromGraph(resolvedRunPath: string, ?graph: LDGraph, ?context: LDContext) : CWL.CWLProcessingUnit option =
198205
let tryDecodeWorkflowProtocol (protocol: LDNode) =
@@ -263,6 +270,41 @@ type WorkflowConversion =
263270
inputs = inputs
264271
)
265272

273+
static member composeWorkflowProtocolFromExpressionToolDescription (filePath : string, expressionTool : CWL.CWLExpressionToolDescription, ?workflowName : string, ?runName : string) =
274+
let inputs =
275+
expressionTool.Inputs
276+
|> Option.map (ResizeArray.map (fun i -> WorkflowConversion.composeFormalParameterFromInput(i, ?workflowName = workflowName, ?runName = runName)))
277+
let outputs =
278+
expressionTool.Outputs
279+
|> ResizeArray.map (fun o -> WorkflowConversion.composeFormalParameterFromOutput(o, ?workflowName = workflowName, ?runName = runName))
280+
let protocol =
281+
LDWorkflowProtocol.create(
282+
id = filePath,
283+
name = filePath,
284+
?inputs = inputs,
285+
programmingLanguages = ResizeArray.singleton (LDComputerLanguage.createCWL()),
286+
outputs = outputs,
287+
additionalType = ResizeArray [WorkflowConversion.expressionToolDescriptionTypeName]
288+
)
289+
LDLabProtocol.setDescriptionAsString(protocol, expressionTool.Expression)
290+
protocol
291+
292+
static member decomposeWorkflowProtocolToExpressionToolDescription (protocol : LDNode, ?context : LDContext, ?graph : LDGraph) =
293+
let inputs =
294+
LDComputationalWorkflow.getInputsAsFormalParameters(protocol, ?graph = graph, ?context = context)
295+
|> ResizeArray.map (fun i -> WorkflowConversion.decomposeInputFromFormalParameter(i, ?context = context, ?graph = graph))
296+
let outputs =
297+
LDComputationalWorkflow.getOutputsAsFormalParameter(protocol, ?graph = graph, ?context = context)
298+
|> ResizeArray.map (fun o -> WorkflowConversion.decomposeOutputFromFormalParameter(o, ?context = context, ?graph = graph))
299+
let expression =
300+
LDLabProtocol.tryGetDescriptionAsString(protocol, ?context = context)
301+
|> Option.defaultValue "$(null)"
302+
CWL.CWLExpressionToolDescription(
303+
outputs = outputs,
304+
expression = expression,
305+
inputs = inputs
306+
)
307+
266308
static member composeWorkflowStep (step : CWL.WorkflowStep, workflowID) =
267309
let id = $"WorkflowStep_{workflowID}_{step.Id}"
268310
let cw = LDComputationalWorkflow.create(id = id, name = step.Id)
@@ -344,13 +386,18 @@ type WorkflowConversion =
344386
WorkflowConversion.composeWorkflowProtocolFromToolDescription(filePath, tool, ?workflowName = workflowName, ?runName = runName)
345387
| CWL.Workflow wf ->
346388
WorkflowConversion.composeWorkflowProtocolFromWorkflow(filePath, wf, ?workflowName = workflowName, ?runName = runName)
389+
| CWL.ExpressionTool et ->
390+
WorkflowConversion.composeWorkflowProtocolFromExpressionToolDescription(filePath, et, ?workflowName = workflowName, ?runName = runName)
347391

348392
static member decomposeWorkflowProtocolToProcessingUnit (protocol : LDNode, ?resolveRunReferences: bool, ?context : LDContext, ?graph : LDGraph) =
349393
let shouldResolveRunReferences = defaultArg resolveRunReferences true
350394
match LDComputationalWorkflow.getAdditionalTypeAsString(protocol, ?context = context) with
351395
| s when s = WorkflowConversion.workflowDescriptionTypeName ->
352396
WorkflowConversion.decomposeWorkflowProtocolToWorkflow(protocol, resolveRunReferences = shouldResolveRunReferences, ?context = context, ?graph = graph)
353397
|> CWL.Workflow
398+
| s when s = WorkflowConversion.expressionToolDescriptionTypeName ->
399+
WorkflowConversion.decomposeWorkflowProtocolToExpressionToolDescription(protocol, ?context = context, ?graph = graph)
400+
|> CWL.ExpressionTool
354401
| s ->
355402
WorkflowConversion.decomposeWorkflowProtocolToToolDescription(protocol, ?context = context, ?graph = graph)
356403
|> CWL.CommandLineTool

0 commit comments

Comments
 (0)