0
|
1 /******************************************************************************
|
|
2 ** @source gaaui
|
|
3 **
|
|
4 ** Calculates various indeces of amino acid usage
|
|
5 **
|
|
6 ** @author Copyright (C) 2012 Hidetoshi Itaya
|
|
7 ** @version 1.0.3
|
|
8 ** @modified 2012/1/20 Hidetoshi Itaya Created!
|
|
9 ** @modified 2013/6/16 Revision 1
|
|
10 ** @modified 2015/2/7 Refactor
|
|
11 ** @@
|
|
12 **
|
|
13 ** This program is free software; you can redistribute it and/or
|
|
14 ** modify it under the terms of the GNU General Public License
|
|
15 ** as published by the Free Software Foundation; either version 2
|
|
16 ** of the License, or (at your option) any later version.
|
|
17 **
|
|
18 ** This program is distributed in the hope that it will be useful,
|
|
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ** GNU General Public License for more details.
|
|
22 **
|
|
23 ** You should have received a copy of the GNU General Public License
|
|
24 ** along with this program; if not, write to the Free Software
|
|
25 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
26 ******************************************************************************/
|
|
27
|
|
28 #include "emboss.h"
|
|
29 #include "glibs.h"
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34 /* @prog gaaui ****************************************************************
|
|
35 **
|
|
36 ** Calculates various indeces of amino acid usage
|
|
37 **
|
|
38 ******************************************************************************/
|
|
39
|
|
40 int main(int argc, char *argv[])
|
|
41 {
|
|
42 embInitPV("gaaui", argc, argv, "GEMBASSY", "1.0.3");
|
|
43
|
|
44 AjPSeqall seqall;
|
|
45 AjPSeq seq;
|
|
46 AjPStr inseq = NULL;
|
|
47
|
|
48 AjBool accid = ajFalse;
|
|
49 AjPStr restid = NULL;
|
|
50 AjPStr seqid = NULL;
|
|
51
|
|
52 AjPStr base = NULL;
|
|
53 AjPStr url = NULL;
|
|
54
|
|
55 AjPFile tmpfile = NULL;
|
|
56 AjPStr tmpname = NULL;
|
|
57
|
|
58 AjPFile outf = NULL;
|
|
59
|
|
60 seqall = ajAcdGetSeqall("sequence");
|
|
61 accid = ajAcdGetBoolean("accid");
|
|
62 outf = ajAcdGetOutfile("outfile");
|
|
63
|
|
64 base = ajStrNewC("rest.g-language.org");
|
|
65
|
|
66 gAssignUniqueName(&tmpname);
|
|
67
|
|
68 while(ajSeqallNext(seqall, &seq))
|
|
69 {
|
|
70 inseq = NULL;
|
|
71
|
|
72 if(!accid)
|
|
73 {
|
|
74 if(gFormatGenbank(seq, &inseq))
|
|
75 {
|
|
76 tmpfile = ajFileNewOutNameS(tmpname);
|
|
77 if(!tmpfile)
|
|
78 {
|
|
79 ajDie("Output file (%S) open error\n", tmpname);
|
|
80 }
|
|
81 ajFmtPrintF(tmpfile, "%S", inseq);
|
|
82 ajFileClose(&tmpfile);
|
|
83 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
|
|
84 gFilePostSS(url, tmpname, &restid);
|
|
85 ajStrDel(&url);
|
|
86 ajSysFileUnlinkS(tmpname);
|
|
87 }
|
|
88 else
|
|
89 {
|
|
90 ajWarn("Sequence does not have features\n"
|
|
91 "Proceeding with sequence accession ID\n");
|
|
92 accid = ajTrue;
|
|
93 }
|
|
94 }
|
|
95
|
|
96 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
|
|
97
|
|
98 if(ajStrGetLen(seqid) == 0)
|
|
99 {
|
|
100 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
|
|
101 }
|
|
102
|
|
103 if(ajStrGetLen(seqid) == 0)
|
|
104 {
|
|
105 ajWarn("No valid header information\n");
|
|
106 }
|
|
107
|
|
108 if(accid)
|
|
109 {
|
|
110 ajStrAssignS(&restid, seqid);
|
|
111 if(ajStrGetLen(seqid) == 0)
|
|
112 {
|
|
113 ajDie("Cannot proceed without header with -accid\n");
|
|
114 }
|
|
115
|
|
116 if(!gValID(seqid))
|
|
117 {
|
|
118 ajDie("Invalid accession ID:%S, exiting\n", seqid);
|
|
119 }
|
|
120 }
|
|
121
|
|
122 url = ajStrNew();
|
|
123
|
|
124 ajFmtPrintS(&url, "http://%S/%S/aaui/output=f/tag=gene", base, restid);
|
|
125
|
|
126 ajFmtPrintF(outf, "Sequence: %S\n", seqid);
|
|
127 if(!gFileOutURLS(url, &outf))
|
|
128 {
|
|
129 ajDie("Failed to download result from:\n%S\n", url);
|
|
130 }
|
|
131
|
|
132 ajStrDel(&url);
|
|
133 ajStrDel(&restid);
|
|
134 ajStrDel(&seqid);
|
|
135 ajStrDel(&inseq);
|
|
136 }
|
|
137
|
|
138 ajFileClose(&outf);
|
|
139
|
|
140 ajSeqallDel(&seqall);
|
|
141 ajSeqDel(&seq);
|
|
142 ajStrDel(&base);
|
|
143
|
|
144 embExit();
|
|
145
|
|
146 return 0;
|
|
147 }
|