Commit patch to not break on spaces.
[bowtie.git] / annot.h
1 /*
2  * annot.h
3  *
4  *  Created on: Aug 3, 2009
5  *      Author: Ben Langmead
6  */
7
8 #ifndef ANNOT_H_
9 #define ANNOT_H_
10
11 #include <stdint.h>
12 #include <map>
13 #include <iostream>
14 #include <fstream>
15
16 /**
17  * Encapsulates a sorted list of reference positions that are annotated
18  * somehow (e.g. as a SNP).
19  */
20 class AnnotationMap {
21 public:
22         typedef std::pair<uint32_t, uint32_t> U32Pair;
23         typedef std::pair<char, char> CharPair;
24         typedef std::map<U32Pair, CharPair> AnnotMap;
25         typedef std::map<U32Pair, CharPair>::const_iterator Iter;
26
27         AnnotationMap(const char *fname) {
28                 fname_ = fname;
29                 parse();
30         }
31
32         /**
33          * Give a reference coordinate in the index, translate it into a
34          * new reference coordinate via the reference map supplied by the
35          * user.
36          */
37         Iter lower_bound(const U32Pair& h) const {
38                 return map_.lower_bound(h);
39         }
40
41         Iter begin() const {
42                 return map_.begin();
43         }
44
45         Iter end() const {
46                 return map_.end();
47         }
48
49 protected:
50
51         /**
52          * Parse an annotation-map file.
53          */
54         void parse();
55
56         /// filename of file containing the annotation map
57         const char *fname_;
58         /// maps reference positions to character annotations
59         AnnotMap map_;
60 };
61
62 #endif /* ANNOT_H_ */