Stockholm and Other Multiple-Sequence Alignment Formats

  • Multiple-sequence alignment (MSA) formats are used to store and exchange alignments of DNA, RNA, or protein sequences. A multiple-sequence alignment arranges related sequences into rows so that corresponding positions can be compared. Gaps are introduced where necessary to represent insertions and deletions, allowing researchers to investigate conserved regions, evolutionary changes, sequence motifs, functional domains, and relationships among genes or proteins. Common alignment formats include Stockholm, Clustal, aligned FASTA, PHYLIP, MAF, MSF, and A3M. Each format has its own structure, conventions, and applications in bioinformatics.
  • The Stockholm format is a flexible text-based format designed to represent multiple-sequence alignments together with associated biological annotations. It is widely used for protein and RNA families, particularly in resources such as Pfam and Rfam. A Stockholm file begins with the header # STOCKHOLM 1.0 and ends with the terminator //. Between these markers, it contains aligned sequences and optional annotation records. The format can preserve information about individual sequences, alignment columns, and the alignment as a whole.
  • A simple Stockholm alignment may look like this:

# STOCKHOLM 1.0

#=GF ID Example_Protein_Family

#=GF DE Example multiple-sequence alignment

Protein_A  MKTAYIAKQRQISFVKSHFSRQ

Protein_B  MKTAYIAKQRQISFVKSHFSRQ

Protein_C  MKTAYIAKQ-KISFVKSHFSRQ

//

  • In this example, each sequence is identified by a name followed by its aligned sequence. The hyphen in Protein_C represents a gap at that alignment position. All aligned sequences must have the same total alignment length, although a Stockholm file may store long alignments in multiple blocks. The header identifies the file format, while the final // marks the end of the alignment record.
  • One of the major advantages of Stockholm is its annotation system. It supports several types of metadata, identified by standardized annotation tags. General file annotations use the #=GF prefix, sequence-specific annotations use #=GS, column-specific annotations use #=GC, and sequence-and-column annotations use #=GR. These annotation types allow researchers to store information that cannot be represented by aligned sequence characters alone.
  • The #=GF annotation describes the alignment or sequence family as a whole. Common examples include ID for an identifier, AC for an accession, DE for a description, and AU for an author. The #=GS annotation provides information about individual sequences, such as accession numbers, descriptions, or species information. The #=GC annotation describes alignment columns and can represent consensus sequences, reference positions, or secondary-structure information. The #=GR annotation describes a particular sequence at each alignment position, including residue-level secondary structure or confidence information.
  • A Stockholm file containing several annotation types may look like this:

# STOCKHOLM 1.0

#=GF ID Example_Family

#=GF AC PF00000

#=GF DE Example protein family

Protein_A  MKTAYIAKQRQISFVKSHFSRQ

Protein_B  MKTAYIAKQRQISFVKSHFSRQ

Protein_C  MKTAYIAKQ-KISFVKSHFSRQ

#=GS Protein_A DE Example protein from species A

#=GS Protein_B DE Example protein from species B

#=GS Protein_C DE Example protein from species C

#=GC RF       xxxxxxxxxxxxxxxxxxxxxx

#=GC SS_cons  HHHHHHHHHHHHHHHHHHHHHH

//

  • Here, RF represents a reference annotation for alignment columns, while SS_cons represents consensus secondary-structure annotation. The exact interpretation of annotation symbols depends on the annotation type and the resource producing the file. Stockholm files may also contain per-sequence annotations, such as SS for secondary structure and PP for posterior probability or confidence information in relevant applications. These annotations make Stockholm particularly useful for curated protein and RNA families, where sequence conservation and structural features are studied together.
  • Stockholm supports interleaved alignments, meaning that long sequences can be divided into consecutive alignment blocks. Corresponding fragments from different sequences are placed together in each block, and the blocks are concatenated to reconstruct the complete alignment. Annotation lines can also be divided across blocks. This makes the format convenient for displaying and managing long alignments while retaining annotations associated with sequences and alignment positions.
  • The Clustal format is another widely used text-based format for multiple-sequence alignments. It is associated with the Clustal family of alignment programs, including ClustalW and Clustal Omega. A Clustal file begins with a header such as CLUSTAL or a program-specific version of that label. The header may be followed by descriptive information, aligned sequence blocks, and consensus lines indicating conserved or similar positions.
  • A simplified Clustal alignment may look like this:

CLUSTAL W multiple sequence alignment

Protein_A   MKTAYIAKQRQISFVKSHFSRQ

Protein_B   MKTAYIAKQRQISFVKSHFSRQ

Protein_C   MKTAYIAKQ-KISFVKSHFSRQ

            ********* ************

  • The sequence names are followed by aligned sequence fragments. The consensus line uses symbols to indicate conservation or similarity. In commonly used Clustal output, an asterisk indicates that all sequences have the same residue at a position. A colon indicates strong conservation of residues with similar properties, while a period indicates weaker similarity. A blank position indicates that the column does not meet the program’s conservation criteria. These symbols describe alignment conservation and are not part of the biological sequences themselves.
  • Clustal files can also be interleaved. In this arrangement, an alignment is displayed in blocks, with each sequence contributing a fragment to each block. The sequence fragments are assembled in order to reconstruct the complete alignment. Clustal is widely supported by alignment viewers, sequence-analysis software, and phylogenetic tools. It is especially convenient for visual inspection because sequence blocks and conservation patterns are displayed together.
  • The aligned FASTA format is an extension of the familiar FASTA sequence format. Ordinary FASTA stores individual sequences, while aligned FASTA stores sequences that have already been aligned. Each sequence begins with a header line starting with >, followed by its aligned sequence. Gaps are represented by characters such as hyphens or, in some applications, periods. All sequences in a valid rectangular multiple-sequence alignment must have the same aligned length.
  • An aligned FASTA file may look like this:

>Protein_A

MKTAYIAKQRQISFVKSHFSRQ

>Protein_B

MKTAYIAKQRQISFVKSHFSRQ

>Protein_C

MKTAYIAKQ-KISFVKSHFSRQ

  • Aligned FASTA is simple, readable, and widely compatible with sequence-analysis tools. It is useful for storing alignments that need to be processed programmatically or supplied to downstream applications. However, the basic format does not provide a standardized mechanism for recording alignment-wide annotations, consensus secondary structure, residue confidence, or detailed column-specific metadata. Such information may be stored in sequence descriptions or separate files, but these approaches are less standardized than the annotation system in Stockholm.
  • The PHYLIP format was developed for phylogenetic analysis and is commonly used to store aligned DNA, RNA, and protein sequences. A PHYLIP alignment typically begins with two numbers: the number of sequences and the alignment length. These are followed by sequence names and aligned sequence data. PHYLIP supports sequential and interleaved representations, depending on the software and file conventions.
  • A simplified sequential PHYLIP alignment may look like this:

3 22

Protein_A  MKTAYIAKQRQISFVKSHFSRQ

Protein_B  MKTAYIAKQRQISFVKSHFSRQ

Protein_C  MKTAYIAKQ-KISFVKSHFSRQ

  • The first number indicates that the alignment contains three sequences, while the second indicates that each aligned sequence has 22 positions. Traditional strict PHYLIP conventions restrict sequence names to a limited number of characters, commonly ten. Relaxed PHYLIP variants allow longer names, but support differs among programs. This distinction is important because sequence identifiers may be truncated or misinterpreted when a file is transferred between software packages.
  • In interleaved PHYLIP, each sequence is divided into fragments, and corresponding fragments are grouped into blocks. The first block contains the initial sequence fragments, while later blocks contain the remaining positions in the same sequence order. Interleaved files are often useful for large alignments and older phylogenetic applications. Researchers should verify whether the receiving software expects strict or relaxed PHYLIP and whether it supports sequential or interleaved input.
  • The Multiple Alignment Format (MAF) is used primarily for representing large-scale genomic multiple alignments, particularly alignments involving multiple species or genome assemblies. Unlike formats such as Stockholm and Clustal, which are commonly used for protein or gene-family alignments, MAF is designed to represent genomic regions with information about sequence sources, genomic coordinates, strand orientation, and aligned blocks. It is widely used in comparative genomics and genome-wide evolutionary analysis.
  • A MAF file begins with a header such as ##maf version=1. Each alignment block is separated from the next by a blank line. A typical block contains an a line describing alignment-level information and one or more s lines describing aligned sequence segments. Additional line types can provide information about sequence quality, empty regions, or component relationships.
  • A simplified MAF alignment block may look like this:

##maf version=1

a score=1200

s human.chr1 100 20 + 1000 ATGCTAGCTAGCTAGCTAGC

s mouse.chr1 150 20 + 1200 ATGCTAG-TAGCTAGCTAGC

  • The a line introduces an alignment block and may contain a score or other attributes. Each s line identifies a sequence source, the start coordinate, the size of the aligned component excluding gap characters, the strand, the total source sequence size, and the aligned text. MAF start coordinates are zero-based, and the size field counts non-gap bases in the component. The strand field indicates the orientation of the aligned sequence relative to its source. These coordinate conventions are important when mapping aligned regions back to reference genomes.
  • MAF can also contain i lines describing information about the sequence component’s relationship to adjacent alignment blocks, e lines representing empty components, and q lines containing base-quality information. The i and e records are particularly useful in genome alignment datasets where not every species is represented in every aligned region. MAF files are used in comparative genome projects, conservation analysis, evolutionary studies, and the identification of conserved non-coding regions. Because genomic alignments can contain many blocks across large genomes, MAF is particularly suitable for representing local alignments across multiple species rather than a single continuous alignment of complete chromosomes.
  • The MSF format, also known as the Multiple Sequence Format, is a text-based alignment format historically associated with the GCG sequence-analysis software environment. It stores multiple aligned sequences along with information such as sequence names, lengths, checksums, and alignment dimensions. MSF files generally contain a header describing the alignment, followed by individual sequence records arranged in blocks.
  • A simplified MSF-style file may look like this:

!!AA_MULTIPLE_ALIGNMENT 1.0

  MSF: 22  Type: P  Check: 0000 ..

 Name: Protein_A  Len: 22  Check: 0000  Weight: 1.00

 Name: Protein_B  Len: 22  Check: 0000  Weight: 1.00

 Name: Protein_C  Len: 22  Check: 0000  Weight: 1.00

//

Protein_A  MKTAYIAKQRQISFVKSHFSRQ

Protein_B  MKTAYIAKQRQISFVKSHFSRQ

Protein_C  MKTAYIAKQ-KISFVKSHFSRQ

  • This example illustrates the general organization of an MSF file; exact header fields and syntax depend on the MSF variant and software implementation. The format was historically important in sequence analysis, but it is less commonly used in modern workflows than FASTA, Stockholm, Clustal, and PHYLIP. It may still be encountered in archived datasets and older bioinformatics pipelines.
  • The A3M format is used in profile-based protein sequence analysis and is closely associated with tools in the HH-suite, including HHblits and HHsearch. It is derived from aligned FASTA conventions but uses a specialized representation of insertions and match states. In A3M, uppercase letters generally represent residues aligned to match states, lowercase letters represent insertions relative to the profile, and hyphens represent deletions or gaps in match positions. Insertions are commonly stored without padding them to the same length across all sequences. As a result, A3M files are not ordinary rectangular alignments in the same sense as conventional aligned FASTA or Clustal files.
  • A simplified A3M example may look like this:

>Query

MKTAYIAKQRQISFVK

>Homolog_1

MKTAYIAKaaQRQISFVK

>Homolog_2

MKTAYI-KQRQISFVK

  • Here, lowercase aa in Homolog_1 represents an insertion relative to the match-state alignment. A3M is useful for representing sequence information in profile-based methods, where the distinction between match states and insertions is important. It should be handled using software that understands A3M conventions rather than treated as an ordinary aligned FASTA file.
  • Several bioinformatics libraries support the reading, writing, and conversion of multiple-sequence alignment formats. Biopython provides the Bio.AlignIO module, which supports formats including Stockholm, Clustal, FASTA, PHYLIP, and MAF. The following Python example reads a Stockholm alignment and displays basic information about it:

from Bio import AlignIO

# Read a Stockholm alignment

alignment = AlignIO.read(“alignment.sto”, “stockholm”)

# Display alignment information

print(“Number of sequences:”, len(alignment))

print(“Alignment length:”, alignment.get_alignment_length())

# Display sequence names and aligned sequences

for record in alignment:

    print(record.id)

    print(record.seq)

Biopython can also read and write Clustal and aligned FASTA files:

from Bio import AlignIO

# Read a Clustal alignment

clustal_alignment = AlignIO.read(“alignment.aln”, “clustal”)

# Write the alignment in FASTA format

AlignIO.write(

    clustal_alignment,

    “alignment.fasta”,

    “fasta”

)

# Write the alignment in Stockholm format

AlignIO.write(

    clustal_alignment,

    “alignment.sto”,

    “stockholm”

)

  • The R programming language also provides tools for working with multiple-sequence alignments. The Biostrings and msa packages in Bioconductor support sequence handling and alignment workflows, while ape and other phylogenetic packages can process alignments in formats supported by their respective functions. The seqinr package also provides functions for reading and handling biological sequence data. The exact formats accepted by each package and function should be checked before using them in automated pipelines.
  • Alignment software commonly produces one or more of these formats. Clustal Omega can generate Clustal and other alignment outputs, while MAFFT supports several alignment input and output conventions. MUSCLE is widely used for multiple-sequence alignment and can produce common alignment representations. HMMER and profile-based resources frequently use Stockholm alignments, particularly when working with protein families and profile hidden Markov models. HH-suite tools use A3M and related profile-alignment representations. Genome alignment tools and comparative genomics pipelines commonly use MAF for large-scale multi-species alignments.
  • Multiple-sequence alignment formats are used in many areas of bioinformatics. In protein-family analysis, Stockholm files can preserve conserved residues, secondary-structure annotations, and family metadata. In molecular phylogenetics, aligned FASTA, PHYLIP, and NEXUS-compatible alignment data can be used as input for evolutionary tree reconstruction. In comparative genomics, MAF files support the identification of conserved genomic regions, evolutionary changes, and species-specific insertions or deletions. In protein structure and function studies, alignment annotations help identify conserved functional residues, catalytic sites, and regions important for molecular interactions.
  • The formats also support the analysis of sequence motifs, evolutionary conservation, domain architecture, gene families, and RNA structure. Multiple-sequence alignments can be used to construct position-specific scoring matrices and profile hidden Markov models. These models are important for identifying remote homologues and detecting conserved protein or RNA families. Alignment data can also support the prediction of functional residues, the study of evolutionary constraints, and the comparison of homologous sequences across species.
  • Choosing the appropriate alignment format depends on the type of data, the intended analysis, and the software being used. Stockholm is especially suitable when sequence-family annotations and structural information need to be retained. Clustal is convenient for displaying alignments and conservation patterns. Aligned FASTA provides a simple and widely compatible representation for sequence-processing workflows. PHYLIP is useful for phylogenetic applications, particularly where traditional programs require it. MAF is designed for genomic alignments involving coordinates and multiple genome assemblies. MSF is mainly encountered in legacy datasets, while A3M is important for profile-based protein sequence analysis.
  • Researchers should pay attention to sequence identifiers, alignment lengths, gap conventions, coordinate systems, and annotation preservation when converting between formats. Some conversions may discard annotations or change identifiers, particularly when moving from Stockholm to formats that do not support equivalent metadata. MAF coordinates must be interpreted according to its zero-based coordinate convention, and A3M insertion characters must not be treated as ordinary aligned positions without considering its match-state representation. PHYLIP name restrictions can also cause problems when long sequence identifiers are truncated. For reproducible analyses, the original alignment file, software name and version, alignment parameters, sequence database release, and any format-conversion steps should be preserved.
  • Stockholm and other multiple-sequence alignment formats provide essential ways to store and exchange aligned biological sequences. Each format addresses different requirements, ranging from simple sequence comparison to annotated protein-family alignments and large-scale comparative genome analysis. Understanding their structures, conventions, strengths, and limitations enables researchers to select suitable formats, preserve important biological information, and perform reliable and reproducible sequence-analysis workflows.
Author:

Leave a Reply

Your email address will not be published. Required fields are marked *