summaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2021-03-21 16:10:14 +0530
committerArun Isaac2021-03-21 16:10:14 +0530
commit5b1c663f99b04157f8b4fac1cc42343a49088128 (patch)
tree4f004b306ea82a8b4d87c232fee943e71ce95ed7 /ccwl
parent553460f7d15e44deda3a7959b89b23bfacc12060 (diff)
downloadccwl-5b1c663f99b04157f8b4fac1cc42343a49088128.tar.gz
ccwl-5b1c663f99b04157f8b4fac1cc42343a49088128.tar.lz
ccwl-5b1c663f99b04157f8b4fac1cc42343a49088128.zip
Use both CWL arguments and inputs arrays.
* ccwl/ccwl.scm (<cli-element>): New type. (command->cwl): Put string and expression arguments into the arguments array. Put <input> arguments into the inputs array.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ccwl.scm79
1 files changed, 61 insertions, 18 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index be99eb6..8cc35b3 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -253,25 +253,68 @@ re-matched."
(cons 'output-binding (output-binding output)))))
,@(output-other output)))
+(define-immutable-record-type <cli-element>
+ (make-cli-element argument position)
+ cli-element?
+ (argument cli-element-argument)
+ (position cli-element-position))
+
(define (command->cwl command)
- `((cwl-version . ,%cwl-version)
- (class . Command-line-tool)
- ,@(command-other command)
- (arguments . ,(list->vector (map (lambda (arg)
- (if (input? arg)
- (string-append "$(inputs." (input-id arg) ")")
- arg))
- (command-args command))))
- (inputs . ,(map input->tree (append (command-inputs command)
- (if (command-stdin command)
- (list (command-stdin command))
- (list)))))
- (outputs . ,(map output->cwl (command-outputs command)))
- ,@(if (command-stdin command)
- `((stdin . ,(string-append "$(inputs."
- (input-id (command-stdin command))
- ".path)")))
- '())))
+ (let ((elements
+ ;; Add a position to all arguments, converting them to
+ ;; <cli-element> objects.
+ (map (lambda (arg position)
+ (make-cli-element
+ ;; If duplicate input, convert it to an expression
+ ;; referring to the input.
+ (if (and (input? arg)
+ (not (= (list-index (lambda (x)
+ (and (input? x)
+ (input=? arg x)))
+ (command-args command))
+ position)))
+ (string-append "$(inputs." (input-id arg) ")")
+ arg)
+ position))
+ (command-args command)
+ (iota (length (command-args command))))))
+ `((cwl-version . ,%cwl-version)
+ (class . Command-line-tool)
+ ,@(command-other command)
+ (arguments . ,(list->vector
+ ;; Put string arguments into the arguments array.
+ (filter-map (lambda (element)
+ (and (string? (cli-element-argument element))
+ `((position . ,(cli-element-position element))
+ (value-from . ,(cli-element-argument element)))))
+ elements)))
+ (inputs . ,(append
+ ;; Put <input> arguments into the inputs array.
+ (filter-map (lambda (element)
+ (let ((input (cli-element-argument element)))
+ (and (input? input)
+ `(,(input-id input)
+ ,@(filter-alist
+ `((type . ,(input-type input))
+ (label . ,(input-label input))
+ (default . ,(and (not (unspecified-default? (input-default input)))
+ (input-default input)))
+ (input-binding . ,(filter-alist
+ `((position . ,(cli-element-position element))
+ (prefix . ,(input-prefix input)))))))
+ ,@(input-other input)))))
+ elements)
+ (let ((stdin (command-stdin command)))
+ (if stdin
+ (list `(,(input-id stdin)
+ (type . ,(input-type stdin))))
+ (list)))))
+ (outputs . ,(map output->cwl (command-outputs command)))
+ ,@(if (command-stdin command)
+ `((stdin . ,(string-append "$(inputs."
+ (input-id (command-stdin command))
+ ".path)")))
+ '()))))
(define (write-cwl step file)
(call-with-output-file file