comparison GEMBASSY-1.0.3/src/ggenomemap3.c @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8300eb051bea
1 /******************************************************************************
2 ** @source ggenomemap3
3 **
4 ** Draws the map of the genome (Version 3)
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 "soapH.h"
30 #include "GLANGSoapBinding.nsmap"
31 #include "soapClient.c"
32 #include "soapC.c"
33 #include "../gsoap/stdsoap2.c"
34 #include "glibs.h"
35
36
37
38
39 /* @prog ggenomemap3 **********************************************************
40 **
41 ** Draws the map of the genome (Version 3)
42 **
43 ******************************************************************************/
44
45 int main(int argc, char *argv[])
46 {
47 embInitPV("ggenomemap3", argc, argv, "GEMBASSY", "1.0.3");
48
49 struct soap soap;
50 struct ns1__genome_USCOREmap3InputParams params;
51
52 AjPSeqall seqall;
53 AjPSeq seq;
54 AjPStr inseq = NULL;
55 AjPStr seqid = NULL;
56 ajint width;
57 ajint height;
58 AjBool accid = ajFalse;
59 AjPFile outf = NULL;
60 AjPStr filename = NULL;
61 AjPStr outfname = NULL;
62 AjPStr format = NULL;
63
64 ajint i;
65
66 char *in0;
67 char *result;
68
69 seqall = ajAcdGetSeqall("sequence");
70 width = ajAcdGetInt("width");
71 height = ajAcdGetInt("height");
72 filename = ajAcdGetString("goutfile");
73 accid = ajAcdGetBoolean("accid");
74 format = ajAcdGetString("format");
75
76 params.width = width;
77 params.height = height;
78 params.gmap = 0;
79 params.datafilename = "";
80 params.output = "g";
81
82 i = 0;
83
84 while(ajSeqallNext(seqall, &seq))
85 {
86
87 soap_init(&soap);
88
89 soap.send_timeout = 0;
90 soap.recv_timeout = 0;
91
92 inseq = NULL;
93
94 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
95
96 if(!ajStrGetLen(seqid))
97 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
98
99 if(!ajStrGetLen(seqid))
100 {
101 ajWarn("No valid header information\n");
102 }
103
104 if(accid || !gFormatGenbank(seq, &inseq))
105 {
106 if(!accid)
107 ajWarn("Sequence does not have features\n"
108 "Proceeding with sequence accession ID:%S\n", seqid);
109
110 if(!gValID(seqid))
111 {
112 ajDie("Invalid accession ID:%S, exiting\n", seqid);
113 }
114
115 ajStrAssignS(&inseq, seqid);
116 }
117
118 in0 = ajCharNewS(inseq);
119
120 if(soap_call_ns1__genome_USCOREmap3(
121 &soap,
122 NULL,
123 NULL,
124 in0,
125 &params,
126 &result
127 ) == SOAP_OK)
128 {
129 ++i;
130
131 outfname = ajStrNewS(ajFmtStr("%S.%d.%S",
132 filename,
133 i,
134 format));
135
136 outf = ajFileNewOutNameS(outfname);
137
138 if(!outf)
139 {
140 ajDie("File open error\n");
141 }
142
143 if(!ajStrMatchC(format, "png"))
144 {
145 if(!gHttpConvertC(result, &outf, ajStrNewC("png"), format))
146 {
147 ajDie("File downloading error from:\n%s\n", result);
148 }
149 else
150 {
151 ajFmtPrint("Created %S\n", outfname);
152 }
153 }
154 else
155 {
156 if(!gHttpGetBinC(result, &outf))
157 {
158 ajDie("File downloading error from:\n%s\n", result);
159 }
160 else
161 {
162 ajFmtPrint("Created %S\n", outfname);
163 }
164 }
165
166 ajStrDel(&outfname);
167 }
168 else
169 {
170 soap_print_fault(&soap, stderr);
171 }
172
173 soap_destroy(&soap);
174 soap_end(&soap);
175 soap_done(&soap);
176
177 AJFREE(in0);
178
179 ajStrDel(&seqid);
180 ajStrDel(&inseq);
181 }
182
183 ajSeqallDel(&seqall);
184 ajSeqDel(&seq);
185
186 ajStrDel(&filename);
187
188 embExit();
189
190 return 0;
191 }