aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/generate-cwl.scm53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/generate-cwl.scm b/scripts/generate-cwl.scm
index a28cdb0..1a26dfb 100644
--- a/scripts/generate-cwl.scm
+++ b/scripts/generate-cwl.scm
@@ -128,3 +128,56 @@ lists---the base command and the actual arguments."
,@(if stderr
`((stderr . ,stderr))
'()))))
+
+(define-record-type (<workflow-output> make-workflow-output workflow-output?)
+ (fields (immutable id workflow-output-id)
+ (immutable type workflow-output-type)
+ (immutable source workflow-output-source)
+ (immutable other workflow-output-other)))
+
+(define* (workflow-output id #:key type source (other '()))
+ "Build and return a <workflow-output> object."
+ (make-workflow-output id type source other))
+
+(define-record-type (<step> step step?)
+ (fields (immutable id step-id)
+ (immutable run step-run)
+ (immutable in step-in)
+ (immutable out step-out)))
+
+(define* (workflow steps outputs #:key (other '()))
+ "Build a Workflow class CWL workflow."
+ `((cwlVersion . "v1.1")
+ (class . Workflow)
+ ,@other
+ (inputs . ,(delete-duplicates
+ (map input->tree
+ (append
+ (append-map (lambda (step)
+ (filter-map (match-lambda
+ ((id . (? input? input)) input)
+ (_ #f))
+ (step-in step)))
+ steps)
+ (filter-map (lambda (output)
+ (and (input? (workflow-output-source output))
+ (workflow-output-source output)))
+ outputs)))))
+ (outputs . ,(map (lambda (output)
+ `(,(workflow-output-id output)
+ (type . ,(workflow-output-type output))
+ (output-source . ,(match (workflow-output-source output)
+ ((? string? source) source)
+ ((? input? input) (input-id input))))))
+ outputs))
+ (steps . ,(map (lambda (step)
+ `(,(step-id step)
+ (in . ,(map (match-lambda
+ ((id . input)
+ (cons id (if (input? input)
+ (input-id input)
+ input))))
+ (step-in step)))
+ (out . ,(list->vector (step-out step)))
+ (run . ,(step-run step))))
+ steps))))