Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/src/ggcwin.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 ggcwin | |
3 ** | |
4 ** Calculates the GC content along the given genome | |
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 ggcwin *************************************************************** | |
36 ** | |
37 ** Calculates the GC content along the given genome | |
38 ** | |
39 ******************************************************************************/ | |
40 | |
41 int main(int argc, char *argv[]) | |
42 { | |
43 embInitPV("ggcwin", 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 AjBool at = 0; | |
61 AjBool purine = 0; | |
62 AjBool keto = 0; | |
63 | |
64 AjBool plot = 0; | |
65 AjPFile outf = NULL; | |
66 AjPFilebuff buff = NULL; | |
67 AjPGraph mult = NULL; | |
68 | |
69 gPlotParams gpp; | |
70 AjPStr title = NULL; | |
71 | |
72 seqall = ajAcdGetSeqall("sequence"); | |
73 window = ajAcdGetInt("window"); | |
74 at = ajAcdGetBoolean("at"); | |
75 purine = ajAcdGetBoolean("purine"); | |
76 keto = ajAcdGetBoolean("keto"); | |
77 | |
78 plot = ajAcdGetToggle("plot"); | |
79 outf = ajAcdGetOutfile("outfile"); | |
80 mult = ajAcdGetGraphxy("graph"); | |
81 | |
82 base = ajStrNewC("rest.g-language.org"); | |
83 | |
84 gAssignUniqueName(&tmpname); | |
85 ajStrAppendC(&tmpname, ".fasta"); | |
86 | |
87 while(ajSeqallNext(seqall, &seq)) | |
88 { | |
89 tmpout = ajSeqoutNew(); | |
90 | |
91 if(!ajSeqoutOpenFilename(tmpout, tmpname)) | |
92 { | |
93 embExitBad(); | |
94 } | |
95 | |
96 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta")); | |
97 ajSeqoutWriteSeq(tmpout, seq); | |
98 ajSeqoutClose(tmpout); | |
99 ajSeqoutDel(&tmpout); | |
100 | |
101 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); | |
102 gFilePostSS(url, tmpname, &restid); | |
103 ajStrDel(&url); | |
104 ajSysFileUnlinkS(tmpname); | |
105 | |
106 ajStrAssignS(&seqid, ajSeqGetAccS(seq)); | |
107 | |
108 if(ajStrGetLen(seqid) == 0) | |
109 { | |
110 ajStrAssignS(&seqid, ajSeqGetNameS(seq)); | |
111 } | |
112 | |
113 if(ajStrGetLen(seqid) == 0) | |
114 { | |
115 ajWarn("No valid header information\n"); | |
116 } | |
117 | |
118 url = ajStrNew(); | |
119 | |
120 ajFmtPrintS(&url, "http://%S/%S/gcwin/window=%d/at=%d/purine=%d/" | |
121 "keto=%d/output=f/", base, restid, window, at, purine, keto); | |
122 | |
123 if(plot) | |
124 { | |
125 title = ajStrNew(); | |
126 | |
127 ajStrAppendC(&title, argv[0]); | |
128 ajStrAppendC(&title, " of "); | |
129 ajStrAppendS(&title, seqid); | |
130 | |
131 gpp.title = ajStrNewS(title); | |
132 gpp.xlab = ajStrNewC("location"); | |
133 gpp.ylab = ajStrNewC("GC content"); | |
134 | |
135 if(!gFilebuffURLS(url, &buff)) | |
136 { | |
137 ajDie("File downloading error from:\n%S\n", url); | |
138 } | |
139 | |
140 if(!gPlotFilebuff(buff, mult, &gpp)) | |
141 { | |
142 ajDie("Error in plotting\n"); | |
143 } | |
144 | |
145 AJFREE(gpp.title); | |
146 AJFREE(gpp.xlab); | |
147 AJFREE(gpp.ylab); | |
148 ajStrDel(&title); | |
149 ajFilebuffDel(&buff); | |
150 } | |
151 else | |
152 { | |
153 ajFmtPrintF(outf, "Sequence: %S\n", seqid); | |
154 if(!gFileOutURLS(url, &outf)) | |
155 { | |
156 ajDie("File downloading error from:\n%S\n", url); | |
157 } | |
158 } | |
159 ajStrDel(&url); | |
160 ajStrDel(&restid); | |
161 ajStrDel(&seqid); | |
162 } | |
163 | |
164 ajFileClose(&outf); | |
165 | |
166 ajSeqallDel(&seqall); | |
167 ajSeqDel(&seq); | |
168 ajStrDel(&base); | |
169 | |
170 embExit(); | |
171 | |
172 return 0; | |
173 } |