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