Main Content


Bioinformatics pipeline block to create BWA indices from reference sequences

Since R2023a

  • bwaindex block icon


A BwaIndex block enables you to create BWA index files from reference sequences.

The block requires the BWA Support Package for Bioinformatics Toolbox™. If the support package is not installed, then a download link is provided. For details, see Bioinformatics Toolbox Software Support Packages.




b = bioinfo.pipeline.block.BwaIndex creates a BwaIndex block.

b = bioinfo.pipeline.block.BwaIndex(options) also specifies additional options.

b = bioinfo.pipeline.block.BwaIndex(Name=Value) specifies additional options as the property names and values of a BWAIndexOptions object. This object is set as the value of the Options property of the block.

Input Arguments

expand all

BwaIndex options, specified as a BWAIndexOptions object, string, or character vector.

If you are specifying a string or character vector, it must be in the bwa native syntax (prefixed by a dash) [1][2].

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.


The following list of arguments is a partial list. For the complete list, refer to the properties of BwaIndexOptions object.

Algorithm to construct the BWT (Burrows-Wheeler transform) index, specified as a character vector or string. Options are:

  • 'is' — Linear-time algorithm. The memory requirement for using this option is 5.37 times the size of the database. You cannot use this option if your database is larger than 2 GB.

  • 'bwtsw' — BWT-SW algorithm.

The default algorithm is chosen automatically based on the size of the reference genome.

Data Types: char | string

Number of bases processed per batch in the bwtsw algorithm, specified as a positive scalar.

Data Types: double


expand all

Function to handle errors from the run method of the block, specified as a function handle. The handle specifies the function to call if the run method encounters an error within a pipeline. For the pipeline to continue after a block fails, ErrorHandler must return a structure that is compatible with the output ports of the block. The error handling function is called with the following two inputs:

  • Structure with these fields:

    identifierIdentifier of the error that occurred
    messageText of the error message
    indexLinear index indicating which block process failed in the parallel run. By default, the index is 1 because there is only one run per block. For details on how block inputs can be split across different dimensions for multiple run calls, see Bioinformatics Pipeline SplitDimension.

  • Input structure passed to the run method when it fails

Data Types: function_handle

This property is read-only.

Input ports of the block, specified as a structure. The field names of the structure are the names of the block input ports, and the field values are bioinfo.pipeline.Input objects. These objects describe the input port behaviors. The input port names are the expected field names of the input structure that you pass to the block run method.

The BwaIndex block Inputs structure has the following field:

  • ReferenceFASTAFile — Name of the FASTA-formatted reference sequence file. This input is a required input that must be satisfied. The default value is a bioinfo.pipeline.datatypes.Unset object, which means that the input value is not set yet.

Data Types: struct

This property is read-only.

Output ports of the block, specified as a structure. The field names of the structure are the names of the block output ports, and the field values are bioinfo.pipeline.Output objects. These objects describe the output port behaviors. The field names of the output structure returned by the block run method are the same as the output port names.

The BwaIndex block Outputs structure has the field named IndexBaseName and writes the index files to the same location where the reference file (ReferenceFASTAFile) is.

Data Types: struct

BwaIndex options, specified as a BWAIndexOptions object. The default value is a default BwaIndexOptions object.

Object Functions

compilePerform block-specific additional checks and validations
copyCopy array of handle objects
emptyInputsCreate input structure for use with run method
evalEvaluate block object
runRun block object


collapse all

Create a set of BWA index files for chromosome 4 of the Drosophila genome.

import bioinfo.pipeline.block.*
import bioinfo.pipeline.Pipeline
FC = FileChooser(which("Dmel_chr4.fa"));
BI = BwaIndex;
P = Pipeline;
addBlock(P,[FC BI]);

% Set the custom location to save the index files.
mkdir C:\BWAIndexFiles\
BI.Options.Prefix = "C:\BWAIndexFiles\BWAIndex_Dmel_chr4";

R = results(P,BI)
R = 

  struct with fields:

    IndexBaseName: "C:\BWAIndexFiles\BWAIndex_Dmel_chr4"

The generated index files are now saved under the folder that you have specified.


[1] Li, Heng, and Richard Durbin. “Fast and Accurate Short Read Alignment with Burrows-Wheeler Transform.” Bioinformatics 25, no. 14 (July 15, 2009): 1754–60.

[2] Li, Heng, and Richard Durbin. “Fast and Accurate Long-Read Alignment with Burrows–Wheeler Transform.” Bioinformatics 26, no. 5 (March 1, 2010): 589–95.

Version History

Introduced in R2023a