1 /* @source backtranseq application
2 **
3 ** Backward translation to the most likely DNA sequence
4 **
5 ** @author Copyright (C) Alan Bleasby (ableasby@hgmp.mrc.ac.uk)
6 ** @@
7 **
8 ** This program is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License
10 ** as published by the Free Software Foundation; either version 2
11 ** of the License, or (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
22
23 #include "emboss.h"
24
25
26
27
28 /* @prog backtranseq **********************************************************
29 **
30 ** Back translate a protein sequence
31 **
32 ******************************************************************************/
33
main(int argc,char ** argv)34 int main(int argc, char **argv)
35 {
36 AjPSeqall seqall;
37 AjPSeq a = NULL;
38 AjPSeqout outf;
39 AjPCod codon;
40 AjPStr substr;
41 AjPStr back;
42
43 ajint beg;
44 ajint end;
45
46 embInit("backtranseq", argc, argv);
47
48 seqall = ajAcdGetSeqall("sequence");
49 codon = ajAcdGetCodon("cfile");
50 outf = ajAcdGetSeqoutall("outfile");
51 while(ajSeqallNext(seqall, &a))
52 {
53 substr = ajStrNew();
54 beg = ajSeqGetBegin(a);
55 end = ajSeqGetEnd(a);
56 ajStrAssignSubS(&substr,ajSeqGetSeqS(a),beg-1,end-1);
57
58 back = ajStrNew();
59 ajCodSetBacktranslate(codon);
60 ajCodBacktranslate(&back,substr,codon);
61
62 ajSeqAssignSeqS (a, back);
63 ajSeqSetNuc (a);
64
65 ajSeqoutWriteSeq(outf,a);
66 }
67
68 ajStrDel(&back);
69 ajStrDel(&substr);
70 ajSeqoutClose(outf);
71 ajCodDel(&codon);
72
73 ajSeqallDel(&seqall);
74 ajSeqoutDel(&outf);
75 ajSeqDel(&a);
76
77 embExit();
78
79 return 0;
80 }
81