Wrapper for Clustal Omega.
[jabaws.git] / binaries / src / clustalo / src / clustalo-api-test.c
1 /* -*- mode: c; tab-width: 4; c-basic-offset: 4;  indent-tabs-mode: nil -*- */
2
3 /*********************************************************************
4  * Clustal Omega - Multiple sequence alignment
5  *
6  * Copyright (C) 2010 University College Dublin
7  *
8  * Clustal-Omega is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This file is part of Clustal-Omega.
14  *
15  ********************************************************************/
16
17 /*
18  *  RCS $Id: clustalo-api-test.c 213 2011-03-11 16:10:15Z andreas $
19  */
20
21
22 #include <stdio.h>
23
24 /* Include clustal-omega's header. That's all you need 
25  *
26  * If you developing in C++, use the following instead:
27  * extern "C" {
28  * #include "clustal-omega.h"
29  * }
30  */
31 #include "clustal-omega.h"
32
33
34 int
35 main(int argc, char **argv)
36 {
37     /* the multiple sequence structure */
38     mseq_t *prMSeq = NULL;
39     /* for openmp: number of threads to use */
40     int iThreads = 1;
41     /* alignment options to use */
42     opts_t rAlnOpts;
43     /* an input file */
44     char *pcSeqInfile;
45     int iAux;
46
47     /* use LOGLEVEL_QUIET to make Clustal shut up */
48     iVerbosityLevel = LOGLEVEL_INFO;
49
50     SetDefaultAlnOpts(&rAlnOpts);
51
52     InitClustalOmega(iThreads);
53
54     /* Get sequence input file name from command line
55      */
56     if (argc!=2) {
57         Fatal("Need sequence file as argument");
58     }
59     pcSeqInfile = argv[1];
60
61     /* Read sequence file
62      */
63     NewMSeq(&prMSeq);
64     if (ReadSequences(prMSeq, pcSeqInfile,
65                       SEQTYPE_UNKNOWN,
66                       INT_MAX, INT_MAX)) {
67         Fatal("Reading sequence file '%s' failed", pcSeqInfile);
68     }
69
70     /* Dump some info about the sequences
71      */
72     for (iAux=0; iAux<prMSeq->nseqs; iAux++) {
73         Info(LOGLEVEL_INFO, 
74              "Sequence no %d has the following name: %s",
75              iAux, prMSeq->sqinfo[iAux].name);
76         Info(LOGLEVEL_INFO, 
77              "Sequence no %d has the following residues: %s",
78              iAux, prMSeq->seq[iAux]);
79         /* more info can be found in prMSeq->sqinfo[iAux] */
80     }
81
82
83     /* Align the sequences without a profile (NULL)
84      */
85     if (Align(prMSeq, NULL, & rAlnOpts)) {
86         Fatal("A fatal error happended during the alignment process");
87     }
88
89
90     /* Output of final alignment to stdout (NULL) as aligned fasta/a2m
91      */
92     if (WriteAlignment(prMSeq, NULL, MSAFILE_A2M)) {
93         Fatal("Could not save alignment");
94     } 
95
96     FreeMSeq(&prMSeq);
97
98     Info(LOGLEVEL_INFO, "Successfull program exit");
99
100     return EXIT_SUCCESS;
101 }
102 /***   end of main()   ***/