Clustal Omega 1.2.4
Clustal-Omega Documentation

Introduction

For more information see http://www.clustal.org/

API

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 280 2013-05-16 16:04:12Z fabian $
*/
#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"
int
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 */
SetDefaultAlnOpts(&rAlnOpts);
InitClustalOmega(iThreads);
/* 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
*/
NewMSeq(&prMSeq);
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++) {
"Sequence no %d has the following name: %s",
iAux, prMSeq->sqinfo[iAux].name);
"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
*/
#define LINE_WRAP 60
if (WriteAlignment(prMSeq, NULL, MSAFILE_A2M, LINE_WRAP)) {
Log(&rLog, LOG_FATAL, "Could not save alignment");
}
FreeMSeq(&prMSeq);
Log(&rLog, LOG_INFO, "Successfull program exit");
return EXIT_SUCCESS;
}
/*** end of main() ***/
#define LINE_WRAP
void SetDefaultAlnOpts(opts_t *opts)
Sets members of given user opts struct to default values.
Definition clustal-omega.c:189
int Align(mseq_t *prMSeq, mseq_t *prMSeqProfile, opts_t *prOpts)
The main alignment function which wraps everything else.
Definition clustal-omega.c:960
void InitClustalOmega(int iNumThreadsToUse)
FIXME.
Definition clustal-omega.c:622
log_t rLog
Definition log.c:34
void Log(log_t *prLog, int iLevel, char *pcFmt,...)
Log to certain level.
Definition log.c:186
void LogDefaultSetup(log_t *log)
Sets up default function pointers.
Definition log.c:152
#define LOG_FATAL
Definition log.h:36
#define LOG_INFO
Definition log.h:31
int WriteAlignment(mseq_t *mseq, const char *pcAlnOutfile, int outfmt, int iWrap, bool bResno)
Write alignment to file.
Definition seq.c:884
int ReadSequences(mseq_t *prMSeq, char *seqfile, int iSeqType, int iSeqFmt, bool bIsProfile, bool bDealignInputSeqs, int iMaxNumSeq, int iMaxSeqLen, char *pcHMMBatch)
reads sequences from file
Definition seq.c:420
void NewMSeq(mseq_t **prMSeq)
allocate and initialise new mseq_t
Definition seq.c:714
void FreeMSeq(mseq_t **mseq)
Frees an mseq_t and it's members and zeros all members.
Definition seq.c:817
#define SEQTYPE_UNKNOWN
Definition seq.h:32
structure for storing multiple sequences
Definition seq.h:47
int nseqs
Definition seq.h:48
char ** seq
Definition seq.h:57
SQINFO * sqinfo
Squid's sequence info structure. Index range: 0–nseq-1.
Definition seq.h:113
Definition clustal-omega.h:76