1 /* @source aligncopy application
2 **
3 ** Reads and writes (returns) alignments
4 ** @author Copyright (C) Jon Ison (jison@ebi.ac.uk)
5 ** @@
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 ******************************************************************************/
21 
22 #include "emboss.h"
23 
24 
25 
26 
27 /* @prog aligncopypair *********************************************************
28 **
29 ** Reads and writes (returns) alignments
30 **
31 ******************************************************************************/
32 
main(int argc,char ** argv)33 int main(int argc, char **argv)
34 {
35     /* Variable Declarations */
36     AjPSeqset seqset = NULL;
37     AjPAlign  align  = NULL;
38     AjPStr    name     = NULL;
39     AjPStr    comment  = NULL;
40     AjBool    append   = ajFalse;
41 
42     AjPSeq   *seqs     = NULL;
43     AjPStr    header   = NULL;
44     ajuint i;
45     ajuint j;
46     ajuint nseqs;
47 
48     ajuint imax;
49 
50     /* ACD File Processing */
51     embInit("aligncopypair", argc, argv);
52     seqset      = ajAcdGetSeqset("sequences");
53     align       = ajAcdGetAlign("outfile");
54     name       = ajAcdGetString("name");
55     comment    = ajAcdGetString("comment");
56     append     = ajAcdGetBoolean("append");
57 
58 
59     /* Application logic */
60     nseqs = ajSeqsetGetSize(seqset);
61     seqs = ajSeqsetGetSeqarray(seqset);
62     if(ajStrGetLen(name))
63         ajFmtPrintS(&header, "Alignment: %S\n\n", name);
64     ajStrAppendS(&header, comment);
65     if(append)
66       ajAlignSetHeaderApp(align, header);
67     else
68       ajAlignSetHeader(align, header);
69 
70     imax = nseqs-1;
71     for(i=0;i<imax;i++)
72     {
73         for(j=i+1;j<nseqs;j++)
74             ajAlignDefineSS(align, seqs[i], seqs[j]);
75     }
76 
77     ajAlignWrite(align);
78     ajAlignClose(align);
79 
80 
81     /* Memory management and exit */
82     ajSeqsetDel(&seqset);
83     ajAlignDel(&align);
84 
85     ajStrDel(&name);
86     ajStrDel(&comment);
87     ajStrDel(&header);
88     ajSeqDelarray(&seqs);
89 
90     embExit();
91 
92     return 0;
93 }
94 
95