annotate GEMBASSY-1.0.3/src/genret.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 genret
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 ** Retrieves various gene related infomration from genome flatfile
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 "glibs.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 /* @prog genret ***************************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 ** Retrieves various gene related infomration from genome flatfile
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 int main(int argc, char *argv[])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 embInitPV("genret", argc, argv, "GEMBASSY", "1.0.3");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 AjPSeqall seqall;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 AjPSeq seq = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 AjPStr inseq = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 AjPStr gene = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 AjPStr access = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 AjBool accid = ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 AjPStr argument = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 AjPFile outfile = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 AjPStr seqid = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54 AjPStr restid = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 AjBool valid = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 AjBool isseq = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 AjBool isgbk = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 AjPFilebuff buff = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61 AjPFile tmpfile = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 AjPStr tmpname = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 AjPStr regexstr = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 AjPStrTok token = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 AjPRegexp regex = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68 AjPStr url = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 AjPStr base = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70 AjPStr head = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 AjPStr line = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 seqall = ajAcdGetSeqall("sequence");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 access = ajAcdGetString("access");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 gene = ajAcdGetString("gene");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 argument = ajAcdGetString("argument");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 accid = ajAcdGetBoolean("accid");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 outfile = ajAcdGetOutfile("outfile");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 if(
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 ajStrMatchC(access, "translation") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 ajStrMatchC(access, "get_exon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83 ajStrMatchC(access, "get_exons") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 ajStrMatchC(access, "get_cdsseq") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 ajStrMatchC(access, "get_gbkseq") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 ajStrMatchC(access, "get_geneseq") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 ajStrMatchC(access, "get_intron") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88 ajStrMatchC(access, "getseq") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89 ajStrMatchC(access, "seq") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 ajStrMatchC(access, "around_startcodon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91 ajStrMatchC(access, "around_stopcodon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 ajStrMatchC(access, "before_startcodon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93 ajStrMatchC(access, "before_stopcodon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 ajStrMatchC(access, "after_startcodon") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95 ajStrMatchC(access, "after_stopcodon")
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 )
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98 isseq = ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 else if(ajStrMatchC(access, "annotate") ||
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 ajStrMatchC(access, "output"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103 isgbk = ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 ajFmtPrintF(outfile, "gene,%S\n", access);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 base = ajStrNewC("rest.g-language.org");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 ajStrExchangeCC(&argument, " ", "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 ajStrExchangeCC(&argument, ",", "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114 ajStrExchangeCC(&argument, "\t", "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 ajStrExchangeCC(&argument, "\r", "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 ajStrExchangeCC(&argument, "\n", "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 if(ajStrMatchC(gene, "*"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 ajStrInsertK(&gene, 0, '.');
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123 if(ajStrPrefixC(gene, "@") || ajStrPrefixC(gene, "list::"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 ajStrExchangeCC(&gene, "@", "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 ajStrExchangeCC(&gene, "list::", "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 ajStrAssignS(&tmpname, gene);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 tmpfile = ajFileNewInNameS(tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 if(!tmpfile)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 ajDie("List file (%S) open error\n", tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 gene = ajStrNew();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 while(ajReadline(tmpfile, &line))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 ajStrAppendS(&gene, line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 ajFileClose(&tmpfile);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 ajStrDel(&tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 ajStrDel(&line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 tmpname = ajStrNew();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 gAssignUniqueName(&tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 while(ajSeqallNext(seqall, &seq))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 inseq = ajStrNew();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155 if(!accid)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 if(gFormatGenbank(seq, &inseq))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159 tmpfile = ajFileNewOutNameS(tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161 if(!tmpfile)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 ajDie("Output file (%S) open error\n", tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 ajFmtPrintF(tmpfile, "%S", inseq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168 ajFileClose(&tmpfile);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172 gFilePostSS(url, tmpname, &restid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174 ajStrDel(&url);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176 ajSysFileUnlinkS(tmpname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180 ajWarn("Sequence does not have features\n"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 "Proceeding with sequence accession ID\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182 accid = ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
185
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
186
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
187 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
188
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
189 if(ajStrGetLen(seqid) == 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
190 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
191 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
192 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
193
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
194 if(ajStrGetLen(seqid) == 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
195 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
196 ajWarn("No valid header information\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
197 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
198
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
199 if(accid)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
200 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
201 ajStrAssignS(&restid, seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
202 if(ajStrGetLen(seqid) == 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
203 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
204 ajDie("Cannot proceed without header with -accid\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
205 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
206
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
207 if(!gValID(seqid))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
208 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
209 ajDie("Invalid accession ID:%S, exiting\n", seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
210 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
211 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
212
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
213 url = ajStrNew();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
214
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
215 if(isgbk)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
216 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
217 ajFmtPrintS(&url, "http://%S/%S/%S", base, restid, access);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
218 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
219 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
220 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
221 ajFmtPrintS(&url, "http://%S/%S/*/%S/%S", base, restid, access, argument);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
222 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
223
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
224 if(!gFilebuffURLS(url, &buff))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
225 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
226 ajDie("GET error from %S\n", url);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
227 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
228
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
229 while(ajBuffreadLine(buff, &line))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
230 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
231 if(isgbk){
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
232 ajFmtPrintF(outfile, "%S", line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
233 continue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
234 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
235
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
236 ajStrRemoveLastNewline(&line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
237
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
238 regex = ajRegCompC("^>");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
239
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
240 if(ajRegExec(regex, line))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
241 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
242 head = ajStrNew();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
243
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
244 ajStrAssignS(&head, line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
245 ajStrTrimStartC(&head, ">");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
246
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
247 valid = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
248
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
249 token = ajStrTokenNewC(ajStrNewS(gene), " ,\t\r\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
250
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
251 while(ajStrTokenNextParse(token, &regexstr))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
252 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
253 if(ajStrGetLen(regexstr))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
254 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
255 regex = ajRegComp(regexstr);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
256
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
257 if(ajRegExec(regex, line))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
258 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
259 valid = ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
260 if(ajStrIsAlnum(regexstr))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
261 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
262 ajStrExchangeSC(&gene, regexstr, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
263 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
264 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
265
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
266 ajRegFree(&regex);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
267 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
268 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
269 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
270 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
271 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
272 if(valid)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
273 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
274 if(isseq)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
275 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
276 ajStrFmtWrap(&line, 60);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
277 ajFmtPrintF(outfile, ">%S\n%S\n", head, line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
278 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
279 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
280 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
281 ajFmtPrintF(outfile, "%S,%S\n", head, line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
282 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
283
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
284 valid = ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
285 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
286 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
287 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
288
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
289 ajFileClose(&outfile);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
290
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
291 ajStrDel(&restid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
292 ajStrDel(&seqid);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
293 ajStrDel(&inseq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
294 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
295
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
296 ajSeqallDel(&seqall);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
297 ajSeqDel(&seq);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
298 ajStrDel(&access);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
299 ajStrDel(&gene);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
300
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
301 embExit();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
302 }