Source

sleipnir / src / annotation.h

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/*****************************************************************************
* This file is provided under the Creative Commons Attribution 3.0 license.
*
* You are free to share, copy, distribute, transmit, or adapt this work
* PROVIDED THAT you attribute the work to the authors listed below.
* For more information, please see the following web page:
* http://creativecommons.org/licenses/by/3.0/
*
* This file is a component of the Sleipnir library for functional genomics,
* authored by:
* Curtis Huttenhower (chuttenh@princeton.edu)
* Mark Schroeder
* Maria D. Chikina
* Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
*
* If you use this library, the included executable tools, or any related
* code in your work, please cite the following publication:
* Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
* Olga G. Troyanskaya.
* "The Sleipnir library for computational functional genomics"
*****************************************************************************/
#ifndef ANNOTATION_H
#define ANNOTATION_H

namespace Sleipnir {

/*!
 * \brief
 * Encapsulates the hypergeometric functional enrichment of a query against one ontology term.
 * 
 * Generated by an IOntology::TermFinder call, each STermFound struct represents the hypergeometric
 * enrichment of one ontology term for a set of query genes.  Documentation assumes a set of query
 * genes Q and a set of term genes T.
 * 
 * \see
 * IOntology
 */
struct STermFound {
	/*!
	 * \brief
	 * ID of the ontology term for this enrichment.
	 */
	size_t	m_iID;
	/*!
	 * \brief
	 * Hypergeometric p-value of this enrichment.
	 */
	double	m_dP;
	/*!
	 * \brief
	 * The number of genes in Q intersect T.
	 */
	size_t	m_iHitsTerm;
	/*!
	 * \brief
	 * The number of genes in T.
	 */
	size_t	m_iSizeTerm;
	/*!
	 * \brief
	 * The number of genes in Q.
	 */
	size_t	m_iHitsTotal;
	/*!
	 * \brief
	 * The total number of genes in the background set (genome).
	 */
	size_t	m_iSizeTotal;

	/*!
	 * \brief
	 * Construct a new structure with the given parameter values.
	 * 
	 * \param iID
	 * ID of the ontology term for this enrichment.
	 * 
	 * \param dP
	 * Hypergeometric p-value of this enrichment.
	 * 
	 * \param iHitsTerm
	 * The number of genes in Q intersect T.
	 * 
	 * \param iSizeTerm
	 * The number of genes in T.
	 * 
	 * \param iHitsTotal
	 * The number of genes in Q.
	 * 
	 * \param iSizeTotal
	 * The total number of genes in the background set (genome).
	 */
	STermFound( size_t iID, double dP, size_t iHitsTerm, size_t iSizeTerm, size_t iHitsTotal, size_t iSizeTotal ) :
		m_iID(iID), m_dP(dP), m_iHitsTerm(iHitsTerm), m_iSizeTerm(iSizeTerm), m_iHitsTotal(iHitsTotal),
		m_iSizeTotal(iSizeTotal) { }
};

}

#include "annotationi.h"

namespace Sleipnir {

/*!
 * \brief
 * Encapsulates a functional catalog/hierarchy/ontology such as GO, KEGG, or MIPS.
 * 
 * IOntology provides a uniform interface able to capture ontological functional catalogs such as the
 * Gene Ontology, hierarchical catalogs such as MIPS, and (essentially) flag functional groupings such
 * as KEGG.  IOntology's structure is modeled on GO's, being the most general: each term in the
 * functional catalog has zero or more parents (more general terms), zero or more children (more specific
 * terms), and zero or more directly annotated genes.  A gene annotated to some term is also implicitly
 * annotated to that term's ancestors.
 * 
 * \see
 * COntologyKEGG | COntologyOBO | COntologyMIPS | COntologyMIPSPhenotypes | CSlim
 */
class IOntology {
public:
	/*!
	 * \brief
	 * Returns string identifier of the encapsulated ontology.
	 * 
	 * \returns
	 * String identifier of the ontology.
	 */
	virtual const std::string& GetID( ) const = 0;
	/*!
	 * \brief
	 * Returns the number of nodes (terms) in the ontology.
	 * 
	 * \returns
	 * Number of nodes (terms) in the ontology.
	 */
	virtual size_t GetNodes( ) const = 0;
	/*!
	 * \brief
	 * Returns the ontology-specific ID string of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \returns
	 * Ontology-specific ID of the requested term (e.g. "GO:0007093").
	 */
	virtual const std::string& GetID( size_t iTerm ) const = 0;
	/*!
	 * \brief
	 * Returns the ontology-specific description of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \returns
	 * Ontology-specific description of the requested term (e.g. "mitotic cell cycle").
	 */
	virtual const std::string& GetGloss( size_t iTerm ) const = 0;
	/*!
	 * \brief
	 * Returns the number of parents of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \returns
	 * Number of parents of the requested term.
	 */
	virtual size_t GetParents( size_t iTerm ) const = 0;
	/*!
	 * \brief
	 * Returns the ontology term index of the requested parent of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \param iParent
	 * Parent to retrieve.
	 * 
	 * \returns
	 * Ontology term index of the requested parent.
	 * 
	 * \remarks
	 * Requested parent must be less than IOntology::GetParents.
	 */
	virtual size_t GetParent( size_t iTerm, size_t iParent ) const = 0;
	/*!
	 * \brief
	 * Returns the number of children of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \returns
	 * Number of children of the requested term.
	 */
	virtual size_t GetChildren( size_t iTerm ) const = 0;
	/*!
	 * \brief
	 * Returns the ontology term index of the requested child of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \param iChild
	 * Child to retrieve.
	 * 
	 * \returns
	 * Ontology term index of the requested child.
	 * 
	 * \remarks
	 * Requested child must be less than IOntology::GetChildren.
	 */
	virtual size_t GetChild( size_t iTerm, size_t iChild ) const = 0;
	/*!
	 * \brief
	 * Retrieves the parent term IDs of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \param setiParents
	 * Output set of parent term IDs.
	 * 
	 * \returns
	 * True on success, false otherwise.
	 * 
	 * \remarks
	 * Operates recursively, returning all nodes between iTerm and the ontology root.
	 * 
	 * \see
	 * GetParents | GetParent
	 */
	virtual bool GetParents( size_t iTerm, std::set<size_t>& setiParents ) const = 0;
	/*!
	 * \brief
	 * Retrieves the descendant term IDs of the requested term.
	 * 
	 * \param iTerm
	 * Index of ontology term.
	 * 
	 * \param setiChildren
	 * Output set of descendant term IDs.
	 * 
	 * \returns
	 * True on success, false otherwise.
	 * 
	 * \remarks
	 * Operates recursively, returning all nodes between iTerm and the ontology leaves.
	 * 
	 * \see
	 * GetChildren | GetChild
	 */
	virtual bool GetChildren( size_t iTerm, std::set<size_t>& setiChildren ) const = 0;
	/*!
	 * \brief
	 * Returns the number of genes annotated to or (optionally) below this term.
	 * 
	 * \param iTerm
	 * Ontology term index.
	 * 
	 * \param fRecursive
	 * If true, include gene annotations to descendant terms.
	 * 
	 * \returns
	 * Number of genes annotated to or below this term.
	 */
	virtual size_t GetGenes( size_t iTerm, bool fRecursive = false ) const = 0;
	/*!
	 * \brief
	 * Returns the requested gene annotated to or below the given term.
	 * 
	 * \param iTerm
	 * Ontology term index from which to retrieve gene.
	 * 
	 * \param iGene
	 * Index of gene within the requested term.
	 * 
	 * \returns
	 * Gene annotation at the requested index.
	 * 
	 * \remarks
	 * If iGene is less than the number of genes annotated directly to the term, a direct annotation is
	 * returned.  Otherwise, descendant terms are searched and the requested gene index is retrieved from
	 * this set.  iGene must be less than the value of IOntology::GetGenes.
	 */
	virtual const CGene& GetGene( size_t iTerm, size_t iGene ) const = 0;
	/*!
	 * \brief
	 * Indicates whether the given gene is annotated to or (optionally) below the given term.
	 * 
	 * \param iTerm
	 * Ontology term index.
	 * 
	 * \param Gene
	 * Gene for which annotation is tested.
	 * 
	 * \param fRecursive
	 * If true, include annotations to descendants of the given term.
	 * 
	 * \returns
	 * True if the given gene is annotated to or (optionally) below the given term.
	 */
	virtual bool IsAnnotated( size_t iTerm, const CGene& Gene, bool fRecursive = true ) const = 0;
	/*!
	 * \brief
	 * Returns the ontology term index corresponding to the given ontology-specific ID string.
	 * 
	 * \param strID
	 * Ontology term ID to retrieve (e.g. "GO:0007093").
	 * 
	 * \returns
	 * The index of the requested term, -1 if not found.
	 */
	virtual size_t GetNode( const std::string& strID ) const = 0;
	/*!
	 * \brief
	 * Obtain the primary gene names for all genes in the ontology.
	 * 
	 * \param vecstrGenes
	 * Outputs primary gene names for all genes in the ontology.
	 */
	virtual void GetGeneNames( std::vector<std::string>& vecstrGenes ) const = 0;
	/*!
	 * \brief
	 * Uses the hypergeometric distribution to find functional enrichments of the given gene set.
	 * 
	 * \param Genes
	 * Gene set to test for functional enrichments.
	 * 
	 * \param vecsTerms
	 * Output statistics for the given genes over all terms in the ontology.
	 * 
	 * \param fBonferroni
	 * If true, p-values are Bonferroni corrected.
	 * 
	 * \param fRecursive
	 * If true, annotations to descendants are used when calculating term overlaps.
	 * 
	 * \param fGenome
	 * If true, use all genes in the genome as background; otherwise, use only genes with at least one
	 * annotation in the ontology.
	 * 
	 * \param dPValue
	 * Only terms significant below this p-value will be recorded.
	 * 
	 * \param pBackground
	 * If non-null, use the given gene set as the background.
	 * 
	 * TermFinder uses the GO::TermFinder technique of Boyle, Sherlock, et al to calculate ontology
	 * terms (i.e. functions) enriched in the given gene set.  This involves significance testing the
	 * overlap of the given gene set with annotations to every ontology term using the hypergeometric
	 * test.
	 */
	virtual void TermFinder( const CGenes& Genes, std::vector<STermFound>& vecsTerms, bool fBonferroni = true,
		bool fRecursive = true, bool fGenome = false, float dPValue = 1,
		const CGenes* pBackground = NULL ) const = 0;
};

// TODO: These should really be templated instead of duplicated like this...

/*!
 * \brief
 * Implements IOntology for the KEGG orthology.
 * 
 * COntologyKEGG parses the "ko" file from the Kyoto Encyclopedia of Genes and Genomes to extract
 * organism-independent function annotations from KEGG.
 */
class COntologyKEGG : COntologyKEGGImpl, public IOntology {
public:
	COntologyKEGG( );
	bool Open( std::istream& istm, CGenome& Genome, const std::string& strOrganism, bool fSynonyms = false );

	void GetGeneNames( std::vector<std::string>& vecstrGenes ) const {

		 COntologyImpl::GetGeneNames( vecstrGenes ); }

	void TermFinder( const CGenes& Genes, std::vector<STermFound>& vecsTerms, bool fBonferroni = true,
		bool fRecursive = true, bool fGenome = false, float dPValue = 1,
		const CGenes* pBackground = NULL ) const {

		 COntologyImpl::TermFinder( Genes, vecsTerms, fBonferroni, fRecursive, fGenome, dPValue,
			pBackground ); }

	size_t GetNode( const std::string& strID ) const {

		return COntologyImpl::GetNode( strID ); }

	bool IsAnnotated( size_t iTerm, const CGene& Gene, bool fRecursive ) const {

		return COntologyImpl::IsAnnotated( iTerm, Gene, fRecursive ); }

	size_t GetNodes( ) const {

		return COntologyImpl::GetNodes( ); }

	const std::string& GetID( ) const {

		return COntologyImpl::GetID( ); }

	const std::string& GetID( size_t iTerm ) const {

		return COntologyImpl::GetID( iTerm ); }

	const std::string& GetGloss( size_t iTerm ) const {

		return COntologyImpl::GetGloss( iTerm ); }

	size_t GetParents( size_t iTerm ) const {

		return COntologyImpl::GetParents( iTerm ); }

	size_t GetParent( size_t iTerm, size_t iParent ) const {

		return COntologyImpl::GetParent( iTerm, iParent ); }

	size_t GetChildren( size_t iTerm ) const {

		return COntologyImpl::GetChildren( iTerm ); }

	size_t GetChild( size_t iTerm, size_t iChild ) const {

		return COntologyImpl::GetChild( iTerm, iChild ); }

	size_t GetGenes( size_t iTerm, bool fRecursive ) const {

		return COntologyImpl::GetGenes( iTerm, fRecursive ); }

	const CGene& GetGene( size_t iTerm, size_t iGene ) const {

		return COntologyImpl::GetGene( iTerm, iGene ); }

	bool GetParents( size_t iTerm, std::set<size_t>& setiParents ) const {

		return COntologyImpl::GetParents( iTerm, setiParents ); }

	bool GetChildren( size_t iTerm, std::set<size_t>& setiChildren ) const {

		return COntologyImpl::GetChildren( iTerm, setiChildren ); }
};

/*!
 * \brief
 * Implements IOntology for OBO based Ontologies.
 * 
 * COntologyOBO parses OBO and annotation files to obtain the structure and annotations
 * for OBO ontologies.
 */
class COntologyOBO : COntologyOBOImpl, public IOntology {
public:
	/*!
	 * \brief
	 * Common Gene Ontology aspects/namespaces: biological process.
	 */
	static const char	c_szBiologicalProcess[];
	/*!
	 * \brief
	 * Common Gene Ontology aspects/namespaces: cellular component.
	 */
	static const char	c_szCellularComponent[];
	/*!
	 * \brief
	 * Common Gene Ontology aspects/namespaces: molecular function.
	 */
	static const char	c_szMolecularFunction[];

	static bool Open( std::istream& istmOntology, std::istream& istmAnnotations, CGenome& Genome,
			COntologyOBO& OntoBP, COntologyOBO& OntoMF, COntologyOBO& OntoCC, bool fDatabaseIDs = false,
		bool fSynonyms = false );

	COntologyOBO( );
	bool Open( std::istream& istmOntology, std::istream& istmAnnotations, CGenome& Genome,
		const char* szNamespace, bool fDatabaseIDs = false, bool fSynonyms = false );

	void GetGeneNames( std::vector<std::string>& vecstrGenes ) const {

		return COntologyImpl::GetGeneNames( vecstrGenes ); }

	void TermFinder( const CGenes& Genes, std::vector<STermFound>& vecsTerms, bool fBonferroni = true,
		bool fRecursive = true, bool fGenome = false, float dPValue = 1,
		const CGenes* pBackground = NULL ) const {

		return COntologyImpl::TermFinder( Genes, vecsTerms, fBonferroni, fRecursive, fGenome, dPValue,
			pBackground ); }

	size_t GetNode( const std::string& strID ) const {

		return COntologyImpl::GetNode( strID ); }

	bool IsAnnotated( size_t iTerm, const CGene& Gene, bool fRecursive ) const {

		return COntologyImpl::IsAnnotated( iTerm, Gene, fRecursive ); }

	size_t GetNodes( ) const {

		return COntologyImpl::GetNodes( ); }

	const std::string& GetID( ) const {

		return COntologyImpl::GetID( ); }

	const std::string& GetID( size_t iTerm ) const {

		return COntologyImpl::GetID( iTerm ); }

	const std::string& GetGloss( size_t iTerm ) const {

		return COntologyImpl::GetGloss( iTerm ); }

	size_t GetParents( size_t iTerm ) const {

		return COntologyImpl::GetParents( iTerm ); }

	size_t GetParent( size_t iTerm, size_t iParent ) const {

		return COntologyImpl::GetParent( iTerm, iParent ); }

	size_t GetChildren( size_t iTerm ) const {

		return COntologyImpl::GetChildren( iTerm ); }

	size_t GetChild( size_t iTerm, size_t iChild ) const {

		return COntologyImpl::GetChild( iTerm, iChild ); }

	size_t GetGenes( size_t iTerm, bool fRecursive ) const {

		return COntologyImpl::GetGenes( iTerm, fRecursive ); }

	const CGene& GetGene( size_t iTerm, size_t iGene ) const {

		return COntologyImpl::GetGene( iTerm, iGene ); }

	bool GetParents( size_t iTerm, std::set<size_t>& setiParents ) const {

		return COntologyImpl::GetParents( iTerm, setiParents ); }

	bool GetChildren( size_t iTerm, std::set<size_t>& setiChildren ) const {

		return COntologyImpl::GetChildren( iTerm, setiChildren ); }
};

/*!
 * \brief
 * Implements IOntology for the MIPS functional catalog.
 * 
 * COntologyMIPS parses the "funcat" structure and annotation files from the Munich Information center for
 * Protein Sequences.
 */
class COntologyMIPS : protected COntologyMIPSImpl, public IOntology {
public:
	COntologyMIPS( );
	bool Open( std::istream& istmOntology, std::istream& istmAnnotations, CGenome& Genome );

	void GetGeneNames( std::vector<std::string>& vecstrGenes ) const {

		return COntologyImpl::GetGeneNames( vecstrGenes ); }

	void TermFinder( const CGenes& Genes, std::vector<STermFound>& vecsTerms, bool fBonferroni = true,
		bool fRecursive = true, bool fGenome = false, float dPValue = 1,
		const CGenes* pBackground = NULL ) const {

		return COntologyImpl::TermFinder( Genes, vecsTerms, fBonferroni, fRecursive, fGenome, dPValue,
			pBackground ); }

	size_t GetNode( const std::string& strID ) const {

		return COntologyImpl::GetNode( strID ); }

	bool IsAnnotated( size_t iTerm, const CGene& Gene, bool fRecursive ) const {

		return COntologyImpl::IsAnnotated( iTerm, Gene, fRecursive ); }

	size_t GetNodes( ) const {

		return COntologyImpl::GetNodes( ); }

	const std::string& GetID( ) const {

		return COntologyImpl::GetID( ); }

	const std::string& GetID( size_t iTerm ) const {

		return COntologyImpl::GetID( iTerm ); }

	const std::string& GetGloss( size_t iTerm ) const {

		return COntologyImpl::GetGloss( iTerm ); }

	size_t GetParents( size_t iTerm ) const {

		return COntologyImpl::GetParents( iTerm ); }

	size_t GetParent( size_t iTerm, size_t iParent ) const {

		return COntologyImpl::GetParent( iTerm, iParent ); }

	size_t GetChildren( size_t iTerm ) const {

		return COntologyImpl::GetChildren( iTerm ); }

	size_t GetChild( size_t iTerm, size_t iChild ) const {

		return COntologyImpl::GetChild( iTerm, iChild ); }

	size_t GetGenes( size_t iTerm, bool fRecursive ) const {

		return COntologyImpl::GetGenes( iTerm, fRecursive ); }

	const CGene& GetGene( size_t iTerm, size_t iGene ) const {

		return COntologyImpl::GetGene( iTerm, iGene ); }

	bool GetParents( size_t iTerm, std::set<size_t>& setiParents ) const {

		return COntologyImpl::GetParents( iTerm, setiParents ); }

	bool GetChildren( size_t iTerm, std::set<size_t>& setiChildren ) const {

		return COntologyImpl::GetChildren( iTerm, setiChildren ); }
};

/*!
 * \brief
 * Extends COntologyMIPS to include the (apparently defunct) "phencat" phenotype hierarchy.
 * 
 * COntologyMIPS parses the "phencat" structure and annotation files from the Munich Information center for
 * Protein Sequences.
 */
class COntologyMIPSPhenotypes : public COntologyMIPS {
public:
	COntologyMIPSPhenotypes( );

protected:
	/*!
	 * \brief
	 * String identifier for the MIPS Phenotype ontology.
	 */
	static const char	c_szMIPSPhen[];
};

/*!
 * \brief
 * Represents a set of ontology terms.
 * 
 * Modeled after the "GO Slim" sets of GO terms, CSlim represents any set of IOntology terms.  A slim is
 * generally opened from a text file listing ontology IDs and can be used in a variety of settings, e.g.
 * functional enrichment or gold standard generation.
 * 
 * \see
 * CDat::Open | CDataPair::Open
 */
class CSlim : CSlimImpl {
public:
	bool Open( std::istream& istmSlim, const IOntology* pOntology );
	void GetGeneNames( std::vector<std::string>& vecstrGenes ) const;

	/*!
	 * \brief
	 * Returns the gene at the requested index below the requested slim term.
	 * 
	 * \param iSlim
	 * Index of the slim term for which a gene are retrieved.
	 * 
	 * \param iGene
	 * Index of the gene to retrieve.
	 * 
	 * \returns
	 * Gene annotated at the requested index below the requested slim term.
	 * 
	 * \remarks
	 * iSlim must be less than CSlim::GetSlims; iGene must be less than CSlim::GetGenes.  All genes annotated
	 * recursively to descendants of the slim terms are considered.
	 * 
	 * \see
	 * IOntology::GetGenes
	 */
	const CGene& GetGene( size_t iSlim, size_t iGene ) const {

		return *m_vecvecpGenes[ iSlim ][ iGene ]; }

	/*!
	 * \brief
	 * Returns the number of ontology terms in this slim.
	 * 
	 * \returns
	 * Number of ontology terms in this slim.
	 */
	size_t GetSlims( ) const {

		return m_vecstrSlims.size( ); }

	/*!
	 * \brief
	 * Returns the number of genes annotated below the given slim term.
	 * 
	 * \param iSlim
	 * Index of the slim term for which genes are retrieved.
	 * 
	 * \returns
	 * Number of genes annotated below the given slim term.
	 * 
	 * \remarks
	 * iSlim must be less than CSlim::GetSlims.
	 */
	size_t GetGenes( size_t iSlim ) const {

		return m_vecvecpGenes[ iSlim ].size( ); }

	/*!
	 * \brief
	 * Returns the string ID of the ontology term at the given slim index.
	 * 
	 * \param iSlim
	 * Index of the slim term to identify.
	 * 
	 * \returns
	 * String ID of the requested slim index.
	 * 
	 * \remarks
	 * iSlim must be less than CSlim::GetSlims.
	 */
	const std::string& GetSlim( size_t iSlim ) const {

		return m_vecstrSlims[ iSlim ]; }

	/*!
	 * \brief
	 * Returns the number of ontology terms in the requested slim.
	 * 
	 * \param iSlim
	 * ID of slim.
	 * 
	 * \returns
	 * Number of ontology terms in the requested slim.
	 * 
	 * \see
	 * GetNode
	 */
	size_t GetNodes( size_t iSlim ) const {

		return m_vecveciTerms[ iSlim ].size( ); }

	/*!
	 * \brief
	 * Returns the ontology term ID at the requested index in the requested slim.
	 * 
	 * \param iSlim
	 * ID of slim.
	 * 
	 * \param iTerm
	 * Index of ontology term to be returned.
	 * 
	 * \returns
	 * Ontology term at the requested index within the given slim.
	 * 
	 * \remarks
	 * No bounds checking is performed; iSlim must be less than GetSlims, and iTerm must be less than GetNodes.
	 * 
	 * \see
	 * GetNodes
	 */
	size_t GetNode( size_t iSlim, size_t iTerm ) const {

		return m_vecveciTerms[ iSlim ][ iTerm ]; }
};

}

#endif // ANNOTATION_H