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