comparison GEMBASSY-1.0.3/src/gaminoinfo.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 gaminoinfo
3 **
4 ** Prints out basic amino acid sequence statistics
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 "glibs.h"
30
31
32
33
34 /* @prog gaminoinfo ***********************************************************
35 **
36 ** Prints out basic amino acid sequence statisctics
37 **
38 ******************************************************************************/
39
40 int main(int argc, char *argv[])
41 {
42 embInitPV("gaminoinfo", argc, argv, "GEMBASSY", "1.0.3");
43
44 AjPSeqall seqall;
45 AjPSeq seq;
46
47 AjPStr restid = NULL;
48 AjPStr seqid = NULL;
49
50 AjPStr base = NULL;
51 AjPStr url = NULL;
52
53 AjPStr tmpname = NULL;
54 AjPSeqout tmpout = NULL;
55
56 AjPFile outf = NULL;
57
58 seqall = ajAcdGetSeqall("sequence");
59 outf = ajAcdGetOutfile("outfile");
60
61 base = ajStrNewC("rest.g-language.org");
62
63 gAssignUniqueName(&tmpname);
64 ajStrAppendC(&tmpname, ".fasta");
65
66 while(ajSeqallNext(seqall, &seq))
67 {
68 tmpout = ajSeqoutNew();
69
70 if(!ajSeqoutOpenFilename(tmpout, tmpname))
71 {
72 embExitBad();
73 }
74
75 ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta"));
76 ajSeqoutWriteSeq(tmpout, seq);
77 ajSeqoutClose(tmpout);
78 ajSeqoutDel(&tmpout);
79
80 ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
81 gFilePostSS(url, tmpname, &restid);
82 ajStrDel(&url);
83 ajSysFileUnlinkS(tmpname);
84
85 ajStrAssignS(&seqid, ajSeqGetAccS(seq));
86
87 if(ajStrGetLen(seqid) == 0)
88 {
89 ajStrAssignS(&seqid, ajSeqGetNameS(seq));
90 }
91
92 if(ajStrGetLen(seqid) == 0)
93 {
94 ajWarn("No valid header information\n");
95 }
96
97 url = ajStrNew();
98
99 ajFmtPrintS(&url, "http://%S/%S/amino_info", base, restid);
100
101 ajFmtPrintF(outf, "Sequence: %S\n", seqid);
102 if(!gFileOutURLS(url, &outf))
103 {
104 ajDie("Failed to download result from:\n%S\n", url);
105 }
106
107 ajStrDel(&url);
108 ajStrDel(&restid);
109 ajStrDel(&seqid);
110 }
111
112 ajFileClose(&outf);
113
114 ajSeqallDel(&seqall);
115 ajSeqDel(&seq);
116 ajStrDel(&base);
117
118 embExit();
119
120 return 0;
121 }