Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/src/gcircularmap.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 gcircularmap | |
3 ** | |
4 ** Draws circular map of the 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 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 gcircularmap ******************************************************** | |
40 ** | |
41 ** Draws circular map of the genome | |
42 ** | |
43 ******************************************************************************/ | |
44 | |
45 int main(int argc, char *argv[]) | |
46 { | |
47 embInitPV("gcircularmap", argc, argv, "GEMBASSY", "1.0.3"); | |
48 | |
49 struct soap soap; | |
50 struct ns1__circular_USCOREmapInputParams params; | |
51 | |
52 AjPSeqall seqall; | |
53 AjPSeq seq; | |
54 AjPStr inseq = NULL; | |
55 AjPStr seqid = NULL; | |
56 AjBool accid = ajFalse; | |
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 filename = ajAcdGetString("goutfile"); | |
69 accid = ajAcdGetBoolean("accid"); | |
70 format = ajAcdGetString("format"); | |
71 | |
72 params.gmap = 0; | |
73 | |
74 i = 0; | |
75 | |
76 while(ajSeqallNext(seqall, &seq)) | |
77 { | |
78 soap_init(&soap); | |
79 | |
80 soap.send_timeout = 0; | |
81 soap.recv_timeout = 0; | |
82 | |
83 inseq = NULL; | |
84 | |
85 ajStrAssignS(&seqid, ajSeqGetAccS(seq)); | |
86 | |
87 if(ajStrGetLen(seqid) == 0) | |
88 { | |
89 ajStrAssignS(&seqid, ajSeqGetNameS(seq)); | |
90 } | |
91 | |
92 if(ajStrGetLen(seqid) == 0) | |
93 { | |
94 ajWarn("No valid header information\n"); | |
95 } | |
96 | |
97 if(accid || !gFormatGenbank(seq, &inseq)) | |
98 { | |
99 if(!accid) | |
100 { | |
101 ajWarn("Sequence does not have features\n" | |
102 "Proceeding with sequence accession ID:%S\n", seqid); | |
103 } | |
104 | |
105 if(!gValID(seqid)) | |
106 { | |
107 ajDie("Invalid accession ID:%S, exiting\n", seqid); | |
108 } | |
109 | |
110 ajStrAssignS(&inseq, seqid); | |
111 } | |
112 | |
113 in0 = ajCharNewS(inseq); | |
114 | |
115 if(soap_call_ns1__circular_USCOREmap( | |
116 &soap, | |
117 NULL, | |
118 NULL, | |
119 in0, | |
120 ¶ms, | |
121 &result | |
122 ) == SOAP_OK) | |
123 { | |
124 ++i; | |
125 | |
126 outfname = ajStrNewS(ajFmtStr("%S.%d.%S", | |
127 filename, | |
128 i, | |
129 format)); | |
130 | |
131 outf = ajFileNewOutNameS(outfname); | |
132 | |
133 if(!outf) | |
134 { | |
135 ajDie("File open error\n"); | |
136 } | |
137 | |
138 if(!ajStrMatchC(format, "svg")) | |
139 { | |
140 if(!gHttpConvertC(result, &outf, ajStrNewC("svg"), format)) | |
141 { | |
142 ajDie("File downloading error from:\n%s\n", result); | |
143 } | |
144 else | |
145 { | |
146 ajFmtPrint("Created %S\n", outfname); | |
147 } | |
148 } | |
149 else | |
150 { | |
151 if(!gHttpGetBinC(result, &outf)) | |
152 { | |
153 ajDie("File downloading error from:\n%s\n", result); | |
154 } | |
155 else | |
156 { | |
157 ajFmtPrint("Created %S\n", outfname); | |
158 } | |
159 } | |
160 | |
161 ajStrDel(&outfname); | |
162 } | |
163 else | |
164 { | |
165 soap_print_fault(&soap, stderr); | |
166 } | |
167 | |
168 soap_destroy(&soap); | |
169 soap_end(&soap); | |
170 soap_done(&soap); | |
171 | |
172 AJFREE(in0); | |
173 | |
174 ajStrDel(&seqid); | |
175 ajStrDel(&inseq); | |
176 } | |
177 | |
178 ajSeqallDel(&seqall); | |
179 ajSeqDel(&seq); | |
180 | |
181 ajStrDel(&filename); | |
182 | |
183 embExit(); | |
184 | |
185 return 0; | |
186 } |