Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/src/gseq2png.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 gseq2png | |
3 ** | |
4 ** Converts a sequence to PNG image | |
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 gseq2png ************************************************************* | |
40 ** | |
41 ** Converts a sequence to PNG image | |
42 ** | |
43 ******************************************************************************/ | |
44 | |
45 int main(int argc, char *argv[]) | |
46 { | |
47 embInitPV("gseq2png", argc, argv, "GEMBASSY", "1.0.3"); | |
48 | |
49 struct soap soap; | |
50 struct ns1__seq2pngInputParams params; | |
51 | |
52 AjPSeqall seqall; | |
53 AjPSeq seq; | |
54 AjPStr inseq = NULL; | |
55 AjPStr seqid = NULL; | |
56 ajint width = 0; | |
57 ajint window = 0; | |
58 AjPFile outf = NULL; | |
59 AjPStr filename = NULL; | |
60 AjPStr outfname = NULL; | |
61 AjPStr tempname = NULL; | |
62 AjPStr appname = NULL; | |
63 AjPStr convert = NULL; | |
64 AjPStr format = NULL; | |
65 | |
66 ajint i; | |
67 | |
68 char *in0; | |
69 char *result; | |
70 | |
71 seqall = ajAcdGetSeqall("sequence"); | |
72 window = ajAcdGetInt("window"); | |
73 width = ajAcdGetInt("width"); | |
74 filename = ajAcdGetString("goutfile"); | |
75 format = ajAcdGetString("format"); | |
76 | |
77 appname = ajStrNewC("convert"); | |
78 | |
79 params.window = window; | |
80 params.width = width; | |
81 params.output = "g"; | |
82 | |
83 i = 0; | |
84 | |
85 while(ajSeqallNext(seqall, &seq)) | |
86 { | |
87 soap_init(&soap); | |
88 | |
89 inseq = NULL; | |
90 | |
91 ajStrAppendC(&inseq, ">"); | |
92 ajStrAppendS(&inseq, ajSeqGetNameS(seq)); | |
93 ajStrAppendC(&inseq, "\n"); | |
94 ajStrAppendS(&inseq, ajSeqGetSeqS(seq)); | |
95 | |
96 ajStrAssignS(&seqid, ajSeqGetAccS(seq)); | |
97 | |
98 in0 = ajCharNewS(inseq); | |
99 | |
100 if(soap_call_ns1__seq2png( | |
101 &soap, | |
102 NULL, | |
103 NULL, | |
104 in0, | |
105 ¶ms, | |
106 &result | |
107 ) == SOAP_OK) | |
108 { | |
109 ++i; | |
110 | |
111 outfname = ajStrNewS(ajFmtStr("%S.%d.%S", | |
112 filename, | |
113 i, | |
114 format)); | |
115 | |
116 outf = ajFileNewOutNameS(outfname); | |
117 | |
118 if(!outf) | |
119 { | |
120 ajDie("File open error\n"); | |
121 } | |
122 | |
123 if(!ajStrMatchC(format, "png")) | |
124 { | |
125 if(!gHttpConvertC(result, &outf, ajStrNewC("png"), format)) | |
126 { | |
127 ajDie("File downloading error from:\n%s\n", result); | |
128 } | |
129 else | |
130 { | |
131 ajFmtPrint("Created %S\n", outfname); | |
132 } | |
133 } | |
134 else | |
135 { | |
136 if(!gHttpGetBinC(result, &outf)) | |
137 { | |
138 ajDie("File downloading error from:\n%s\n", result); | |
139 } | |
140 else | |
141 { | |
142 ajFmtPrint("Created %S\n", outfname); | |
143 } | |
144 } | |
145 | |
146 ajStrDel(&outfname); | |
147 } | |
148 else | |
149 { | |
150 soap_print_fault(&soap, stderr); | |
151 } | |
152 | |
153 soap_destroy(&soap); | |
154 soap_end(&soap); | |
155 soap_done(&soap); | |
156 | |
157 AJFREE(in0); | |
158 | |
159 ajStrDel(&seqid); | |
160 ajStrDel(&inseq); | |
161 } | |
162 | |
163 ajSeqallDel(&seqall); | |
164 ajSeqDel(&seq); | |
165 | |
166 ajStrDel(&filename); | |
167 | |
168 embExit(); | |
169 | |
170 return 0; | |
171 } |