Main Content


Run block object

Since R2023a



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


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.


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.


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.

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