Skip to content

Commit 5d6573e

Browse files
author
Toby Hodges
committed
added file formats episode
1 parent b8ad1ab commit 5d6573e

File tree

6 files changed

+114
-0
lines changed

6 files changed

+114
-0
lines changed

_episodes/16-file-formats.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: "File Formats"
3+
teaching: 10
4+
exercises: 0
5+
questions:
6+
- "How can I allow type-checking of input and output files?"
7+
objectives:
8+
- "Learn how to unambiguously specify the format of `File` objects."
9+
keypoints:
10+
- "You can document the expected format of input and output `File`s."
11+
- "Once your tool is mature, we recommend specifying formats by referencing
12+
existing ontologies e.g. EDAM."
13+
---
14+
Tools and workflows can take `File` types as input and produce them as output.
15+
We also recommend indicating the format for `File` types. This helps document
16+
for others how to use your tool while allowing you to do some simple
17+
type-checking when creating parameter files.
18+
19+
For file formats, we recommend referencing existing ontologies (like EDAM in
20+
our example), reference a local ontology for your institution, or do not add
21+
a file format initially for quick development before sharing your tool with
22+
others.
23+
24+
Note that for added value `cwltool` can do some basic reasoning based on file
25+
formats and warn you if there seem to be some obvious mismatches.
26+
27+
*metadata_example.cwl*
28+
29+
```
30+
{% include cwl/metadata_example.cwl %}
31+
```
32+
33+
#### Sample Parameter Files
34+
35+
Below is an example of a parameter file for the example above. We encourage
36+
checking in working examples of parameter files for your tool. This allows
37+
others to quickly work with your tool, starting from a "known good"
38+
parameterization.
39+
40+
*sample.json*
41+
42+
```
43+
{% include cwl/sample.json %}
44+
```
45+
46+
Now invoke `cwl-runner` with the tool wrapper and the input object on the
47+
command line:
48+
49+
```
50+
$ cwltool metadata_example.cwl sample.json
51+
/usr/local/bin/cwltool 1.0.20161114152756
52+
Resolved 'metadata_example.cwl' to 'file:///media/large_volume/testing/cwl_tutorial2/metadata_example.cwl'
53+
[job metadata_example.cwl] /tmp/tmpNWyAd6$ /bin/sh \
54+
-c \
55+
'wc' '-l' '/tmp/tmpBf6m9u/stge293ac74-3d42-45c9-b506-dd35ea3e6eea/rna.SRR948778.bam' > /tmp/tmpNWyAd6/output.txt
56+
Final process status is success
57+
{
58+
"report": {
59+
"format": "http://edamontology.org/format_1964",
60+
"checksum": "sha1$49dc5004959ba9f1d07b8c00da9c46dd802cbe79",
61+
"basename": "output.txt",
62+
"location": "file:///media/large_volume/testing/cwl_tutorial2/output.txt",
63+
"path": "/media/large_volume/testing/cwl_tutorial2/output.txt",
64+
"class": "File",
65+
"size": 80
66+
}
67+
}
68+
```
File renamed without changes.

_includes/cwl/metadata_example.cwl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
class: CommandLineTool
4+
id: Example tool
5+
label: Example tool
6+
cwlVersion: v1.0
7+
doc: |
8+
An example tool demonstrating metadata.
9+
10+
requirements:
11+
- class: ShellCommandRequirement
12+
13+
inputs:
14+
bam_input:
15+
type: File
16+
doc: The BAM file used as input
17+
format: http://edamontology.org/format_2572
18+
inputBinding:
19+
position: 1
20+
21+
stdout: output.txt
22+
23+
outputs:
24+
report:
25+
type: File
26+
format: http://edamontology.org/format_1964
27+
outputBinding:
28+
glob: "*.txt"
29+
doc: A text file that contains a line count
30+
31+
baseCommand: ["wc", "-l"]
32+
33+
$schemas:
34+
- http://dublincore.org/2012/06/14/dcterms.rdf
35+
- http://xmlns.com/foaf/spec/20140114.rdf
File renamed without changes.
File renamed without changes.

_includes/cwl/sample.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"bam_input": {
3+
"class": "File",
4+
"format": "http://edamontology.org/format_2572",
5+
"path": "rna.SRR948778.bam"
6+
},
7+
"bamstats_report": {
8+
"class": "File",
9+
"path": "/tmp/bamstats_report.zip"
10+
}
11+
}

0 commit comments

Comments
 (0)