Contenuto principale

run

Run block object

Since R2023a

Description

outStruct = run(blockObj,inStruct) runs a block object blockObj using an input structure inStruct and returns the block outputs in an output structure outStruct.

Tip

For most cases, use the run method of a block instead of eval because the run method performs additional error checks and ensures that the block inputs and outputs are satisfied and the eval method accepts and returns a scalar structure, which is a requirement to run the block as part of a pipeline. In addition, when you run a pipeline, it calls the run method of each block.

example

outStruct = run(blockObj,inStruct,RunFolder=folderLocation) specifies a folder location to store the block output files.

example

Examples

collapse all

Create a SamSort block.

SSBlock = bioinfo.pipeline.block.SamSort;

The emptyInputs method of the block creates an input structure with the field name equivalent to the name of the input port of the block. The run method of a block requires such a structure.

inputStruct = emptyInputs(SSBlock)
inputStruct = struct with fields:
    SAMFile: []

Set the value of the SAMFile field to a sample SAM file.

inputStruct.SAMFile = which("ex1.sam");

Call the run method of the block with the input structure. The output structure contains the field name that is the same as the output port name of the block and its value is the block output (which is a sorted SAM file).

outStruct = run(SSBlock,inputStruct)
outStruct = struct with fields:
    SortedSAMFile: [1×1 bioinfo.pipeline.datatype.File]

Use unwrap to check the location of the generated sorted SAM file.

unwrap(outStruct.SortedSAMFile)

Create a SamSort block.

SSBlock = bioinfo.pipeline.block.SamSort;

Use emptyInputs to create an empty input structure that is used to specify the input file name: ex1.sam, which is provided with the toolbox.

inputStruct = emptyInputs(SSBlock)
inputStruct = struct with fields:
    SAMFile: []

inputStruct.SAMFile = "ex1.sam";

Specify the folder to save the block output file after the run is complete.

folderLocation = "C:\Examples\tmp\samsortFolder";

Run the block.

outStruct = run(SSBlock,inputStruct,RunFolder=folderLocation)
outStruct = struct with fields:
    SortedSAMFile: [1×1 bioinfo.pipeline.datatype.File]

Use unwrap to check the location of the generated sorted SAM file.

unwrap(outStruct.SortedSAMFile)
ans = 
"C:\Examples\tmp\samsortFolder\ex1.sorted.sam"

Input Arguments

collapse all

Block object, specified as a scalar bioinfo.pipeline.Block object.

Block input, specified as a structure. The field names of the structure must be the names of the input ports of the block.

Location of a folder to save the block output files, specified as a character vector or string scalar. After the run is complete, the block saves the output files in the specified folder location instead of the current folder.

However, if you run the block within a pipeline, the pipeline automatically makes the specified location as a subfolder of the pipeline results folder (ResultsDirectory).

In other words, for blocks that let you specify an output folder, output prefix, or output filename, such specified output information is appended to the pipeline results folder instead.

Output Arguments

collapse all

Block output, returned as a structure. The field names of the structure are the names of the output ports of the block, and the field values are the output values of the block.

Version History

Introduced in R2023a

expand all