File: rename-inputs.cwl

package info (click to toggle)
cwl-utils 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 5,156 kB
  • sloc: python: 88,920; makefile: 141; javascript: 91
file content (59 lines) | stat: -rw-r--r-- 1,704 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env cwl-runner
id: InputSecondaryFileConformanceTest
class: CommandLineTool
cwlVersion: v1.2
doc: |
  Simple test to confirm the implementation of expressions returning a File within a CommandInputParameter.secondaryFile field.

  Use GREP to filter the result from ls to ensure we only get the secondary files in there.

  Related links:
  - Issue: https://github.com/common-workflow-language/cwltool/issues/1232
  - PR: https://github.com/common-workflow-language/cwltool/pull/1233
  - Discourse: https://cwl.discourse.group/t/ask-cwl-to-rename-a-secondary-file/72

inputs:
- id: inputWithSecondary
  type: File
  doc: |
    This input will with a secondary file `.accessory`. You could create these files (and its accessory) with:
    ```bash
    touch secondary_file_test.txt
    touch secondary_file_test.txt.accessory
    ```
  secondaryFiles:
    - |
      ${
        function resolveSecondary(base, secPattern) {
          if (secPattern[0] == '^') {
            var spl = base.split('.');
            var endIndex = spl.length > 1 ? spl.length - 1 : 1;
            return resolveSecondary(spl.slice(undefined, endIndex).join("."), secPattern.slice(1));
          }
          return base + secPattern;
        }
        return [{
            "class": "File",
            "location": inputs.accessory.location,
            "basename": resolveSecondary(self.basename, '^.accessory')
        }];
      }
- id: accessory
  type: File


arguments:
- "ls"
- $(inputs.inputWithSecondary.dirname)
- valueFrom: "|"
  shellQuote: false
- "grep"
- "secondary"

outputs:
- id: output_file
  type: stdout
stdout: result
requirements:
  InlineJavascriptRequirement: {}
  ShellCommandRequirement: {}