Main Content

compile

Verify pipeline structure and check for warnings and errors

Since R2023a

Description

compile(pipeline) checks if the pipeline is ready to run. The function also performs block-specific checks by running the compile methods of individual blocks in the pipeline and also checks that all required input ports are satisfied.

example

compile(pipeline,inputStruct) compiles the pipeline using a structure inputStruct as an input.

example

Examples

collapse all

Checks for errors and warnings before running a pipeline.

Import the pipeline and block objects needed for the example.

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

Create a pipeline.

P = Pipeline;

Add some blocks to the pipeline.

FCB = FileChooser(which("ex1.sam"));
SSB = SamSort;
addBlock(P,[FCB, SSB]);

Compile the pipeline.

compile(P)
Error using bioinfo.pipeline.Pipeline/compile
Pipeline compilation failed with the following reason.

Caused by:
    Block 'SamSort_1' has one or more required ports that are not connected or passed in as the
    pipeline inputs.

The error is due to the blocks being not connected. Connect the blocks and recompile to ensure that there is no more error, and the pipeline is ready to run.

connect(P,FCB,SSB,["Files","SAMFile"]);
compile(P)

Import the Pipeline and block objects needed for the example.

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

Create a pipeline.

P = Pipeline;

Create a Bowtie2Build block to build index files for the reference genome.

bowtie2build = Bowtie2Build;

Create a Bowtie2 block to map the read sequences to the reference sequence.

bowtie2 = Bowtie2;

Add the blocks to the pipeline.

addBlock(P,[bowtie2build,bowtie2],["bowtie2build","bowtie2"]);

Get the list of names of all the required input ports from every block in the pipeline that are needed to be set or connected. IndexBaseName is an input port of both bowtie2build and bowtie2 block. Reads1File is the input port of the bowtie2 block and ReferenceFASTAFile is the input of bowtie2build block.

portnames = inputNames(P)
portnames = 1×3 string
    "IndexBaseName"    "Reads1Files"    "ReferenceFASTAFiles"

Some blocks have optional input ports. To see the names of these ports, set IncludeOptional=true. For instance, the Bowtie2 block has an optional input port (Reads2Files) that accepts files for the second mate reads when you have paired-end read data.

allportnames = inputNames(P,IncludeOptional=true)
allportnames = 1×4 string
    "IndexBaseName"    "Reads1Files"    "Reads2Files"    "ReferenceFASTAFiles"

Create an input structure to set the input port values of the bowtie2 and bowtie2build blocks. Specifically, set IndexBaseName to "Dmel_chr4" which is the base name for the reference index files for the Drosophila genome. Set Reads1Files to "SRR6008575_10k_1.fq" and Reads2Files to "SRR6008575_10k_2.fq". Set ReferenceFASTAFile to "Dmel_chr4.fa". These read files are already provided with the toolbox.

inputStruct.IndexBaseName = "Dmel_chr4";
inputStruct.Reads1Files   = "SRR6008575_10k_1.fq";
inputStruct.Reads2Files   = "SRR6008575_10k_2.fq";
inputStruct.ReferenceFASTAFiles = "Dmel_chr4.fa";

Optionally, you can compile and check if the input structure is set up correctly. Note that this compilation also happens automatically when you run the pipeline.

compile(P,inputStruct);

Run the pipeline using the structure as an input.

run(P,inputStruct);

Get the bowtie2 block result after the pipeline finishes running.

wait(P);
mappedFile = results(P,bowtie2)
mappedFile = struct with fields:
    SAMFile: [1×1 bioinfo.pipeline.datatype.File]

The Bowtie2 block generates a SAM file that contains the mapped results. To see the location of the file, use unwrap.

unwrap(mappedFile.SAMFile)

Input Arguments

collapse all

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

Input structure to satisfy unconnected input ports, specified as a structure.

The field names of inputStruct must match the names of unconnected ports in the pipeline.

Tip

Use inputNames to get the list of names for all unconnected input ports and use them as field names in inputStruct.

Data Types: struct

More About

collapse all

Satisfy Input Ports

All required input ports of every block in a pipeline must be satisfied before you can run the pipeline.

To satisfy an input port, you must do one of the following:

  • Connect to another port.

  • Set the value of the input port, that is, myBlock.Inputs.PropertyName.Value. For example, consider a BamSort block. To specify the name of a BAM file as the block input value, set the value as bamsortBlock.Inputs.BAMFile.Value = "ex1.bam".

  • Pass in an input structure by calling run(pipeline,inputStruct), where inputStruct has the field name equivalent to the input port name and the field value as the input port value.

Version History

Introduced in R2023a