|
| 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 | +``` |
0 commit comments