Main Content

connect

Connect two blocks in pipeline

Since R2023a

Description

connect(pipeline,sourceBlock,targetBlock,portsToConnect) connects an output port of the sourceBlock to an input port of the targetBlock. portsToConnect specifies the output and input ports.

example

mappedPorts = connect(pipeline,sourceBlock,targetBlock,portsToConnect) also returns the complete list of connections mappedPorts between the source block and target block after connecting two blocks as specified by portsToConnect.

Examples

collapse all

Import the Pipeline and block objects needed for the example.

import bioinfo.pipeline.Pipeline
import bioinfo.pipeline.block.*

Create a pipeline.

qcpipeline = Pipeline;

Select an input FASTQ file using a FileChooser block.

fastqfile = FileChooser(which("SRR005164_1_50.fastq"));

Create a SeqFilter block.

sequencefilter = SeqFilter;

Add blocks to the pipeline. Optionally, you can specify the block names.

addBlock(qcpipeline,[fastqfile,sequencefilter],["FF","SF"]);

Connect the output of the first block to the input of the second block. To do so, you need to first check the input and output port names of the corresponding blocks.

View the Outputs (port of the first block) and Inputs (port of the second block).

fastqfile.Outputs
ans = struct with fields:
    Files: [1×1 bioinfo.pipeline.Output]

sequencefilter.Inputs
ans = struct with fields:
    FASTQFiles: [1×1 bioinfo.pipeline.Input]

Connect the Files output port of the fastqfile block to the FASTQFiles port of sequencefilter block. The output is a 1-by-2 string array, indicating the names of two ports that are now connected. You can use either the block objects themselves or the block names that you have defined previously. The next command uses the block names to identify and connect these two blocks.

connectedports = connect(qcpipeline,"FF","SF",["Files","FASTQFiles"])
connectedports = 1×2 string
    "Files"    "FASTQFiles"

You can also query the names of connected ports using portMap.

portnames = portMap(qcpipeline,"FF","SF")
portnames = 1×2 string
    "Files"    "FASTQFiles"

Input Arguments

collapse all

Bioinformatics pipeline, specified as a bioinfo.pipeline.Pipeline object.

Block in the pipeline to connect from, specified as a bioinfo.pipeline.Block object or character vector or string scalar that represents the block name.

Block in the pipeline to connect to, specified as a bioinfo.pipeline.Block object or character vector or string scalar that represents the block name.

Output port name of the source block and an input port name of the target block to connect, specified an N-by-2 string array, where N is the number of connections between two blocks.

For example, if you are connecting the source block that has two output ports, "output1" and "output2", to the target block that has two input ports, "input1" and "input2", specify portsToConnect as a 2-by-2 string array: ["output1","input1";"output2","input2"]. The next figure is a graphical representation of such connections.

Two blocks, sourceBlock and targetBlock, with arrows from output1 and output2 on the source to input1 and input2, respectively, on the target.

Tip

To get the names of the input or output ports of a block, check the Inputs and Outputs properties of the block. Each property is returned as a structure, where each field name represents the corresponding port name that you can use to connect the blocks.

Data Types: string

Output Arguments

collapse all

Connections between source and target blocks, returned as an N-by-2 string array. N is the total number of connections between two blocks.

Version History

Introduced in R2023a