annotate GEMBASSY-1.0.3/src/ggenomemap3.c @ 1:84a17b3fad1f draft

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:20:29 -0400
parents 8300eb051bea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 /******************************************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 ** @source ggenomemap3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 ** Draws the map of the genome (Version 3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 ** @author Copyright (C) 2012 Hidetoshi Itaya
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7 ** @version 1.0.3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 ** @modified 2012/1/20 Hidetoshi Itaya Created!
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 ** @modified 2013/6/16 Revision 1
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10 ** @modified 2015/2/7 Refactor
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 ** @@
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 ** This program is free software; you can redistribute it and/or
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 ** modify it under the terms of the GNU General Public License
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 ** as published by the Free Software Foundation; either version 2
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 ** of the License, or (at your option) any later version.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 ** This program is distributed in the hope that it will be useful,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21 ** GNU General Public License for more details.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23 ** You should have received a copy of the GNU General Public License
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 ** along with this program; if not, write to the Free Software
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28 #include "emboss.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 #include "soapH.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 #include "GLANGSoapBinding.nsmap"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 #include "soapClient.c"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32 #include "soapC.c"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 #include "../gsoap/stdsoap2.c"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 #include "glibs.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 /* @prog ggenomemap3 **********************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 ** Draws the map of the genome (Version 3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 int main(int argc, char *argv[])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 embInitPV("ggenomemap3", argc, argv, "GEMBASSY", "1.0.3");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 struct soap soap;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 struct ns1__genome_USCOREmap3InputParams params;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52 AjPSeqall seqall;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 AjPSeq seq;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54 AjPStr inseq = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 AjPStr seqid = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 ajint width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 ajint height;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 AjBool accid = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 AjPFile outf = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 AjPStr filename = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61 AjPStr outfname = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 AjPStr format = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 ajint i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 char *in0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 char *result;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 seqall = ajAcdGetSeqall("sequence");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70 width = ajAcdGetInt("width");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 height = ajAcdGetInt("height");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72 filename = ajAcdGetString("goutfile");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 accid = ajAcdGetBoolean("accid");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 format = ajAcdGetString("format");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 params.width = width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 params.height = height;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 params.gmap = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79 params.datafilename = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 params.output = "g";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 while(ajSeqallNext(seqall, &seq))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 soap_init(&soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89 soap.send_timeout = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 soap.recv_timeout = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 inseq = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 if(!ajStrGetLen(seqid))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 if(!ajStrGetLen(seqid))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 ajWarn("No valid header information\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 if(accid || !gFormatGenbank(seq, &inseq))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 if(!accid)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 ajWarn("Sequence does not have features\n"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108 "Proceeding with sequence accession ID:%S\n", seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 if(!gValID(seqid))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 ajDie("Invalid accession ID:%S, exiting\n", seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 ajStrAssignS(&inseq, seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 in0 = ajCharNewS(inseq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 if(soap_call_ns1__genome_USCOREmap3(
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 &soap,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 NULL,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123 NULL,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 in0,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 &params,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 &result
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 ) == SOAP_OK)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 ++i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 outfname = ajStrNewS(ajFmtStr("%S.%d.%S",
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 filename,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 i,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 format));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 outf = ajFileNewOutNameS(outfname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 if(!outf)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 ajDie("File open error\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 if(!ajStrMatchC(format, "png"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 if(!gHttpConvertC(result, &outf, ajStrNewC("png"), format))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147 ajDie("File downloading error from:\n%s\n", result);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 ajFmtPrint("Created %S\n", outfname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 if(!gHttpGetBinC(result, &outf))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158 ajDie("File downloading error from:\n%s\n", result);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 ajFmtPrint("Created %S\n", outfname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 ajStrDel(&outfname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 soap_print_fault(&soap, stderr);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173 soap_destroy(&soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174 soap_end(&soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175 soap_done(&soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 AJFREE(in0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179 ajStrDel(&seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180 ajStrDel(&inseq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 ajSeqallDel(&seqall);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 ajSeqDel(&seq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
185
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
186 ajStrDel(&filename);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
187
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
188 embExit();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
189
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
190 return 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
191 }