comparison GEMBASSY-1.0.3/src/ggcskew.c @ 2:8947fca5f715 draft default tip

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:21:44 -0400
parents 84a17b3fad1f
children
comparison
equal deleted inserted replaced
1:84a17b3fad1f 2:8947fca5f715
1 /******************************************************************************
2 ** @source ggcskew
3 **
4 ** Calculates the GC skew of the input sequence
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 ggcskew **************************************************************
36 **
37 ** Calculates the GC skew of the input sequence
38 **
39 ******************************************************************************/
40
41 int main(int argc, char *argv[])
42 {
43 embInitPV("ggcskew", argc, argv, "GEMBASSY", "1.0.3");
44
45 AjPSeqall seqall;
46 AjPSeq seq;
47 AjPStr inseq = NULL;
48
49 AjBool accid = ajFalse;
50 AjPStr restid = NULL;
51 AjPStr seqid = NULL;
52
53 AjPStr base = NULL;
54 AjPStr url = NULL;
55
56 AjPStr tmpname = NULL;
57 AjPSeqout tmpout = NULL;
58
59 ajint window = 0;
60 ajint slide = 0;
61 AjBool cumulative = 0;
62 AjBool at = 0;
63 AjBool purine = 0;
64 AjBool keto = 0;
65
66 AjBool plot = 0;
67 AjPFile outf = NULL;
68 AjPFilebuff buff = NULL;
69 AjPGraph mult = NULL;
70
71 gPlotParams gpp;
72 AjPStr title = NULL;
73
74 seqall = ajAcdGetSeqall("sequence");
75 window = ajAcdGetInt("window");
76 slide = ajAcdGetInt("slide");
77 cumulative = ajAcdGetBoolean("cumulative");
78 at = ajAcdGetBoolean("at");
79 purine = ajAcdGetBoolean("purine");
80 keto = ajAcdGetBoolean("keto");
81
82 plot = ajAcdGetToggle("plot");
83 outf = ajAcdGetOutfile("outfile");
84 mult = ajAcdGetGraphxy("graph");
85
86 base = ajStrNewC("rest.g-language.org");
87
88 gAssignUniqueName(&tmpname);
89 ajStrAppendC(&tmpname, ".fasta");
90
91 while(ajSeqallNext(seqall, &seq))
92 {
93 tmpout = ajSeqoutNew();
94
95 if(!ajSeqoutOpenFilename(tmpout, tmpname))
96 {
97 embExitBad();
98 }
99
100 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta"));
101 ajSeqoutWriteSeq(tmpout, seq);
102 ajSeqoutClose(tmpout);
103 ajSeqoutDel(&tmpout);
104
105 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
106 gFilePostSS(url, tmpname, &restid);
107 ajStrDel(&url);
108 ajSysFileUnlinkS(tmpname);
109
110 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
111
112 if(ajStrGetLen(seqid) == 0)
113 {
114 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
115 }
116
117 if(ajStrGetLen(seqid) == 0)
118 {
119 ajWarn("No valid header information\n");
120 }
121
122 url = ajStrNew();
123
124 ajFmtPrintS(&url, "http://%S/%S/gcskew/window=%d/slide=%d/cumulative=%d/"
125 "at=%d/purine=%d/keto=%d/output=f/", base, restid, window,
126 slide, cumulative, at, purine, keto);
127
128 if(plot)
129 {
130 title = ajStrNew();
131
132 ajStrAppendC(&title, argv[0]);
133 ajStrAppendC(&title, " of ");
134 ajStrAppendS(&title, seqid);
135
136 gpp.title = ajStrNewS(title);
137 gpp.xlab = ajStrNewC("location");
138 gpp.ylab = ajStrNewC("GC skew");
139
140 if(!gFilebuffURLS(url, &buff))
141 {
142 ajDie("File downloading error from:\n%S\n", url);
143 }
144
145 if(!gPlotFilebuff(buff, mult, &gpp))
146 {
147 ajDie("Error in plotting\n");
148 }
149
150 AJFREE(gpp.title);
151 AJFREE(gpp.xlab);
152 AJFREE(gpp.ylab);
153 ajStrDel(&title);
154 ajFilebuffDel(&buff);
155 }
156 else
157 {
158 ajFmtPrintF(outf, "Sequence: %S\n", seqid);
159 if(!gFileOutURLS(url, &outf))
160 {
161 ajDie("File downloading error from:\n%S\n", url);
162 }
163 }
164 ajStrDel(&url);
165 ajStrDel(&restid);
166 ajStrDel(&seqid);
167 }
168
169 ajFileClose(&outf);
170
171 ajSeqallDel(&seqall);
172 ajSeqDel(&seq);
173 ajStrDel(&base);
174
175 embExit();
176
177 return 0;
178 }