Browse code

add package to the repository

msa


git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/msa@102253 bc3139a8-67e5-0310-9ffc-ced21a209358

Sonali Arora authored on 10/04/2015 00:12:33
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,110 @@
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
+    int msa_c = 0;
50
+    char **msa_v = NULL;
51
+
52
+
53
+    /* Must happen first: setup logger */
54
+    LogDefaultSetup(&rLog);
55
+
56
+    SetDefaultAlnOpts(&rAlnOpts);
57
+
58
+    InitClustalOmega(iThreads);
59
+
60
+    /* Get sequence input file name from command line
61
+     */
62
+    if (argc!=2) {
63
+        Log(&rLog, LOG_FATAL, "Need sequence file as argument");
64
+    }
65
+    pcSeqInfile = argv[1];
66
+
67
+    /* Read sequence file
68
+     */
69
+    NewMSeq(&prMSeq);
70
+    if (ReadSequences(prMSeq, pcSeqInfile,
71
+                      SEQTYPE_UNKNOWN,
72
+                      INT_MAX, INT_MAX)) {
73
+        Log(&rLog, LOG_FATAL, "Reading sequence file '%s' failed", pcSeqInfile);
74
+    }
75
+
76
+    /* Dump some info about the sequences
77
+     */
78
+    for (iAux=0; iAux<prMSeq->nseqs; iAux++) {
79
+        Log(&rLog, LOG_INFO, 
80
+             "Sequence no %d has the following name: %s",
81
+             iAux, prMSeq->sqinfo[iAux].name);
82
+        Log(&rLog, LOG_INFO, 
83
+             "Sequence no %d has the following residues: %s",
84
+             iAux, prMSeq->seq[iAux]);
85
+        /* more info can be found in prMSeq->sqinfo[iAux] */
86
+    }
87
+
88
+
89
+    /* Align the sequences without a profile (NULL)
90
+     */
91
+    if (Align(prMSeq, NULL, &rAlnOpts)) {
92
+        Log(&rLog, LOG_FATAL, "A fatal error happended during the alignment process");
93
+    }
94
+
95
+
96
+    /* Output of final alignment to stdout (NULL) as aligned fasta/a2m
97
+     */
98
+#define LINE_WRAP 60
99
+    ClustalOmegaOutput msaOutput;
100
+    if (WriteAlignment(prMSeq, NULL, MSAFILE_A2M, LINE_WRAP, &msa_c, &msa_v)) {
101
+        Log(&rLog, LOG_FATAL, "Could not save alignment");
102
+    } 
103
+
104
+    FreeMSeq(&prMSeq);
105
+
106
+    Log(&rLog, LOG_INFO, "Successfull program exit");
107
+
108
+    return EXIT_SUCCESS;
109
+}
110
+/***   end of main()   ***/