0
|
1 /******************************************************************************
|
|
2 ** @source ggcsi
|
|
3 **
|
|
4 ** GC Skew Index: an index for strand-specific mutational bias
|
|
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 RESTify
|
|
11 ** @modified 2015/2/7 Refactor
|
|
12 ** @@
|
|
13 **
|
|
14 ** This program is free software; you can redistribute it and/or
|
|
15 ** modify it under the terms of the GNU General Public License
|
|
16 ** as published by the Free Software Foundation; either version 2
|
|
17 ** of the License, or (at your option) any later version.
|
|
18 **
|
|
19 ** This program is distributed in the hope that it will be useful,
|
|
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22 ** GNU General Public License for more details.
|
|
23 **
|
|
24 ** You should have received a copy of the GNU General Public License
|
|
25 ** along with this program; if not, write to the Free Software
|
|
26 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
27 ******************************************************************************/
|
|
28
|
|
29 #include "emboss.h"
|
|
30 #include "glibs.h"
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35 /* @prog ggcsi ****************************************************************
|
|
36 **
|
|
37 ** GC Skew Index: an index for strand-specific mutational bias
|
|
38 **
|
|
39 ******************************************************************************/
|
|
40
|
|
41 int main(int argc, char *argv[])
|
|
42 {
|
|
43 embInitPV("ggcsi", argc, argv, "GEMBASSY", "1.0.3");
|
|
44
|
|
45 AjPSeqall seqall;
|
|
46 AjPSeq seq;
|
|
47 AjPStr inseq = NULL;
|
|
48
|
|
49 AjPStr restid = NULL;
|
|
50 AjPStr seqid = NULL;
|
|
51
|
|
52 AjPStr base = NULL;
|
|
53 AjPStr url = NULL;
|
|
54
|
|
55 ajint window = 0;
|
|
56 AjBool at = 0;
|
|
57 AjBool purine = 0;
|
|
58 AjBool keto = 0;
|
|
59 AjBool pval = 0;
|
|
60 AjPStr version = NULL;
|
|
61
|
|
62 AjPStr tmpname = NULL;
|
|
63 AjPSeqout tmpout = NULL;
|
|
64 AjPFilebuff tmpbuff = NULL;
|
|
65
|
|
66 AjPStr tmp = NULL;
|
|
67 AjPStr parse = NULL;
|
|
68 AjPStr gcsi = NULL;
|
|
69 AjPStr sa = NULL;
|
|
70 AjPStr dist = NULL;
|
|
71 AjPStr z = NULL;
|
|
72 AjPStr p = NULL;
|
|
73
|
|
74 AjPStrTok handle = NULL;
|
|
75
|
|
76 AjPFile outf = NULL;
|
|
77
|
|
78 seqall = ajAcdGetSeqall("sequence");
|
|
79 window = ajAcdGetInt("window");
|
|
80 at = ajAcdGetBoolean("at");
|
|
81 purine = ajAcdGetBoolean("purine");
|
|
82 keto = ajAcdGetBoolean("keto");
|
|
83 pval = ajAcdGetBoolean("pval");
|
|
84 version = ajAcdGetSelectSingle("gcsi");
|
|
85 outf = ajAcdGetOutfile("outfile");
|
|
86
|
|
87 base = ajStrNewC("rest.g-language.org");
|
|
88
|
|
89 gAssignUniqueName(&tmpname);
|
|
90 ajStrAppendC(&tmpname, ".fasta");
|
|
91
|
|
92 while(ajSeqallNext(seqall, &seq))
|
|
93 {
|
|
94 tmpout = ajSeqoutNew();
|
|
95
|
|
96 if(!ajSeqoutOpenFilename(tmpout, tmpname))
|
|
97 {
|
|
98 embExitBad();
|
|
99 }
|
|
100
|
|
101 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta"));
|
|
102 ajSeqoutWriteSeq(tmpout, seq);
|
|
103 ajSeqoutClose(tmpout);
|
|
104 ajSeqoutDel(&tmpout);
|
|
105
|
|
106 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
|
|
107 gFilePostSS(url, tmpname, &restid);
|
|
108 ajStrDel(&url);
|
|
109 ajSysFileUnlinkS(tmpname);
|
|
110
|
|
111 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
|
|
112
|
|
113 if(ajStrGetLen(seqid) == 0)
|
|
114 {
|
|
115 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
|
|
116 }
|
|
117
|
|
118 if(ajStrGetLen(seqid) == 0)
|
|
119 {
|
|
120 ajWarn("No valid header information\n");
|
|
121 }
|
|
122
|
|
123 url = ajStrNew();
|
|
124
|
|
125 ajFmtPrintS(&url, "http://%S/%S/gcsi/window=%d/at=%d/purine=%d/"
|
|
126 "keto=%d/p=%d/version=%d/", base, restid, window, at, purine,
|
|
127 keto, pval, version);
|
|
128
|
|
129 if(!gFilebuffURLS(url, &tmpbuff))
|
|
130 {
|
|
131 ajDie("Failed to download result from:\n%S\n", url);
|
|
132 }
|
|
133
|
|
134 ajBuffreadLine(tmpbuff, &tmp);
|
|
135
|
|
136 parse = ajStrNew();
|
|
137 gcsi = ajStrNew();
|
|
138 sa = ajStrNew();
|
|
139 dist = ajStrNew();
|
|
140 z = ajStrNew();
|
|
141 p = ajStrNew();
|
|
142
|
|
143 ajStrRemoveLastNewline(&tmp);
|
|
144
|
|
145 handle = ajStrTokenNewC(tmp, ",");
|
|
146
|
|
147 while (ajStrTokenNextParse(handle, &parse))
|
|
148 {
|
|
149 if (ajStrIsFloat(parse))
|
|
150 {
|
|
151 if(!ajStrGetLen(gcsi))
|
|
152 ajStrAssignS(&gcsi, parse);
|
|
153 else if(!ajStrGetLen(sa))
|
|
154 ajStrAssignS(&sa, parse);
|
|
155 else if(!ajStrGetLen(dist))
|
|
156 ajStrAssignS(&dist, parse);
|
|
157 else if(!ajStrGetLen(z))
|
|
158 ajStrAssignS(&z, parse);
|
|
159 else if(!ajStrGetLen(p))
|
|
160 ajStrAssignS(&p, parse);
|
|
161 }
|
|
162 }
|
|
163
|
|
164 tmp = ajFmtStr("Sequence: %S GCSI: %S SA: %S DIST: %S",
|
|
165 seqid, gcsi, sa, dist);
|
|
166
|
|
167 if(pval)
|
|
168 tmp = ajFmtStr("%S Z: %S P: %S", tmp, z, p);
|
|
169
|
|
170 ajFmtPrintF(outf, "%S\n", tmp);
|
|
171
|
|
172 ajStrDel(&tmp);
|
|
173 ajStrDel(&parse);
|
|
174 ajStrDel(&gcsi);
|
|
175 ajStrDel(&sa);
|
|
176 ajStrDel(&dist);
|
|
177 ajStrDel(&z);
|
|
178 ajStrDel(&p);
|
|
179
|
|
180 ajStrDel(&inseq);
|
|
181 }
|
|
182
|
|
183 ajFileClose(&outf);
|
|
184
|
|
185 ajSeqallDel(&seqall);
|
|
186 ajSeqDel(&seq);
|
|
187 ajStrDel(&seqid);
|
|
188
|
|
189 embExit();
|
|
190
|
|
191 return 0;
|
|
192 }
|