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
|
/*
* refmap.h
*
* Created on: Aug 3, 2009
* Author: Ben Langmead
*/
#ifndef REFMAP_H_
#define REFMAP_H_
#include <stdint.h>
#include <cassert>
#include <vector>
#include <iostream>
#include <fstream>
#include "btypes.h"
class ReferenceMap {
typedef std::pair<TIndexOffU, TIndexOffU> UPair;
public:
ReferenceMap(const char *fname, bool parseNames) {
fname_ = fname;
parseNames_ = parseNames;
parse();
}
/**
* Give a reference coordinate in the index, translate it into a
* new reference coordinate via the reference map supplied by the
* user.
*/
void map(UPair& h) const;
/**
* Return true iff we have a name for reference with id 'i'.
*/
bool hasName(size_t i) const {
if(!parseNames_) return false;
return !names_[i].empty();
}
/**
* Get the name for reference with id 'i'.
*/
const std::string& getName(size_t i) const {
assert(parseNames_);
assert(hasName(i));
return names_[i];
}
protected:
/**
* Parse a reference-map file.
*/
void parse();
const char *fname_;
std::vector<UPair> map_;
bool parseNames_;
std::vector<std::string> names_;
};
#endif /* REFMAP_H_ */
|