RadiantDB.hpp 1.16 KB
Newer Older
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef RADIANTDB_HPP
#define RADIANTDB_HPP

// standard header
#include <iostream>                     // for operator<<, cout, ostream, etc
#include <vector>                       // for vector
#include <unordered_map>

// Boost header
#include <boost/filesystem.hpp>

// BSDL header
13 14
#include "../libs/BioSeqDataLib/src/utility/Input.hpp"
#include "../libs/BioSeqDataLib/src/utility/Output.hpp"
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
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

#include "common.hpp"

namespace fs = boost::filesystem;




class RadiantDB
{
private:
	fs::path prefix_;
	std::unordered_map<PrefixType, std::vector<SuffixAcc> > database_;
	SuffixAcc noSuffix_;
	std::ifstream dbFile_;

	void
	write_(const fs::path &path, const std::unordered_map<PrefixType, std::map<CodedSuffix, unsigned short > > &database) const;

	void
	close_();

	short
	static char_diff_(SuffixType val1, SuffixType val2);

public:

	RadiantDB()
	{}

	RadiantDB(const fs::path &path)
	{
		read(path);
	}

	~RadiantDB()
	{
		dbFile_.close();
	}

	void
	read(const fs::path &path);


	/*void
	build(const fs::path &inPath, bool forward, const fs::path &outPath);
	*/


	short
	getDomID(const PrefixType &prefix, const CodedSuffix &suffix, bool &position) const;


};


#endif