From 3125f1d25498247b8a3f33a358f16b1fee5ccbe2 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 12 Sep 2024 13:26:31 +0100 Subject: 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. --- ravanan/reader.scm | 39 +++++++++++++++++++++++++++++++++++++-- 1 file 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") -- cgit v1.2.3