1 /* @source martfilters application
2 **
3 ** Return biomart filters given mart dataset info
4 **
5 ** @author Copyright (C) Alan Bleasby
6 ** @@
7 **
8 ** This program is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License
10 ** as published by the Free Software Foundation; either version 2
11 ** of the License, or (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
22
23 #include "emboss.h"
24
25
26
27
28 /* @prog martfilters *********************************************************
29 **
30 ** Reads and writes (returns) sequences
31 **
32 ******************************************************************************/
33
main(int argc,char ** argv)34 int main(int argc, char **argv)
35 {
36 AjPSeqin seqin = NULL;
37 AjPMartquery mq = NULL;
38 AjPMartquery pmq = NULL;
39 AjPMartFilter filt = NULL;
40
41 AjPStr dataset = NULL;
42 AjPStr host = NULL;
43 AjPStr path = NULL;
44
45 AjPFile outf = NULL;
46 ajint iport = 0;
47
48 ajuint i;
49 AjPStr key1 = NULL;
50 AjPStr key2 = NULL;
51 const AjPStr value1 = NULL;
52 const AjPStr value2 = NULL;
53
54
55 embInit("martfilters", argc, argv);
56
57
58 host = ajAcdGetString("host");
59 path = ajAcdGetString("path");
60 iport = ajAcdGetInt("port");
61 dataset = ajAcdGetString("dataset");
62
63 outf = ajAcdGetOutfile("outfile");
64
65 mq = ajMartqueryNew();
66 seqin = ajSeqinNew();
67
68 ajMartAttachMartquery(seqin,mq);
69 ajMartSetMarthostS(seqin,host);
70 ajMartSetMartpathS(seqin,path);
71 ajMartSetMartport(seqin,iport);
72
73 /*
74 **
75 ** This section retrieves the filters given a mart dataset name
76 ** from a mart host.
77 */
78
79 ajMartGetFilters(seqin, dataset);
80 ajMartfiltersParse(seqin);
81
82
83 key1 = ajStrNewC("name");
84 key2 = ajStrNewC("displayName");
85
86 pmq = ajMartGetMartqueryPtr(seqin);
87 filt = pmq->Filters;
88
89 for(i=0; i < filt->Nfilters; ++i)
90 {
91 value1 = ajTableFetchS(filt->Filters[i], key1);
92 value2 = ajTableFetchS(filt->Filters[i], key2);
93 ajFmtPrintF(outf,"%-40S %S\n",value1,value2);
94 }
95
96
97 ajStrDel(&key1);
98 ajStrDel(&key2);
99
100
101 ajStrDel(&host);
102 ajStrDel(&path);
103 ajStrDel(&dataset);
104
105 ajMartquerySeqinFree(seqin);
106
107 ajSeqinDel(&seqin);
108 ajFileClose(&outf);
109
110 embExit();
111
112 return 0;
113 }
114