4 * Created on: Aug 3, 2009
10 #include "assert_helpers.h"
15 * Given a refid,offset pair in the index space, transform it into the
16 * reference coordinate space according to the reference mappings
17 * provided by the user.
19 void ReferenceMap::map(U32Pair& h) const {
20 if(h.first >= map_.size()) {
21 cerr << "Could not find a reference-map entry for reference "
22 << h.first << " in map file \"" << fname_ << "\""
26 h.second += map_[h.first].second;
27 h.first = map_[h.first].first;
31 * Parse a reference-map file.
33 void ReferenceMap::parse() {
35 if(!in.good() || !in.is_open()) {
36 cerr << "Could not open reference map file " << fname_ << endl;
40 while((c = in.peek()) != EOF) {
42 // This appears to be a name line
43 in.get(); // chop off the initial '>'
46 in.get(); // chop off tab
48 in.getline(buf, 1023);
50 if(names_.size() <= off) names_.resize(off+1);
51 names_[off] = string(buf);
57 map_.resize(map_.size()+1);
58 map_.back().first = id;
59 map_.back().second = off;
60 while(isspace(in.peek())) in.get();