Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/src/gfindoriter.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 gfindoriter | |
3 ** | |
4 ** Predict the replication origin and terminus in bacterial genomes | |
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 RESTify | |
11 ** @modified 2015/2/7 Refactor | |
12 ** @@ | |
13 ** | |
14 ** This program is free software; you can redistribute it and/or | |
15 ** modify it under the terms of the GNU General Public License | |
16 ** as published by the Free Software Foundation; either version 2 | |
17 ** of the License, or (at your option) any later version. | |
18 ** | |
19 ** This program is distributed in the hope that it will be useful, | |
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ** GNU General Public License for more details. | |
23 ** | |
24 ** You should have received a copy of the GNU General Public License | |
25 ** along with this program; if not, write to the Free Software | |
26 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
27 ******************************************************************************/ | |
28 | |
29 #include "emboss.h" | |
30 #include "glibs.h" | |
31 | |
32 | |
33 | |
34 | |
35 /* @prog gfindoriter ******************************************************** | |
36 ** | |
37 ** Predict the replication origin and terminus in bacterial genomes | |
38 ** | |
39 ******************************************************************************/ | |
40 | |
41 int main(int argc, char *argv[]) | |
42 { | |
43 embInitPV("gfindoriter", argc, argv, "GEMBASSY", "1.0.3"); | |
44 | |
45 AjPSeqall seqall; | |
46 AjPSeq seq; | |
47 | |
48 ajint window = 0; | |
49 AjBool purine = 0; | |
50 AjBool keto = 0; | |
51 ajint lowpass = 0; | |
52 | |
53 AjPStr ori = NULL; | |
54 AjPStr ter = NULL; | |
55 | |
56 AjPStr restid = NULL; | |
57 AjPStr seqid = NULL; | |
58 | |
59 AjPStr base = NULL; | |
60 AjPStr url = NULL; | |
61 | |
62 AjPStr tmpname = NULL; | |
63 AjPSeqout tmpout = NULL; | |
64 AjPFilebuff tmpbuff = NULL; | |
65 | |
66 AjPStr tmp = NULL; | |
67 AjPStr line = NULL; | |
68 | |
69 AjPRegexp regex; | |
70 | |
71 AjPFile outf = NULL; | |
72 | |
73 seqall = ajAcdGetSeqall("sequence"); | |
74 window = ajAcdGetInt("window"); | |
75 lowpass = ajAcdGetInt("lowpass"); | |
76 purine = ajAcdGetBoolean("purine"); | |
77 keto = ajAcdGetBoolean("keto"); | |
78 outf = ajAcdGetOutfile("outfile"); | |
79 | |
80 base = ajStrNewC("rest.g-language.org"); | |
81 | |
82 gAssignUniqueName(&tmpname); | |
83 ajStrAppendC(&tmpname, ".fasta"); | |
84 | |
85 while(ajSeqallNext(seqall, &seq)) | |
86 { | |
87 tmpout = ajSeqoutNew(); | |
88 | |
89 if(!ajSeqoutOpenFilename(tmpout, tmpname)) | |
90 { | |
91 embExitBad(); | |
92 } | |
93 | |
94 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta")); | |
95 ajSeqoutWriteSeq(tmpout, seq); | |
96 ajSeqoutClose(tmpout); | |
97 ajSeqoutDel(&tmpout); | |
98 | |
99 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); | |
100 gFilePostSS(url, tmpname, &restid); | |
101 ajStrDel(&url); | |
102 ajSysFileUnlinkS(tmpname); | |
103 | |
104 ajStrAssignS(&seqid, ajSeqGetAccS(seq)); | |
105 | |
106 if(ajStrGetLen(seqid) == 0) | |
107 { | |
108 ajStrAssignS(&seqid, ajSeqGetNameS(seq)); | |
109 } | |
110 | |
111 if(ajStrGetLen(seqid) == 0) | |
112 { | |
113 ajWarn("No valid header information\n"); | |
114 } | |
115 | |
116 url = ajStrNew(); | |
117 | |
118 ajFmtPrintS(&url, "http://%S/%S/find_ori_ter/window=%d/lowpass=%d/" | |
119 "purine=%d/keto=%d/", base, restid, window, lowpass, | |
120 purine, keto); | |
121 | |
122 if(!gFilebuffURLS(url, &tmpbuff)) | |
123 { | |
124 ajDie("Failed to download result from:\n%S\n", url); | |
125 } | |
126 | |
127 regex = ajRegCompC("([0-9]+)$"); | |
128 | |
129 while(ajBuffreadLine(tmpbuff, &line)) | |
130 { | |
131 if(ajRegExec(regex, line)) | |
132 { | |
133 if(ajRegSubI(regex, 0, &tmp)) | |
134 { | |
135 if(ajStrGetLen(ori) == 0) | |
136 { | |
137 ajStrAssignS(&ori, tmp); | |
138 } | |
139 else if(ajStrGetLen(ter) == 0) | |
140 { | |
141 ajStrAssignS(&ter, tmp); | |
142 } | |
143 } | |
144 } | |
145 } | |
146 | |
147 ajFmtPrintF(outf, "Sequence: %S Origin: %S Terminus: %S\n", | |
148 seqid, ori, ter); | |
149 | |
150 ajStrDel(&tmp); | |
151 ajStrDel(&ori); | |
152 ajStrDel(&ter); | |
153 | |
154 ajStrDel(&url); | |
155 ajStrDel(&restid); | |
156 } | |
157 | |
158 ajFileClose(&outf); | |
159 | |
160 ajSeqallDel(&seqall); | |
161 ajSeqDel(&seq); | |
162 ajStrDel(&seqid); | |
163 | |
164 embExit(); | |
165 | |
166 return 0; | |
167 } |