Main Content


Build Bowtie 2 index files



run(object,referenceFileNames,indexBaseName) builds Bowtie 2 index files from the reference sequence information saved in the FASTA files specified by referenceFileNames.

run requires the Bowtie 2 Support Package for Bioinformatics Toolbox™. If this support package is not installed, then the function provides a download link. For details, see Bioinformatics Toolbox Software Support Packages.


run(___,'IncludeAll',TF) specifies whether to use all object properties and their corresponding values when running bowtie2build. Specify this option after all other input arguments. By default, only the modified properties are used to run the function.


flag = run(___) returns an exit flag of the function using any of the input arguments in the previous syntaxes.


collapse all

Build a set of index files for the Drosophila genome. An error message appears if you do not have the Bioinformatics Toolbox Interface for Bowtie Aligner support package installed when you run the function. Click the provided link to download the package from the Add-on menu.

Create an options object.

buildOpt = Bowtie2BuildOptions;

Build the index files using the run function. For this example, the reference sequence Dmel_chr4.fa is already provided with the toolbox.

flag = run(buildOpt,'Dmel_chr4.fa', 'Dmel_chr4_index');

If the index build is successful, the function returns 0 and creates the index files (*.bt2) in the current folder. The files have the prefix 'Dmel_chr4_index'.

Input Arguments

collapse all

Options to build the index files, specified as a Bowtie2BuildOptions object.

Example: 'buildOpt'

Names of files with reference sequence information, specified as a string, character vector, string array, or cell array of character vectors.

Example: 'Dmel_chr4.fa'

Data Types: char | string | cell

Base name (prefix) of the reference index files, specified as a character vector or string. The index files are in the BT2 or BT21 format.

Example: 'Dmel_chr4'

Data Types: char | string

Flag to use all object properties and their corresponding values when you run the function, specified as true or false. By default, only the modified properties are used.

Example: true

Output Arguments

collapse all

Exit status of the function, returned as an integer. flag is 0 if the function runs without errors or warning. Otherwise, it is nonzero.


[1] Langmead, B., and S. Salzberg. "Fast gapped-read alignment with Bowtie 2." Nature Methods. 9, 2012, 357–359.

Version History

Introduced in R2018a