Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/src/goligomercounter.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 goligomercounter | |
3 ** | |
4 ** Counts the number of given oligomers in a sequence | |
5 ** | |
6 ** @author Copyright (C) 2012 Hidetoshi Itaya | |
7 ** @version 1.0.3 Revision 1 | |
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 "glibs.h" | |
30 | |
31 | |
32 | |
33 | |
34 /* @prog goligomercounter **************************************************** | |
35 ** | |
36 ** Counts the number of given oligomers in a sequence | |
37 ** | |
38 ******************************************************************************/ | |
39 | |
40 int main(int argc, char *argv[]) | |
41 { | |
42 embInitPV("goligomercounter", argc, argv, "GEMBASSY", "1.0.3"); | |
43 | |
44 AjPSeqall seqall; | |
45 AjPSeq seq; | |
46 AjPStr inseq = NULL; | |
47 AjPStr oligomer = NULL; | |
48 | |
49 AjPStr restid = NULL; | |
50 AjPStr seqid = NULL; | |
51 | |
52 AjPStr base = NULL; | |
53 AjPStr url = NULL; | |
54 | |
55 ajint window = 0; | |
56 | |
57 AjPFile outf = NULL; | |
58 | |
59 AjPStr tmpname = NULL; | |
60 AjPSeqout tmpout = NULL; | |
61 | |
62 AjPFilebuff tmp = NULL; | |
63 AjPStr line = NULL; | |
64 | |
65 seqall = ajAcdGetSeqall("sequence"); | |
66 oligomer = ajAcdGetString("oligomer"); | |
67 window = ajAcdGetInt("window"); | |
68 outf = ajAcdGetOutfile("outfile"); | |
69 | |
70 base = ajStrNewC("rest.g-language.org"); | |
71 | |
72 gAssignUniqueName(&tmpname); | |
73 ajStrAppendC(&tmpname, ".fasta"); | |
74 | |
75 while(ajSeqallNext(seqall, &seq)) | |
76 { | |
77 inseq = NULL; | |
78 | |
79 tmpout = ajSeqoutNew(); | |
80 | |
81 if(!ajSeqoutOpenFilename(tmpout, tmpname)) | |
82 { | |
83 embExitBad(); | |
84 } | |
85 | |
86 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta")); | |
87 ajSeqoutWriteSeq(tmpout, seq); | |
88 ajSeqoutClose(tmpout); | |
89 ajSeqoutDel(&tmpout); | |
90 | |
91 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); | |
92 gFilePostSS(url, tmpname, &restid); | |
93 ajStrDel(&url); | |
94 ajSysFileUnlinkS(tmpname); | |
95 | |
96 ajStrAssignS(&seqid, ajSeqGetAccS(seq)); | |
97 | |
98 if(ajStrGetLen(seqid) == 0) | |
99 { | |
100 ajStrAssignS(&seqid, ajSeqGetNameS(seq)); | |
101 } | |
102 | |
103 if(ajStrGetLen(seqid) == 0) | |
104 { | |
105 ajWarn("No valid header information\n"); | |
106 } | |
107 | |
108 url = ajStrNew(); | |
109 | |
110 ajFmtPrintS(&url, "http://%S/%S/oligomer_counter/%S", | |
111 base, restid, oligomer); | |
112 | |
113 if(!gFilebuffURLS(url, &tmp)) | |
114 { | |
115 ajDie("Failed to download result from:\n%S\n", url); | |
116 } | |
117 | |
118 ajBuffreadLine(tmp, &line); | |
119 | |
120 ajStrRemoveSetC(&line, "\n"); | |
121 | |
122 ajFmtPrintF(outf, "Sequence: %S Oligomer: %S Number: %S\n", | |
123 seqid, oligomer, line); | |
124 | |
125 ajStrDel(&url); | |
126 ajStrDel(&restid); | |
127 ajStrDel(&seqid); | |
128 ajStrDel(&inseq); | |
129 } | |
130 | |
131 ajFileClose(&outf); | |
132 | |
133 ajSeqallDel(&seqall); | |
134 ajSeqDel(&seq); | |
135 ajStrDel(&base); | |
136 | |
137 ajStrDel(&oligomer); | |
138 | |
139 embExit(); | |
140 | |
141 return 0; | |
142 } |