The Seven Bridges Knowledge Center

The Seven Bridges Platform is a simple solution for doing bioinformatics at industrial scale. But sometimes, everyone needs a little help.

Get Started

Set the default value for an input port

On this page, we will explain how to wrap your tool so that it takes a particular input value as a default, in the case that no other value is provided to that input port.

You may have noticed that a field entitled Tool Default is available for all non-file inputs on the Inputs tab of the Tool Editor. This field is descriptive only: it is used to provide information on what the default value is, but does not actually set the value. However, you can use dynamic expressions in the form of 'if' statements to set the default value for an input port that will be used by the tool if no value is entered to port in question at runtime. To illustrate how a default value is defined, we will use the app GATK VariantRecalibrator as an example. This app is available as a public tool on the Platform, and has been wrapped to include a default input value for the input port use_annotation.

Examine the use_annotation port for GATK VariantRecalibrator in the Tool Editor:

  1. Search for GATK VariantRecalibrator in the Public Apps and copy it to one of your projects.
  2. Navigate to the Apps tab in the project you added the app to, and click the pencil icon next to the app name. This opens the Tool Editor.

When you open GATK VariantRecalibrator in the Tool Editor, on the Inputs tab you will find an input port whose ID is use_annotation. This input port takes an array of strings that contains the names of the annotations that should be used for calculations. When you click the pencil icon to edit this input port's properties, the Value field contains the following expression:

{
  if ($job.inputs.use_annotation.length == 0){
    return ['QD', 'MQRankSum', 'FS', 'DP', 'ReadPosRankSum', 'HaplotypeScore']
  }
  else
    return $job.inputs.use_annotation
}

The expression works as follows:

  1. The if statement checks if there is any input value for the input port whose ID is use_annotation:
if ($job.inputs.use_annotation.length == 0)
  1. If nothing has been entered to that port for the particular job being executed, the following array of strings is assigned as the value:
return ['QD', 'MQRankSum', 'FS', 'DP', 'ReadPosRankSum', 'HaplotypeScore']

These strings are hard-coded as the default values for the input port.

  1. If values have been entered for the use_annotation input port, then those values are used:
return $job.inputs.use_annotation

You can adjust this dynamic expression to match the name and type of your input port by:

  • Replacing the two occurrences of use_annotation with the ID of your input port.
  • Replacing the array of strings on line 3 of the expression with value(s) appropriate for your input port. The entered value(s) will be used as the default if no other value is provided at runtime.