0
|
1 /******************************************************************************
|
|
2 ** @source gphx
|
|
3 **
|
|
4 ** Identify predict highly expressed gene
|
|
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 ** @@
|
|
11 **
|
|
12 ** This program is free software; you can redistribute it and/or
|
|
13 ** modify it under the terms of the GNU General Public License
|
|
14 ** as published by the Free Software Foundation; either version 2
|
|
15 ** of the License, or (at your option) any later version.
|
|
16 **
|
|
17 ** This program is distributed in the hope that it will be useful,
|
|
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 ** GNU General Public License for more details.
|
|
21 **
|
|
22 ** You should have received a copy of the GNU General Public License
|
|
23 ** along with this program; if not, write to the Free Software
|
|
24 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
25 ******************************************************************************/
|
|
26
|
|
27 #include "emboss.h"
|
|
28 #include "glibs.h"
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33 /* @prog gphx *****************************************************************
|
|
34 **
|
|
35 ** Identify predict highly expressed gene
|
|
36 **
|
|
37 ******************************************************************************/
|
|
38
|
|
39 int main(int argc, char *argv[])
|
|
40 {
|
|
41 embInitPV("gphx", argc, argv, "GEMBASSY", "1.0.3");
|
|
42
|
|
43 AjPSeqall seqall;
|
|
44 AjPSeq seq;
|
|
45 AjPStr inseq = NULL;
|
|
46
|
|
47 AjBool translate = ajFalse;
|
|
48 AjPStr delkey = NULL;
|
|
49
|
|
50 AjBool accid = ajFalse;
|
|
51 AjPStr restid = NULL;
|
|
52 AjPStr seqid = NULL;
|
|
53
|
|
54 AjPStr base = NULL;
|
|
55 AjPStr url = NULL;
|
|
56
|
|
57 AjPFile tmpfile = NULL;
|
|
58 AjPStr tmpname = NULL;
|
|
59
|
|
60 AjPFile outf = NULL;
|
|
61
|
|
62 seqall = ajAcdGetSeqall("sequence");
|
|
63 translate = ajAcdGetBoolean("translate");
|
|
64 delkey = ajAcdGetString("delkey");
|
|
65 accid = ajAcdGetBoolean("accid");
|
|
66 outf = ajAcdGetOutfile("outfile");
|
|
67
|
|
68 base = ajStrNewC("rest.g-language.org");
|
|
69
|
|
70 gAssignUniqueName(&tmpname);
|
|
71
|
|
72 while(ajSeqallNext(seqall, &seq))
|
|
73 {
|
|
74 inseq = NULL;
|
|
75
|
|
76 if(!accid)
|
|
77 {
|
|
78 if(gFormatGenbank(seq, &inseq))
|
|
79 {
|
|
80 tmpfile = ajFileNewOutNameS(tmpname);
|
|
81 if(!tmpfile)
|
|
82 {
|
|
83 ajDie("Output file (%S) open error\n", tmpname);
|
|
84 }
|
|
85 ajFmtPrintF(tmpfile, "%S", inseq);
|
|
86 ajFileClose(&tmpfile);
|
|
87 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
|
|
88 gFilePostSS(url, tmpname, &restid);
|
|
89 ajStrDel(&url);
|
|
90 ajSysFileUnlinkS(tmpname);
|
|
91 }
|
|
92 else
|
|
93 {
|
|
94 ajWarn("Sequence does not have features\n"
|
|
95 "Proceeding with sequence accession ID\n");
|
|
96 accid = ajTrue;
|
|
97 }
|
|
98 }
|
|
99
|
|
100 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
|
|
101
|
|
102 if(ajStrGetLen(seqid) == 0)
|
|
103 {
|
|
104 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
|
|
105 }
|
|
106
|
|
107 if(ajStrGetLen(seqid) == 0)
|
|
108 {
|
|
109 ajWarn("No valid header information\n");
|
|
110 }
|
|
111
|
|
112 if(accid)
|
|
113 {
|
|
114 ajStrAssignS(&restid, seqid);
|
|
115 if(ajStrGetLen(seqid) == 0)
|
|
116 {
|
|
117 ajDie("Cannot proceed without header with -accid\n");
|
|
118 }
|
|
119
|
|
120 if(!gValID(seqid))
|
|
121 {
|
|
122 ajDie("Invalid accession ID:%S, exiting\n", seqid);
|
|
123 }
|
|
124 }
|
|
125
|
|
126 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
|
|
127
|
|
128 url = ajStrNew();
|
|
129
|
|
130 ajFmtPrintS(&url, "http://%S/%S/phx/translate=%d/delkey=%S/"
|
|
131 "output=f/tag=gene", base, restid, translate, delkey);
|
|
132
|
|
133 ajFmtPrintF(outf, "Sequence: %S\n", seqid);
|
|
134 if(!gFileOutURLS(url, &outf))
|
|
135 {
|
|
136 ajDie("Failed to download result from:\n%S\n", url);
|
|
137 }
|
|
138
|
|
139 ajStrDel(&url);
|
|
140 ajStrDel(&restid);
|
|
141 ajStrDel(&seqid);
|
|
142 ajStrDel(&inseq);
|
|
143 }
|
|
144
|
|
145 ajFileClose(&outf);
|
|
146
|
|
147 ajSeqallDel(&seqall);
|
|
148 ajSeqDel(&seq);
|
|
149 ajStrDel(&base);
|
|
150
|
|
151 ajStrDel(&delkey);
|
|
152
|
|
153 embExit();
|
|
154
|
|
155 return 0;
|
|
156 }
|