Solving more complex problems with scripts and toolkits
Overview
Teaching: 0 min
Exercises: 0 minQuestions
How to include and run a script in a step at runtime?
Which requirements need to be specified?
How to capture output of a script?
How to find other tools/solutions for awkward problems?
Objectives
script objectives:
Include and run a script in a step at runtime
Capture output of a script
tools objectives:
know good resources for finding solutions to common problems
By the end of this episode, learners should be able to include and run their own script in a step at runtime and be aware of where they can look for CWL recipes and more help for common, but awkward, tasks.
Exercise 1:
Which
Requirement
from the following options is used to create a script at runtime?A. InlineJavascriptRequirement B. InitialWorkDirRequirement C. ResourceRequirement D. DockerRequirement
Solution
B. InitialWorkDirRequirement
Exercise 2:
Using the template below, add the missing instructions so that a script named
script.sh
with the specified contents is created at runtime.InitialWorkDirRequirement: listing: - ------: script.sh ------: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string
Solution:
InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string
Exercise 3:
Since we are using
echo
in the script (as shown below) - what is the appropriatetype
in theoutputs
section of following code block to capture standard output?class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" outputs: message: type: ----
Your options are: A. File B. Directory C. stdout D. string
Solution:
C. stdout
Exercise 4:
Fix the
baseCommand
in following code snippet to execute the script we have created in previous exercises.baseCommand: []
Solution:
baseCommand: [ sh, script.sh ]
Exercise 5:
CHALLENGE question. Extend the
outputs
section of the following CWLtool definition to capture the script we have created along with tools’ standard output.This will help you inspect the generated script and is useful in more complex situations to troubleshoot related issues.
class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" baseCommand: ["sh", "script.sh"] outputs: message: type: stdout
Solution:
class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" baseCommand: ["sh", "script.sh"] outputs: message: type: stdout script: type: File outputBinding: glob: "script.sh"
Key Points
First key point. Brief Answer to questions. (FIXME)