From 3cc79d23fa386349fb2609c7fc7072e65bb71593 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 10 Jun 2016 15:49:58 -0400 Subject: [PATCH] Port draft-3 changes to command line generation tests to draft-4. --- draft-4/conformance_test_draft-4.yaml | 73 +++++++------------ draft-4/draft-4/args.py | 7 ++ draft-4/draft-4/binding-test.cwl | 15 +++- draft-4/draft-4/bwa-mem-job.json | 6 +- draft-4/draft-4/bwa-mem-tool.cwl | 36 +++++---- draft-4/draft-4/cat1-testcli.cwl | 35 +++++++++ draft-4/draft-4/chr20.fa | 0 .../draft-4/example_human_Illumina.pe_1.fastq | 0 .../draft-4/example_human_Illumina.pe_2.fastq | 0 draft-4/draft-4/reads.fastq | 0 draft-4/draft-4/template-tool.cwl | 9 ++- draft-4/draft-4/tmap-tool.cwl | 18 ++++- 12 files changed, 129 insertions(+), 70 deletions(-) create mode 100755 draft-4/draft-4/args.py create mode 100755 draft-4/draft-4/cat1-testcli.cwl create mode 100644 draft-4/draft-4/chr20.fa create mode 100644 draft-4/draft-4/example_human_Illumina.pe_1.fastq create mode 100644 draft-4/draft-4/example_human_Illumina.pe_2.fastq create mode 100644 draft-4/draft-4/reads.fastq diff --git a/draft-4/conformance_test_draft-4.yaml b/draft-4/conformance_test_draft-4.yaml index e35762f42..19ed74b24 100644 --- a/draft-4/conformance_test_draft-4.yaml +++ b/draft-4/conformance_test_draft-4.yaml @@ -1,69 +1,52 @@ -- args: [bwa, mem, -t, '4', -I, '1,2,3,4', -m, '3', draft-4/rabix/tests/test-files/chr20.fa, - draft-4/rabix/tests/test-files/example_human_Illumina.pe_1.fastq, draft-4/rabix/tests/test-files/example_human_Illumina.pe_2.fastq] +- args: job: draft-4/bwa-mem-job.json - stdout: output.sam tool: draft-4/bwa-mem-tool.cwl + output: + args: [bwa, mem, -t, '4', -I, '1,2,3,4', -m, '3', + chr20.fa, + example_human_Illumina.pe_1.fastq, + example_human_Illumina.pe_2.fastq] doc: General test of command line generation -- args: [bwa, mem, draft-4/rabix/tests/test-files/chr20.fa, - "-XXX", - "-YYY", draft-4/rabix/tests/test-files/example_human_Illumina.pe_1.fastq, - "-YYY", draft-4/rabix/tests/test-files/example_human_Illumina.pe_2.fastq] +- output: + args: [bwa, mem, chr20.fa, + "-XXX", + "-YYY", example_human_Illumina.pe_1.fastq, + "-YYY", example_human_Illumina.pe_2.fastq] job: draft-4/bwa-mem-job.json tool: draft-4/binding-test.cwl doc: Test nested prefixes with arrays -- args: [tmap, mapall, stage1, map1, --min-seq-length, '20', map2, --min-seq-length, +- output: + args: [tmap, mapall, stage1, map1, --min-seq-length, '20', map2, --min-seq-length, '20', stage2, map1, --max-seq-length, '20', --min-seq-length, '10', --seed-length, '16', map2, --max-seed-hits, '-1', --max-seq-length, '20', --min-seq-length, '10'] job: draft-4/tmap-job.json - stdin: draft-4/reads.fastq - stdout: output.sam tool: draft-4/tmap-tool.cwl - doc: Test nested command line bindings and stdin/stdout redirection + doc: Test nested command line bindings -- args: [cat, draft-4/hello.txt] +- output: + args: [cat, hello.txt] job: draft-4/cat-job.json - tool: draft-4/cat1-tool.cwl + tool: draft-4/cat1-testcli.cwl doc: Test command line with optional input (missing) -- args: [cat, -n, draft-4/hello.txt] +- output: + args: [cat, -n, hello.txt] job: draft-4/cat-n-job.json - tool: draft-4/cat1-tool.cwl + tool: draft-4/cat1-testcli.cwl doc: Test command line with optional input (provided) -- args: [cat] - job: draft-4/cat-job.json - stdin: draft-4/hello.txt - tool: draft-4/cat2-tool.cwl - doc: Test command line with stdin redirection - -- args: [cat, draft-4/hello.txt] - job: draft-4/cat-job.json - stdout: output.txt - tool: draft-4/cat3-tool.cwl - doc: Test command line with stdout redirection - -- args: [egrep] - stderr: error.txt - job: - tool: draft-4/egrep-stderr.cwl - doc: Test command line with stdout redirection - -- args: [cat] - job: draft-4/cat-job.json - stdin: draft-4/hello.txt - stdout: output.txt - tool: draft-4/cat4-tool.cwl - doc: Test command line with stdin and stdout redirection - -- args: [cat, foo.txt] - createfiles: {foo.txt: 'The file is draft-4/hello.txt - - '} +- output: + "foo": { + "checksum": "sha1$63da67422622fbf9251a046d7a34b7ea0fd4fead", + "class": "File", + "path": "foo.txt", + "size": 22 + } job: draft-4/cat-job.json tool: draft-4/template-tool.cwl - doc: Test CreateFileRequirement ExpressionEngineRequirement.engineConfig features + doc: Test CreateFileRequirement ExpressionEngineRequirement.engineConfig feature - job: draft-4/cat-job.json output: diff --git a/draft-4/draft-4/args.py b/draft-4/draft-4/args.py new file mode 100755 index 000000000..1baf6a090 --- /dev/null +++ b/draft-4/draft-4/args.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python +import sys +import json +import os +args = [os.path.basename(a) for a in sys.argv[1:]] +with open("cwl.output.json", "w") as f: + json.dump({"args": args}, f) diff --git a/draft-4/draft-4/binding-test.cwl b/draft-4/draft-4/binding-test.cwl index 085145df9..7e6c3c826 100755 --- a/draft-4/draft-4/binding-test.cwl +++ b/draft-4/draft-4/binding-test.cwl @@ -4,17 +4,26 @@ class: CommandLineTool cwlVersion: cwl:draft-4.dev2 inputs: - reference: + - id: reference type: File inputBinding: { position: 2 } - reads: + - id: reads type: type: array items: File inputBinding: { prefix: "-YYY" } inputBinding: { position: 3, prefix: "-XXX" } + - id: "#args.py" + type: File + default: + class: File + path: args.py + inputBinding: + position: -1 + outputs: [] -baseCommand: [bwa, mem] +baseCommand: python +arguments: ["bwa", "mem"] diff --git a/draft-4/draft-4/bwa-mem-job.json b/draft-4/draft-4/bwa-mem-job.json index b6b290140..48d7d6cfe 100644 --- a/draft-4/draft-4/bwa-mem-job.json +++ b/draft-4/draft-4/bwa-mem-job.json @@ -1,18 +1,18 @@ { "reference": { "class": "File", - "path": "rabix/tests/test-files/chr20.fa", + "path": "chr20.fa", "size": 123, "checksum": "sha1$hash" }, "reads": [ { "class": "File", - "path": "rabix/tests/test-files/example_human_Illumina.pe_1.fastq" + "path": "example_human_Illumina.pe_1.fastq" }, { "class": "File", - "path": "rabix/tests/test-files/example_human_Illumina.pe_2.fastq" + "path": "example_human_Illumina.pe_2.fastq" } ], "min_std_max_min": [ diff --git a/draft-4/draft-4/bwa-mem-tool.cwl b/draft-4/draft-4/bwa-mem-tool.cwl index 830d071c8..b0722effa 100755 --- a/draft-4/draft-4/bwa-mem-tool.cwl +++ b/draft-4/draft-4/bwa-mem-tool.cwl @@ -1,47 +1,57 @@ #!/usr/bin/env cwl-runner -cwlVersion: cwl:draft-4.dev2 +cwlVersion: draft-4.dev2 class: CommandLineTool hints: - DockerRequirement: - dockerPull: images.sbgenomics.com/rabix/bwa - dockerImageId: 9d3b9b0359cf - - ResourceRequirement: + - class: ResourceRequirement coresMin: 4 inputs: - reference: + - id: reference type: File inputBinding: { position: 2 } - reads: + - id: reads type: type: array items: File inputBinding: { position: 3 } - minimum_seed_length: + - id: minimum_seed_length type: int inputBinding: { position: 1, prefix: -m } - min_std_max_min: + - id: min_std_max_min type: { type: array, items: int } inputBinding: position: 1 prefix: -I itemSeparator: "," -outputs: - sam: + - id: args.py type: File + default: + class: File + path: args.py + inputBinding: + position: -1 + +outputs: + - id: sam + type: ["null", File] outputBinding: { glob: output.sam } + - id: args + type: + type: array + items: string -baseCommand: [bwa, mem] +baseCommand: python arguments: + - bwa + - mem - valueFrom: $(runtime.cores) position: 1 prefix: -t diff --git a/draft-4/draft-4/cat1-testcli.cwl b/draft-4/draft-4/cat1-testcli.cwl new file mode 100755 index 000000000..3bad2b662 --- /dev/null +++ b/draft-4/draft-4/cat1-testcli.cwl @@ -0,0 +1,35 @@ +#!/usr/bin/env cwl-runner +{ + "class": "CommandLineTool", + "cwlVersion": "cwl:draft-4.dev2", + "description": "Print the contents of a file to stdout using 'cat' running in a docker container.", + "inputs": [ + { + "id": "file1", + "type": "File", + "inputBinding": {"position": 1} + }, + { + "id": "numbering", + "type": ["null", "boolean"], + "inputBinding": { + "position": 0, + "prefix": "-n" + } + }, + { + id: "args.py", + type: File, + default: { + class: File, + path: args.py + }, + inputBinding: { + position: -1 + } + } + ], + "outputs": [], + "baseCommand": "python", + "arguments": ["cat"] +} diff --git a/draft-4/draft-4/chr20.fa b/draft-4/draft-4/chr20.fa new file mode 100644 index 000000000..e69de29bb diff --git a/draft-4/draft-4/example_human_Illumina.pe_1.fastq b/draft-4/draft-4/example_human_Illumina.pe_1.fastq new file mode 100644 index 000000000..e69de29bb diff --git a/draft-4/draft-4/example_human_Illumina.pe_2.fastq b/draft-4/draft-4/example_human_Illumina.pe_2.fastq new file mode 100644 index 000000000..e69de29bb diff --git a/draft-4/draft-4/reads.fastq b/draft-4/draft-4/reads.fastq new file mode 100644 index 000000000..e69de29bb diff --git a/draft-4/draft-4/template-tool.cwl b/draft-4/draft-4/template-tool.cwl index ac4014e54..7e3521382 100755 --- a/draft-4/draft-4/template-tool.cwl +++ b/draft-4/draft-4/template-tool.cwl @@ -11,9 +11,14 @@ requirements: - class: CreateFileRequirement fileDef: - filename: foo.txt - fileContent: $(t("The file is <%= inputs.file1.path %>\n")) + fileContent: > + $(t("The file is <%= inputs.file1.path.split('/').slice(-1)[0] %>\n")) inputs: - id: file1 type: File -outputs: [] +outputs: + - id: foo + type: File + outputBinding: + glob: foo.txt baseCommand: [cat, foo.txt] diff --git a/draft-4/draft-4/tmap-tool.cwl b/draft-4/draft-4/tmap-tool.cwl index f33b01f5c..8f8aca16a 100755 --- a/draft-4/draft-4/tmap-tool.cwl +++ b/draft-4/draft-4/tmap-tool.cwl @@ -18,7 +18,18 @@ "type": "array", "items": "#Stage" } + }, + { + id: "#args.py", + type: File, + default: { + class: File, + path: args.py + }, + inputBinding: { + position: -1 } + } ], "outputs": [ { @@ -26,7 +37,7 @@ "outputBinding": { "glob": "output.sam" }, - "type": "File" + "type": ["null", "File"] } ], "requirements": [ @@ -235,7 +246,6 @@ ] } ]}], - "baseCommand": ["tmap", "mapall"], - "stdin": "$(inputs.reads.path)", - "stdout": "output.sam" + "baseCommand": "python", + "arguments": ["tmap", "mapall"] }