Clustal-Omega Documentation



For more information see


An Example Program

To use libclustalo you will have to include the clustal-omega.h header and link against libclustalo. For linking against libclustalo you will have to use a C++ compiler, no matter if your program was written in C or C++. See below (Using pkg-config / Figuring out compiler flags)) on how to figure out compiler flags with pkg-config.

Assuming Clustal Omega was installed in system-wide default directory (e.g. /usr), first compile (don't link yet) your source (for example code see section Example Source Code) and then link against libclustalo:

 $ gcc -c -ansi -Wall clustalo-api-test.c
 $ g++  -ansi -Wall -o clustalo-api-test clustalo-api-test.o  -lclustalo

Voila! Now you have your own alignment program based on Clustal Omega which can be run with

 $ ./clustalo-api-test <your-sequence-input>

It's best to use the same compiler that you used for compiling libclustal. If libclustal was compiled with OpenMP support, you will have to use OpenMP flags for you program as well.

Using pkg-config / Figuring out compiler flags

Clustal Omega comes with support for pkg-config, which means you can run

 $ pkg-config --cflags --libs clustalo

to figure out cflags and library flags needed to compile and link against libclustalo. This is especially handy if Clustal Omega was installed to a non-standard directory.

You might have to change PKG_CONFIG_PATH. For example, if you used the prefix $HOME/local/ for installation then you will first need to set PKG_CONFIG_PATH:

 $ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
 $ pkg-config --cflags --libs clustalo

To compile your source use as above but this time using proper flags:

 $ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
 $ gcc -c -ansi -Wall $(pkg-config --cflags clustalo) clustalo-api-test.c  
 $ g++  -ansi -Wall -o clustalo-api-test $(pkg-config --libs clustalo) clustalo-api-test.o 

Example Source Code

/* -*- mode: c; tab-width: 4; c-basic-offset: 4;  indent-tabs-mode: nil -*- */

 * Clustal Omega - Multiple sequence alignment
 * Copyright (C) 2010 University College Dublin
 * Clustal-Omega is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 * This file is part of Clustal-Omega.

 *  RCS $Id: clustalo-api-test.c 266 2011-10-20 16:04:11Z andreas $

#include <stdio.h>

/* see clustal-omega.c for documentation */

/* Include clustal-omega's header. That's all you need 
 * If you developing in C++, use the following instead:
 * extern "C" {
 * #include "clustal-omega.h"
 * }
#include "clustal-omega.h"

main(int argc, char **argv)
    /* the multiple sequence structure */
    mseq_t *prMSeq = NULL;
    /* for openmp: number of threads to use */
    int iThreads = 1;
    /* alignment options to use */
    opts_t rAlnOpts;
    /* an input file */
    char *pcSeqInfile;
    int iAux;

    /* Must happen first: setup logger */



    /* Get sequence input file name from command line
    if (argc!=2) {
        Log(&rLog, LOG_FATAL, "Need sequence file as argument");
    pcSeqInfile = argv[1];

    /* Read sequence file
    if (ReadSequences(prMSeq, pcSeqInfile,
                      INT_MAX, INT_MAX)) {
        Log(&rLog, LOG_FATAL, "Reading sequence file '%s' failed", pcSeqInfile);

    /* Dump some info about the sequences
    for (iAux=0; iAux<prMSeq->nseqs; iAux++) {
        Log(&rLog, LOG_INFO, 
             "Sequence no %d has the following name: %s",
             iAux, prMSeq->sqinfo[iAux].name);
        Log(&rLog, LOG_INFO, 
             "Sequence no %d has the following residues: %s",
             iAux, prMSeq->seq[iAux]);
        /* more info can be found in prMSeq->sqinfo[iAux] */

    /* Align the sequences without a profile (NULL)
    if (Align(prMSeq, NULL, &rAlnOpts)) {
        Log(&rLog, LOG_FATAL, "A fatal error happended during the alignment process");

    /* Output of final alignment to stdout (NULL) as aligned fasta/a2m
    if (WriteAlignment(prMSeq, NULL, MSAFILE_A2M)) {
        Log(&rLog, LOG_FATAL, "Could not save alignment");


    Log(&rLog, LOG_INFO, "Successfull program exit");

    return EXIT_SUCCESS;
/***   end of main()   ***/
Generated on Fri Aug 31 05:32:52 2012 for Clustal Omega by  doxygen 1.6.3