From 14b037c135889579013f34534374b46ee491a1d4 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 25 Feb 2021 13:55:02 +0530 Subject: Support embedding clitool into a workflow step. * generate-cwl/generate-cwl.scm: Export intermediate and clitool-step. (): New type. (clitool-step): New function. (workflow): Pull out inputs and intermediate put into objects by clitool-step. --- generate-cwl/generate-cwl.scm | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/generate-cwl/generate-cwl.scm b/generate-cwl/generate-cwl.scm index 03ce77d..4e6420a 100644 --- a/generate-cwl/generate-cwl.scm +++ b/generate-cwl/generate-cwl.scm @@ -13,7 +13,9 @@ input output step - workflow-output)) + workflow-output + intermediate + clitool-step)) (define-record-type ( make-input input?) (fields (immutable id input-id) @@ -38,6 +40,29 @@ "Build and return an object." (make-output id type binding other)) +(define-record-type ( intermediate intermediate?) + (fields (immutable input intermediate-input) + (immutable output-source intermediate-output-source))) + +(define* (clitool-step id args #:key (additional-inputs '()) (outputs '()) stdout stderr (other '())) + (step id + (clitool (map (lambda (arg) + (if (intermediate? arg) + (intermediate-input arg) + arg)) + args) + #:additional-inputs additional-inputs + #:outputs outputs + #:stdout stdout + #:stderr stderr + #:other other) + (append (filter (lambda (arg) + (or (input? arg) + (intermediate? arg))) + args) + additional-inputs) + (map output-id outputs))) + (define* (parse-arguments args #:optional (position 1)) "Parse ARGS, a list of command line arguments and return a parse tree of labelled arguments. POSITION is an internal recursion @@ -156,6 +181,7 @@ lists---the base command and the actual arguments." (append-map (lambda (step) (filter-map (match-lambda ((id . (? input? input)) input) + ((? input? input) input) (_ #f)) (step-in step))) steps) @@ -176,7 +202,12 @@ lists---the base command and the actual arguments." ((id . input) (cons id (if (input? input) (input-id input) - input)))) + input))) + ((? input? input) + (cons (input-id input) (input-id input))) + ((? intermediate? intermediate) + (cons (input-id (intermediate-input intermediate)) + (intermediate-output-source intermediate)))) (step-in step))) (out . ,(list->vector (step-out step))) (run . ,(step-run step)))) -- cgit v1.2.3