Main Content


Read multiple sequence alignment file


S = multialignread(File)
[Headers, Sequences] = multialignread(File)
... = multialignread(File, 'IgnoreGaps', IgnoreGapsValue)
... = multialignread(File, 'TimeOut', TimeOutValue)

Input Arguments


Multiple sequence alignment file specified by one of the following:

  • File name or path and file name

  • URL pointing to a file

  • MATLAB® character array that contains the text of a multiple sequence alignment file

You can read common multiple sequence alignment file types, such as ClustalW (.aln), GCG (.msf), and PHYLIP.

IgnoreGapsValueControls removing gap symbols, such as '-' or '.', from the sequences. Choices are true or false (default).
TimeOutValueConnection timeout in seconds, specified as a positive scalar. The default value is 5. For details, see here.

Output Arguments


MATLAB structure array containing the following fields:

  • Header — Header information from the file.

  • Sequence — Amino acid or nucleotide sequences.


Cell array containing the header information from the file.


Cell array containing the amino acid or nucleotide sequences.


S = multialignread(File) reads a multiple sequence alignment file. The file contains multiple sequence lines that start with a sequence header followed by an optional number (not used by multialignread) and a section of the sequence. The multiple sequences are broken into blocks with the same number of blocks for every sequence. To view an example multiple sequence alignment file, type open aagag.aln at the MATLAB command line.

The output, S, is a structure array where S.Header contains the header information and S.Sequence contains the amino acid or nucleotide sequences.

[Headers, Sequences] = multialignread(File) reads the file into separate variables, Headers and Sequences, which are cell arrays containing header information and amino acid or nucleotide sequences, respectively.

... = multialignread(File, 'IgnoreGaps', IgnoreGapsValue) controls the removal of any gap symbol, such as '-' or '.', from the sequences. Choices are true or false (default).

... = multialignread(File, 'TimeOut', TimeOutValue) sets the connection timeout (in seconds) to read data from a remote file or URL.


Read a multiple sequence alignment of the gag polyprotein for several HIV strains.

gagaa = multialignread('aagag.aln')

gagaa = 

1x16 struct array with fields:

Version History

Introduced before R2006a