aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-09-12 13:26:31 +0100
committerArun Isaac2024-09-13 02:57:39 +0100
commit3125f1d25498247b8a3f33a358f16b1fee5ccbe2 (patch)
tree337337f3a3df45d0b86ab48e10bda67c19a52e71
parent5c794e855472d4c86cdffdc49776baca1a8f81aa (diff)
downloadravanan-3125f1d25498247b8a3f33a358f16b1fee5ccbe2.tar.gz
ravanan-3125f1d25498247b8a3f33a358f16b1fee5ccbe2.tar.lz
ravanan-3125f1d25498247b8a3f33a358f16b1fee5ccbe2.zip
reader: Normalize secondaryFiles in formals.
* ravanan/reader.scm (normalize-workflow)[normalize-secondary-files]: New function. [normalize-formal-input]: Use normalize-secondary-files. [normalize-formal-output]: New function. Call normalie-formal-output from main body.
-rw-r--r--ravanan/reader.scm39
1 files changed, 37 insertions, 2 deletions
diff --git a/ravanan/reader.scm b/ravanan/reader.scm
index afcf552..6f1fdfe 100644
--- a/ravanan/reader.scm
+++ b/ravanan/reader.scm
@@ -115,6 +115,25 @@ each association list of the returned vector of association lists. If
(define (normalize-workflow cwl)
"Normalize CWL workflow @var{cwl} (of any class)."
+ (define (normalize-secondary-files secondary-files default-required)
+ (cond
+ ;; array of SecondaryFileSchema objects
+ ((vector? secondary-files)
+ (vector-append-map (cut normalize-secondary-files <> default-required)
+ secondary-files))
+ ;; SecondaryFileSchema object
+ ((not (string? secondary-files))
+ (vector secondary-files))
+ ;; string form optional SecondaryFileSchema object
+ ((string-suffix? "?" secondary-files)
+ (vector `(("pattern" . ,(string-drop-right secondary-files
+ (string-length "?")))
+ ("required" . #f))))
+ ;; string form SecondaryFileSchema object with an unspecified required
+ (else
+ (vector `(("pattern" . ,secondary-files)
+ ("required" . ,default-required))))))
+
(define (normalize-formal-input input)
(if (eq? (formal-parameter-type (assoc-ref input "type"))
'File)
@@ -122,9 +141,23 @@ each association list of the returned vector of association lists. If
(cons (list "default" "location")
(maybe-let* ((location (maybe-assoc-ref (just input)
"default" "location")))
- (just (canonicalize-path location)))))
+ (just (canonicalize-path location))))
+ (cons "secondaryFiles"
+ (maybe-bind (maybe-assoc-ref (just input) "secondaryFiles")
+ (compose just
+ (cut normalize-secondary-files <> #t)))))
input))
+ (define (normalize-formal-output output)
+ (if (eq? (formal-parameter-type (assoc-ref output "type"))
+ 'File)
+ (maybe-assoc-set output
+ (cons "secondaryFiles"
+ (maybe-bind (maybe-assoc-ref (just output) "secondaryFiles")
+ (compose just
+ (cut normalize-secondary-files <> #f)))))
+ output))
+
(define (normalize-base-command maybe-base-command)
(maybe-let* ((base-command maybe-base-command))
(cond
@@ -181,7 +214,9 @@ each association list of the returned vector of association lists. If
(assoc-ref cwl "inputs")))))
;; Normalize outputs.
(cons "outputs"
- (just (normalize-formals (assoc-ref cwl "outputs"))))
+ (just (vector-map normalize-formal-output
+ (normalize-formals
+ (assoc-ref cwl "outputs")))))
(let ((class (assoc-ref cwl "class")))
(cond
((string=? class "CommandLineTool")