1 /** @source ontogetup
2 **
3 ** Find ontology terms by child identifier
4 **
5 ** @author Copyright (C) 2010 Jon Ison / EMBOSS
6 ** @version 1  First version</replaceable>
7 ** @modified July 2010  Jon Ison First version</replaceable>
8 ** @@
9 **
10 ** This program is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License
12 ** as published by the Free Software Foundation; either version 2
13 ** of the License, or (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ** GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 ********************************************************************/
24 
25 
26 /* ==================================================================== */
27 /* ========================== include files =========================== */
28 /* ==================================================================== */
29 
30 #include "emboss.h"
31 
32 /* Inclusion of system and local header files goes here */
33 
34 
35 
36 /* ==================================================================== */
37 /* ============================ constants ============================= */
38 /* ==================================================================== */
39 
40 /* #define and enum statements go here */
41 
42 
43 
44 /* ==================================================================== */
45 /* ======================== global variables ========================== */
46 /* ==================================================================== */
47 
48 /* Global variables definitions go here */
49 
50 
51 
52 /* ==================================================================== */
53 /* ============================== data ================================ */
54 /* ==================================================================== */
55 
56 /* Definition of datatypes go here */
57 
58 
59 
60 /* ==================================================================== */
61 /* ==================== function prototypes =========================== */
62 /* ==================================================================== */
63 
64 /* Function prototypes for public (external) functions go here */
65 
66 
67 
68 
69 /* @prog ontogetup ************************************************************
70 **
71 ** Find EDAM ontology 'data' (identifier) terms by keyword
72 **
73 ******************************************************************************/
74 
main(int argc,char ** argv)75 int main(int argc, char **argv)
76 {
77     /* Variable declarations */
78     AjPOutfile  outfile = NULL;
79     AjBool obsolete = ajTrue;
80 
81     AjPObo obo = NULL;
82     AjPObo oboparent = NULL;
83     AjPOboall oboall = NULL;
84     AjPOboin oboinparent = NULL;
85 
86     AjPStr oboqryup = NULL;
87     AjPTable foundtable = NULL;
88 
89     AjPStr up = NULL;
90     AjPList uplist = NULL;
91 
92     /* ACD processing */
93     embInit("ontogetup", argc, argv);
94 
95     oboall   = ajAcdGetOboall("oboterms");
96     outfile  = ajAcdGetOutobo("outfile");
97     obsolete = ajAcdGetBoolean("obsolete");
98 
99     /* Application logic */
100     /* Check EDAM ontology (edam.obo) is installed indexed.
101        Loop through queryable fields
102         :Return list of EDAM ids with fields matching keyword(s)
103        Merge lists of matching entries
104        Write output file */
105 
106     oboinparent = ajOboinNew();
107     oboparent = ajOboNew();
108     uplist = ajListNew();
109 
110     foundtable = ajTablestrNew(600);
111 
112     while(ajOboallNext(oboall, &obo))
113     {
114         if(!obsolete && ajOboIsObsolete(obo))
115             continue;
116 
117         ajOboGetParents(obo, uplist);
118 
119         while(ajListstrPop(uplist, &up))
120         {
121             ajFmtPrintS(&oboqryup, "%S-id:%S", ajOboGetDb(obo), up);
122             ajOboinQryS(oboinparent, oboqryup);
123             while(ajOboinRead(oboinparent, oboparent))
124             {
125                 if(!obsolete && ajOboIsObsolete(oboparent))
126                     continue;
127 
128                 if(!ajTableMatchS(foundtable, oboparent->Id))
129                 {
130                     ajObooutWrite(outfile, oboparent);
131                     ajTablePut(foundtable,
132                                ajStrNewS(oboparent->Id),
133                                (void *) 1);
134                 }
135             }
136             ajStrDel(&up);
137         }
138     }
139 
140     /* Memory clean-up and exit */
141 
142     ajOboallDel(&oboall);
143     ajOboinDel(&oboinparent);
144     ajOboDel(&obo);
145     ajOboDel(&oboparent);
146 
147     ajListFree(&uplist);
148 
149     ajTablestrFreeKey(&foundtable);
150 
151     ajStrDel(&oboqryup);
152 
153     ajOutfileClose(&outfile);
154 
155     embExit();
156 
157     return 0;
158 }
159 
160 
161 /* ==================================================================== */
162 /* ============================ functions ============================= */
163 /* ==================================================================== */
164 
165