9d5f0c7a45a8a66fb5bbbed2e43146a6fe886305
[jalview.git] / forester / java / src / org / forester / go / TestGo.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25
26 package org.forester.go;
27
28 import java.io.File;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Map;
32 import java.util.SortedSet;
33
34 import org.forester.util.ForesterUtil;
35
36 public class TestGo {
37
38     private final static double ZERO_DIFF = 1.0E-9;
39
40     public static boolean isEqual( final double a, final double b ) {
41         return ( ( Math.abs( a - b ) ) < ZERO_DIFF );
42     }
43
44     public static boolean test( final File test_dir ) {
45         System.out.print( "  GO ID: " );
46         if ( !testGoId() ) {
47             System.out.println( "failed." );
48             return false;
49         }
50         System.out.println( "OK." );
51         System.out.print( "  Namespace: " );
52         if ( !testNamespace() ) {
53             System.out.println( "failed." );
54             return false;
55         }
56         System.out.println( "OK." );
57         System.out.print( "  Basic GO term: " );
58         if ( !testBasicGoTerm() ) {
59             System.out.println( "failed." );
60             return false;
61         }
62         System.out.println( "OK." );
63         System.out.print( "  OBO parser: " );
64         if ( !testOBOparser( test_dir ) ) {
65             System.out.println( "failed." );
66             return false;
67         }
68         System.out.println( "OK." );
69         System.out.print( "  Pfam to GO mapping: " );
70         if ( !testPfamToGoMapping() ) {
71             System.out.println( "failed." );
72             return false;
73         }
74         System.out.println( "OK." );
75         System.out.print( "  Pfam to GO parser: " );
76         if ( !testPfamToGoParser( test_dir ) ) {
77             System.out.println( "failed." );
78             return false;
79         }
80         System.out.println( "OK." );
81         System.out.print( "  Super terms: " );
82         if ( !testSuperTermGetting( test_dir ) ) {
83             System.out.println( "failed." );
84             return false;
85         }
86         System.out.println( "OK." );
87         System.out.print( "  Super term counting: " );
88         if ( !testSuperTermCounting( test_dir ) ) {
89             System.out.println( "failed." );
90             return false;
91         }
92         System.out.println( "OK." );
93         return true;
94     }
95
96     private static boolean testBasicGoTerm() {
97         try {
98             final GoTerm gt1 = new BasicGoTerm( "GO:0047579",
99                                                 "4-hydroxymandelate oxidase activity",
100                                                 "molecular_function",
101                                                 false );
102             final GoTerm gt2 = new BasicGoTerm( "GO:0047579",
103                                                 "4-hydroxymandelate oxidase activity",
104                                                 "molecular_function",
105                                                 false );
106             final GoTerm gt3 = new BasicGoTerm( "GO:0047579", "?", "molecular_function", true );
107             final GoTerm gt4 = new BasicGoTerm( "GO:0047579",
108                                                 "4-hydroxymandelate oxidase activity",
109                                                 "biological_process",
110                                                 false );
111             final GoTerm gt5 = new BasicGoTerm( "GO:0047578",
112                                                 "4-hydroxymandelate oxidase activity",
113                                                 "molecular_function",
114                                                 false );
115             if ( !gt1.equals( gt2 ) ) {
116                 return false;
117             }
118             if ( !gt1.equals( gt3 ) ) {
119                 return false;
120             }
121             if ( gt1.equals( gt4 ) ) {
122                 return false;
123             }
124             if ( gt1.hashCode() != gt4.hashCode() ) {
125                 return false;
126             }
127             if ( gt1.equals( gt5 ) ) {
128                 return false;
129             }
130             final GoTerm gt6 = ( GoTerm ) gt5.copy();
131             if ( !gt6.equals( gt5 ) ) {
132                 return false;
133             }
134         }
135         catch ( final Exception e ) {
136             e.printStackTrace( System.out );
137             return false;
138         }
139         return true;
140     }
141
142     private static boolean testGoId() {
143         try {
144             final GoId id1 = new GoId( "GO:0042617" );
145             final GoId id2 = new GoId( "GO:0042630" );
146             final GoId id3 = new GoId( "GO:0042630" );
147             if ( id1.equals( id2 ) ) {
148                 return false;
149             }
150             if ( !id2.equals( id3 ) ) {
151                 return false;
152             }
153             if ( !id1.toString().equals( "GO:0042617" ) ) {
154                 return false;
155             }
156             if ( id2.hashCode() != id3.hashCode() ) {
157                 return false;
158             }
159             if ( id1.hashCode() == id2.hashCode() ) {
160                 return false;
161             }
162         }
163         catch ( final Exception e ) {
164             e.printStackTrace( System.out );
165             return false;
166         }
167         return true;
168     }
169
170     private static boolean testNamespace() {
171         try {
172             final GoNameSpace b = new GoNameSpace( "Biological_process" );
173             final GoNameSpace c = new GoNameSpace( "Cellular_Component" );
174             final GoNameSpace m = new GoNameSpace( "molecular_function" );
175             final GoNameSpace m2 = new GoNameSpace( GoNameSpace.GoNamespaceType.MOLECULAR_FUNCTION );
176             if ( b.equals( c ) ) {
177                 return false;
178             }
179             if ( !m.equals( m2 ) ) {
180                 return false;
181             }
182             if ( !b.toString().equals( "biological_process" ) ) {
183                 return false;
184             }
185             if ( !c.toString().equals( "cellular_component" ) ) {
186                 return false;
187             }
188             if ( !m.toString().equals( "molecular_function" ) ) {
189                 return false;
190             }
191         }
192         catch ( final Exception e ) {
193             e.printStackTrace( System.out );
194             return false;
195         }
196         return true;
197     }
198
199     private static boolean testOBOparser( final File test_dir ) {
200         try {
201             final OBOparser parser = new OBOparser( new File( test_dir + ForesterUtil.getFileSeparator() + "obo_test" ),
202                                                     OBOparser.ReturnType.BASIC_GO_TERM );
203             final List<GoTerm> go_terms = parser.parse();
204             if ( parser.getGoTermCount() != 26 ) {
205                 return false;
206             }
207             final GoTerm g0 = go_terms.get( 0 );
208             final GoTerm g1 = go_terms.get( 1 );
209             final GoTerm g3 = go_terms.get( 2 );
210             final GoTerm g2 = go_terms.get( 25 );
211             if ( !g0.getComment().equals( "" ) ) {
212                 return false;
213             }
214             if ( !g0.getDefinition()
215                     .equals( "\"The distribution of mitochondria, including the mitochondrial genome, into daughter cells after mitosis or meiosis, mediated by interactions between mitochondria and the cytoskeleton.\" [GOC:mcc, PMID:10873824, PMID:11389764]" ) ) {
216                 return false;
217             }
218             if ( !g0.getGoId().getId().equals( "GO:0000001" ) ) {
219                 return false;
220             }
221             if ( g0.getGoNameSpace().equals( GoNameSpace.GoNamespaceType.BIOLOGICAL_PROCESS ) ) {
222                 return false;
223             }
224             if ( g0.getGoNameSpace().getType() != GoNameSpace.GoNamespaceType.BIOLOGICAL_PROCESS ) {
225                 return false;
226             }
227             if ( g0.getGoRelationships().size() != 0 ) {
228                 return false;
229             }
230             if ( g0.getGoXRefs().size() != 0 ) {
231                 return false;
232             }
233             if ( !g0.getName().equals( "mitochondrion inheritance" ) ) {
234                 return false;
235             }
236             if ( g0.getSuperGoIds().size() != 2 ) {
237                 return false;
238             }
239             if ( !g0.isObsolete() ) {
240                 return false;
241             }
242             if ( !g1.getComment().equals( "comment" ) ) {
243                 return false;
244             }
245             if ( !g1.getDefinition()
246                     .equals( "\"The maintenance of the structure and integrity of the mitochondrial genome.\" [GOC:ai]" ) ) {
247                 return false;
248             }
249             if ( !g1.getGoId().getId().equals( "GO:0000002" ) ) {
250                 return false;
251             }
252             if ( g1.getGoNameSpace().equals( GoNameSpace.GoNamespaceType.BIOLOGICAL_PROCESS ) ) {
253                 return false;
254             }
255             if ( g1.getGoNameSpace().getType() != GoNameSpace.GoNamespaceType.BIOLOGICAL_PROCESS ) {
256                 return false;
257             }
258             if ( g1.getGoRelationships().size() != 1 ) {
259                 return false;
260             }
261             if ( g1.getGoXRefs().size() != 5 ) {
262                 return false;
263             }
264             if ( !g1.getName().equals( "mitochondrial genome maintenance" ) ) {
265                 return false;
266             }
267             if ( g1.getSuperGoIds().size() != 1 ) {
268                 return false;
269             }
270             if ( g1.isObsolete() ) {
271                 return false;
272             }
273             if ( !g1.getGoXRefs().get( 0 ).equals( new BasicGoXRef( "EC:2.4.1.-" ) ) ) {
274                 return false;
275             }
276             if ( !g1.getGoXRefs().get( 0 ).getXRef().equals( "2.4.1.-" ) ) {
277                 return false;
278             }
279             if ( g1.getGoXRefs().get( 0 ).getType() != GoXRef.Type.EC ) {
280                 return false;
281             }
282             if ( g1.getGoXRefs().get( 0 ).equals( new BasicGoXRef( "EC:2.4.1.1" ) ) ) {
283                 return false;
284             }
285             if ( g1.getGoXRefs().get( 0 ).equals( new BasicGoXRef( "Reactome:2.4.1.-" ) ) ) {
286                 return false;
287             }
288             if ( !g1.getGoXRefs().get( 1 ).equals( new BasicGoXRef( "Reactome:7672" ) ) ) {
289                 return false;
290             }
291             if ( !g1.getGoXRefs().get( 2 ).equals( new BasicGoXRef( "MetaCyc:SIROHEME-FERROCHELAT-RXN" ) ) ) {
292                 return false;
293             }
294             if ( !g1.getGoXRefs().get( 3 ).equals( new BasicGoXRef( "RESID:AA02376" ) ) ) {
295                 return false;
296             }
297             if ( !g1.getGoXRefs().get( 4 ).equals( new BasicGoXRef( "UM-BBD_enzymeID:e0271" ) ) ) {
298                 return false;
299             }
300             if ( !g1.getGoRelationships().get( 0 ).equals( new BasicGoRelationship( "part_of GO:0007052" ) ) ) {
301                 return false;
302             }
303             if ( !g1.getGoRelationships().get( 0 ).getGoId().equals( new GoId( "GO:0007052" ) ) ) {
304                 return false;
305             }
306             if ( !g1.getGoRelationships().get( 0 ).getGoId().getId().equals( "GO:0007052" ) ) {
307                 return false;
308             }
309             if ( g1.getGoRelationships().get( 0 ).getType() != GoRelationship.Type.PART_OF ) {
310                 return false;
311             }
312             if ( g1.getGoRelationships().get( 0 ).equals( new BasicGoRelationship( "part_of GO:1007052" ) ) ) {
313                 return false;
314             }
315             if ( !g1.getSuperGoIds().get( 0 ).equals( new GoId( "GO:0007005" ) ) ) {
316                 return false;
317             }
318             if ( g1.getSuperGoIds().get( 0 ).equals( new GoId( "GO:1007005" ) ) ) {
319                 return false;
320             }
321             if ( !g2.getGoId().getId().equals( "GO:0000030" ) ) {
322                 return false;
323             }
324             if ( !g2.getGoId().equals( new GoId( "GO:0000030" ) ) ) {
325                 return false;
326             }
327             if ( g2.getGoId().getId().equals( "GO:0000031" ) ) {
328                 return false;
329             }
330             if ( g2.getGoId().equals( new GoId( "GO:0000031" ) ) ) {
331                 return false;
332             }
333             if ( g3.getGoSubsets().size() != 3 ) {
334                 return false;
335             }
336             if ( !g3.getGoSubsets().contains( new BasicGoSubset( "goslim_generic" ) ) ) {
337                 return false;
338             }
339             if ( !g3.getGoSubsets().contains( new BasicGoSubset( "goslim_plant" ) ) ) {
340                 return false;
341             }
342             if ( !g3.getGoSubsets().contains( new BasicGoSubset( "gosubset_prok" ) ) ) {
343                 return false;
344             }
345             if ( g3.getGoSubsets().contains( new BasicGoSubset( "goslim_candida" ) ) ) {
346                 return false;
347             }
348         }
349         catch ( final Exception e ) {
350             e.printStackTrace( System.out );
351             return false;
352         }
353         return true;
354     }
355
356     private static boolean testPfamToGoMapping() {
357         try {
358             final PfamToGoMapping pg0 = new PfamToGoMapping( "A", new GoId( "GO:0000001" ) );
359             final PfamToGoMapping pg1 = new PfamToGoMapping( "A", new GoId( "GO:0000001" ) );
360             final PfamToGoMapping pg2 = new PfamToGoMapping( "B", new GoId( "GO:0000001" ) );
361             final PfamToGoMapping pg3 = new PfamToGoMapping( "A", new GoId( "GO:0000002" ) );
362             final PfamToGoMapping pg4 = new PfamToGoMapping( "B", new GoId( "GO:0000002" ) );
363             if ( !pg0.equals( pg0 ) ) {
364                 return false;
365             }
366             if ( !pg0.equals( pg1 ) ) {
367                 return false;
368             }
369             if ( pg0.equals( pg2 ) ) {
370                 return false;
371             }
372             if ( pg0.equals( pg3 ) ) {
373                 return false;
374             }
375             if ( pg0.equals( pg4 ) ) {
376                 return false;
377             }
378             if ( pg0.compareTo( pg3 ) != 0 ) {
379                 return false;
380             }
381             if ( pg0.compareTo( pg2 ) >= 0 ) {
382                 return false;
383             }
384             if ( pg2.compareTo( pg0 ) <= 0 ) {
385                 return false;
386             }
387         }
388         catch ( final Exception e ) {
389             e.printStackTrace( System.out );
390             return false;
391         }
392         return true;
393     }
394
395     private static boolean testPfamToGoParser( final File test_dir ) {
396         try {
397             final PfamToGoParser parser = new PfamToGoParser( new File( test_dir + ForesterUtil.getFileSeparator()
398                     + "pfam_to_go_test" ) );
399             final List<PfamToGoMapping> mappings = parser.parse();
400             if ( parser.getMappingCount() != 426 ) {
401                 return false;
402             }
403             if ( mappings.size() != 426 ) {
404                 return false;
405             }
406             final PfamToGoMapping m0 = mappings.get( 0 );
407             final PfamToGoMapping m1 = mappings.get( 1 );
408             final PfamToGoMapping m2 = mappings.get( 2 );
409             final PfamToGoMapping m3 = mappings.get( 3 );
410             final PfamToGoMapping m4 = mappings.get( 4 );
411             final PfamToGoMapping m5 = mappings.get( 5 );
412             final PfamToGoMapping m424 = mappings.get( 424 );
413             final PfamToGoMapping m425 = mappings.get( 425 );
414             if ( !m0.getKey().equals( "7tm_1" ) ) {
415                 return false;
416             }
417             if ( !m0.getValue().equals( new GoId( "GO:0001584" ) ) ) {
418                 return false;
419             }
420             if ( m0.getKey().equals( "7tm_x" ) ) {
421                 return false;
422             }
423             if ( m0.getValue().equals( new GoId( "GO:0001585" ) ) ) {
424                 return false;
425             }
426             if ( !m1.getKey().equals( "7tm_1" ) ) {
427                 return false;
428             }
429             if ( !m1.getValue().equals( new GoId( "GO:0007186" ) ) ) {
430                 return false;
431             }
432             if ( !m2.getKey().equals( "7tm_1" ) ) {
433                 return false;
434             }
435             if ( !m2.getValue().equals( new GoId( "GO:0016021" ) ) ) {
436                 return false;
437             }
438             if ( !m3.getKey().equals( "7tm_2" ) ) {
439                 return false;
440             }
441             if ( !m3.getValue().equals( new GoId( "GO:0004930" ) ) ) {
442                 return false;
443             }
444             if ( !m4.getKey().equals( "7tm_2" ) ) {
445                 return false;
446             }
447             if ( !m4.getValue().equals( new GoId( "GO:0016020" ) ) ) {
448                 return false;
449             }
450             if ( !m5.getKey().equals( "7tm_3" ) ) {
451                 return false;
452             }
453             if ( !m5.getValue().equals( new GoId( "GO:0008067" ) ) ) {
454                 return false;
455             }
456             if ( !m424.getKey().equals( "OMPdecase" ) ) {
457                 return false;
458             }
459             if ( !m424.getValue().equals( new GoId( "GO:0006207" ) ) ) {
460                 return false;
461             }
462             if ( !m425.getKey().equals( "Bac_DNA_binding" ) ) {
463                 return false;
464             }
465             if ( !m425.getValue().equals( new GoId( "GO:0003677" ) ) ) {
466                 return false;
467             }
468         }
469         catch ( final Exception e ) {
470             e.printStackTrace( System.out );
471             return false;
472         }
473         return true;
474     }
475
476     private static boolean testSuperTermCounting( final File test_dir ) {
477         try {
478             final OBOparser parser = new OBOparser( new File( test_dir + ForesterUtil.getFileSeparator()
479                     + "gene_ontology_edit.obo" ), OBOparser.ReturnType.BASIC_GO_TERM );
480             final List<GoTerm> all_go_terms = parser.parse();
481             if ( parser.getGoTermCount() != 27748 ) {
482                 return false;
483             }
484             final Map<GoId, GoTerm> goid_to_term_map = GoUtils.createGoIdToGoTermMap( all_go_terms );
485             final List<GoTerm> categories = new ArrayList<GoTerm>();
486             final List<GoTerm> experiment_set = new ArrayList<GoTerm>();
487             experiment_set.add( new BasicGoTerm( new GoId( "GO:0005690" ), "snRNP U4atac", GoNameSpace
488                     .createUnassigned(), false ) );
489             experiment_set.add( new BasicGoTerm( new GoId( "GO:0009698" ),
490                                                  "phenylpropanoid metabolic process",
491                                                  GoNameSpace.createUnassigned(),
492                                                  false ) );
493             experiment_set.add( new BasicGoTerm( new GoId( "GO:0008150" ), "biological_process", GoNameSpace
494                     .createUnassigned(), false ) );
495             experiment_set.add( new BasicGoTerm( new GoId( "GO:0006915" ),
496                                                  "apoptosis",
497                                                  GoNameSpace.createUnassigned(),
498                                                  false ) );
499             experiment_set.add( new BasicGoTerm( new GoId( "GO:0001783" ), "B cell apoptosis", GoNameSpace
500                     .createUnassigned(), false ) );
501             experiment_set.add( new BasicGoTerm( new GoId( "GO:0010657" ), "muscle cell apoptosis", GoNameSpace
502                     .createUnassigned(), false ) );
503             experiment_set.add( new BasicGoTerm( new GoId( "GO:0010657" ), "muscle cell apoptosis", GoNameSpace
504                     .createUnassigned(), false ) );
505             experiment_set.add( new BasicGoTerm( new GoId( "GO:0010658" ),
506                                                  "striated muscle cell apoptosis",
507                                                  GoNameSpace.createUnassigned(),
508                                                  false ) );
509             experiment_set.add( new BasicGoTerm( new GoId( "GO:0043065" ),
510                                                  "positive regulation of apoptosis",
511                                                  GoNameSpace.createUnassigned(),
512                                                  false ) );
513             categories
514                     .add( new BasicGoTerm( new GoId( "GO:0016265" ), "death", GoNameSpace.createUnassigned(), false ) );
515             categories.add( new BasicGoTerm( new GoId( "GO:0006915" ),
516                                              "apoptosis",
517                                              GoNameSpace.createUnassigned(),
518                                              false ) );
519             categories.add( new BasicGoTerm( new GoId( "GO:0008150" ), "biological_process", GoNameSpace
520                     .createUnassigned(), false ) );
521             categories.add( new BasicGoTerm( new GoId( "GO:0010657" ), "muscle cell apoptosis", GoNameSpace
522                     .createUnassigned(), false ) );
523             categories.add( new BasicGoTerm( new GoId( "GO:0010658" ), "striated muscle cell apoptosis", GoNameSpace
524                     .createUnassigned(), false ) );
525             categories.add( new BasicGoTerm( new GoId( "GO:0046242" ), "o-xylene biosynthetic process", GoNameSpace
526                     .createUnassigned(), false ) );
527             categories.add( new BasicGoTerm( new GoId( "GO:0016326" ), "kinesin motor activity", GoNameSpace
528                     .createUnassigned(), false ) );
529             categories.add( new BasicGoTerm( new GoId( "GO:0005575" ), "cellular_component", GoNameSpace
530                     .createUnassigned(), false ) );
531             categories.add( new BasicGoTerm( new GoId( "GO:0032502" ), "developmental process", GoNameSpace
532                     .createUnassigned(), false ) );
533             categories.add( new BasicGoTerm( new GoId( "GO:0051094" ),
534                                              "positive regulation of developmental process",
535                                              GoNameSpace.createUnassigned(),
536                                              false ) );
537             categories.add( new BasicGoTerm( new GoId( "GO:0048522" ),
538                                              "positive regulation of cellular process",
539                                              GoNameSpace.createUnassigned(),
540                                              false ) );
541             final Map<GoId, Integer> counts = GoUtils.countCategories( categories, experiment_set, goid_to_term_map );
542             // death
543             if ( counts.get( new GoId( "GO:0016265" ) ) != 5 ) {
544                 return false;
545             }
546             // apoptosis
547             if ( counts.get( new GoId( "GO:0006915" ) ) != 5 ) {
548                 return false;
549             }
550             // biological_process
551             if ( counts.get( new GoId( "GO:0008150" ) ) != 8 ) {
552                 return false;
553             }
554             // muscle cell apoptosis
555             if ( counts.get( new GoId( "GO:0010657" ) ) != 3 ) {
556                 return false;
557             }
558             // striated muscle cell apoptosis
559             if ( counts.get( new GoId( "GO:0010658" ) ) != 1 ) {
560                 return false;
561             }
562             // o-xylene biosynthetic process
563             if ( counts.get( new GoId( "GO:0046242" ) ) != 0 ) {
564                 return false;
565             }
566             // kinesin motor activity
567             if ( counts.get( new GoId( "GO:0016326" ) ) != 0 ) {
568                 return false;
569             }
570             // cellular_component
571             if ( counts.get( new GoId( "GO:0005575" ) ) != 1 ) {
572                 return false;
573             }
574             // developmental process
575             if ( counts.get( new GoId( "GO:0032502" ) ) != 5 ) {
576                 return false;
577             }
578             // positive regulation of developmental process
579             if ( counts.get( new GoId( "GO:0051094" ) ) != 1 ) {
580                 return false;
581             }
582             // positive regulation of cellular process
583             if ( counts.get( new GoId( "GO:0048522" ) ) != 1 ) {
584                 return false;
585             }
586             final List<GoId> categories_id = new ArrayList<GoId>();
587             final List<GoId> experiment_set_id = new ArrayList<GoId>();
588             experiment_set_id.add( new GoId( "GO:0005690" ) );
589             experiment_set_id.add( new GoId( "GO:0009698" ) );
590             experiment_set_id.add( new GoId( "GO:0008150" ) );
591             experiment_set_id.add( new GoId( "GO:0006915" ) );
592             experiment_set_id.add( new GoId( "GO:0001783" ) );
593             experiment_set_id.add( new GoId( "GO:0010657" ) );
594             experiment_set_id.add( new GoId( "GO:0010657" ) );
595             experiment_set_id.add( new GoId( "GO:0010658" ) );
596             categories_id.add( new GoId( "GO:0016265" ) );
597             categories_id.add( new GoId( "GO:0006915" ) );
598             categories_id.add( new GoId( "GO:0008150" ) );
599             categories_id.add( new GoId( "GO:0010657" ) );
600             categories_id.add( new GoId( "GO:0010658" ) );
601             categories_id.add( new GoId( "GO:0046242" ) );
602             categories_id.add( new GoId( "GO:0016326" ) );
603             categories_id.add( new GoId( "GO:0005575" ) );
604             final Map<GoId, Integer> counts_id = GoUtils.countCategoriesId( categories_id,
605                                                                             experiment_set_id,
606                                                                             goid_to_term_map );
607             // death
608             if ( counts_id.get( new GoId( "GO:0016265" ) ) != 5 ) {
609                 return false;
610             }
611             // apoptosis
612             if ( counts_id.get( new GoId( "GO:0006915" ) ) != 5 ) {
613                 return false;
614             }
615             // biological_process
616             if ( counts_id.get( new GoId( "GO:0008150" ) ) != 7 ) {
617                 return false;
618             }
619             // muscle cell apoptosis
620             if ( counts_id.get( new GoId( "GO:0010657" ) ) != 3 ) {
621                 return false;
622             }
623             // striated muscle cell apoptosis
624             if ( counts_id.get( new GoId( "GO:0010658" ) ) != 1 ) {
625                 return false;
626             }
627             // o-xylene biosynthetic process
628             if ( counts_id.get( new GoId( "GO:0046242" ) ) != 0 ) {
629                 return false;
630             }
631             // kinesin motor activity
632             if ( counts_id.get( new GoId( "GO:0016326" ) ) != 0 ) {
633                 return false;
634             }
635             // cellular_componen
636             if ( counts_id.get( new GoId( "GO:0005575" ) ) != 1 ) {
637                 return false;
638             }
639         }
640         catch ( final Exception e ) {
641             e.printStackTrace( System.out );
642             return false;
643         }
644         return true;
645     }
646
647     private static boolean testSuperTermGetting( final File test_dir ) {
648         try {
649             final OBOparser parser = new OBOparser( new File( test_dir + ForesterUtil.getFileSeparator()
650                     + "gene_ontology_edit.obo" ), OBOparser.ReturnType.BASIC_GO_TERM );
651             final List<GoTerm> go_terms = parser.parse();
652             if ( parser.getGoTermCount() != 27748 ) {
653                 return false;
654             }
655             final Map<GoId, GoTerm> goid_to_term_map = GoUtils.createGoIdToGoTermMap( go_terms );
656             final SortedSet<GoTerm> b_cell_selection = GoUtils.getAllSuperGoTerms( new GoId( "GO:0002339" ),
657                                                                                    goid_to_term_map );
658             if ( b_cell_selection.size() != 2 ) {
659                 return false;
660             }
661             if ( !b_cell_selection.contains( new BasicGoTerm( new GoId( "GO:0002376" ),
662                                                               "immune system process",
663                                                               GoNameSpace.createBiologicalProcess(),
664                                                               false ) ) ) {
665                 return false;
666             }
667             if ( !b_cell_selection.contains( new BasicGoTerm( new GoId( "GO:0008150" ),
668                                                               "biological process",
669                                                               GoNameSpace.createBiologicalProcess(),
670                                                               false ) ) ) {
671                 return false;
672             }
673             final SortedSet<GoTerm> b_cell_differentation = GoUtils.getAllSuperGoTerms( new GoId( "GO:0030183" ),
674                                                                                         goid_to_term_map );
675             if ( b_cell_differentation.size() != 12 ) {
676                 return false;
677             }
678             final SortedSet<GoTerm> biological_process = GoUtils.getAllSuperGoTerms( new GoId( "GO:0008150" ),
679                                                                                      goid_to_term_map );
680             if ( biological_process.size() != 0 ) {
681                 return false;
682             }
683             final SortedSet<GoTerm> protein_aa_phosphorylation = GoUtils.getAllSuperGoTerms( new GoId( "GO:0006468" ),
684                                                                                              goid_to_term_map );
685             if ( protein_aa_phosphorylation.size() != 16 ) {
686                 return false;
687             }
688         }
689         catch ( final Exception e ) {
690             e.printStackTrace( System.out );
691             return false;
692         }
693         return true;
694     }
695 }