comparison GEMBASSY-1.0.3/src/gkmertable.c @ 2:8947fca5f715 draft default tip

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