JWS-112 Bumping version of ClustalO (src, binaries and windows) to version 1.2.4.
[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 280 2013-05-16 16:04:12Z fabian $
19  */
20
21
22 #include <stdio.h>
23
24 /* see clustal-omega.c for documentation */
25
26 /* Include clustal-omega's header. That's all you need 
27  *
28  * If you developing in C++, use the following instead:
29  * extern "C" {
30  * #include "clustal-omega.h"
31  * }
32  */
33 #include "clustal-omega.h"
34
35
36 int
37 main(int argc, char **argv)
38 {
39     /* the multiple sequence structure */
40     mseq_t *prMSeq = NULL;
41     /* for openmp: number of threads to use */
42     int iThreads = 1;
43     /* alignment options to use */
44     opts_t rAlnOpts;
45     /* an input file */
46     char *pcSeqInfile;
47     int iAux;
48
49
50     /* Must happen first: setup logger */
51     LogDefaultSetup(&rLog);
52
53     SetDefaultAlnOpts(&rAlnOpts);
54
55     InitClustalOmega(iThreads);
56
57     /* Get sequence input file name from command line
58      */
59     if (argc!=2) {
60         Log(&rLog, LOG_FATAL, "Need sequence file as argument");
61     }
62     pcSeqInfile = argv[1];
63
64     /* Read sequence file
65      */
66     NewMSeq(&prMSeq);
67     if (ReadSequences(prMSeq, pcSeqInfile,
68                       SEQTYPE_UNKNOWN,
69                       INT_MAX, INT_MAX)) {
70         Log(&rLog, LOG_FATAL, "Reading sequence file '%s' failed", pcSeqInfile);
71     }
72
73     /* Dump some info about the sequences
74      */
75     for (iAux=0; iAux<prMSeq->nseqs; iAux++) {
76         Log(&rLog, LOG_INFO, 
77              "Sequence no %d has the following name: %s",
78              iAux, prMSeq->sqinfo[iAux].name);
79         Log(&rLog, LOG_INFO, 
80              "Sequence no %d has the following residues: %s",
81              iAux, prMSeq->seq[iAux]);
82         /* more info can be found in prMSeq->sqinfo[iAux] */
83     }
84
85
86     /* Align the sequences without a profile (NULL)
87      */
88     if (Align(prMSeq, NULL, &rAlnOpts)) {
89         Log(&rLog, LOG_FATAL, "A fatal error happended during the alignment process");
90     }
91
92
93     /* Output of final alignment to stdout (NULL) as aligned fasta/a2m
94      */
95 #define LINE_WRAP 60
96     if (WriteAlignment(prMSeq, NULL, MSAFILE_A2M, LINE_WRAP)) {
97         Log(&rLog, LOG_FATAL, "Could not save alignment");
98     } 
99
100     FreeMSeq(&prMSeq);
101
102     Log(&rLog, LOG_INFO, "Successfull program exit");
103
104     return EXIT_SUCCESS;
105 }
106 /***   end of main()   ***/