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