From 2ed13ca5e4c779b59d04e574a496b6cb69bcba44 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 21 Feb 2021 19:44:54 +0530 Subject: Add CWL generator for Workflow workflows --- scripts/generate-cwl.scm | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'scripts/generate-cwl.scm') 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 ( 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 object." + (make-workflow-output id type source other)) + +(define-record-type ( 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)))) -- cgit v1.2.3