File: BinTree.h

package info (click to toggle)
bedtools 2.27.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 54,804 kB
  • sloc: cpp: 38,072; sh: 7,307; makefile: 2,241; python: 163
file content (78 lines) | stat: -rw-r--r-- 1,933 bytes parent folder | download | duplicates (2)
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
/*
 * BinTree.h
 *
 *  Created on: Jan 5, 2013
 *      Author: nek3d
 */

#ifndef BINTREE_H_
#define BINTREE_H_

#include <stdint.h>
#include <string>
#include <set>
#include <map>

#include "string.h"
#include "RecordKeyList.h"
#include "ContextIntersect.h"

using namespace std;

class FileRecordMgr;
class Record;

class BinTree {
public:
	BinTree(ContextIntersect *context);

	~BinTree();
	void loadDB();
	void getHits(Record *record, RecordKeyVector &hitSet);

private:

	ContextIntersect *_context;

    //
    // BIN HANDLING
    //
	typedef int32_t binNumType;
	static const binNumType NUM_BINS = 37450;
	static const binNumType NUM_BIN_LEVELS = 7;

	// bins range in size from 16kb to 512Mb
	// Bin  0          spans 512Mbp,   # Level 1
	// Bins 1-8        span 64Mbp,     # Level 2
	// Bins 9-72       span 8Mbp,      # Level 3
	// Bins 73-584     span 1Mbp       # Level 4
	// Bins 585-4680   span 128Kbp     # Level 5
	// Bins 4681-37449 span 16Kbp      # Level 6
	binNumType *_binOffsetsExtended;
	static const binNumType _binFirstShift = 14;       /* How much to shift to get to finest bin. */
	static const binNumType _binNextShift  = 3;        /* How much to shift to get to next larger bin. */

//	typedef RecordList innerListType;
//	typedef const RecordListNode * innerListIterType;
//	typedef innerListType * binType;
//	typedef binType * allBinsType;
//	typedef string mainKeyType;
//	typedef map<mainKeyType, allBinsType> mainMapType;
//	mainMapType _mainMap;

	typedef vector<Record *> binType;
	typedef map<binNumType, binType> allBinsType; //for each bin number, have a RecordList
	typedef map<string, allBinsType> mainMapType; //for each chrom, a map of bin num to RecordLists.
	mainMapType _mainMap;

	map<binNumType, int> _binsHit;

	bool addRecordToTree(Record *);
	binNumType getBin(binNumType start, binNumType end) const;
	binNumType getBin(const Record *record) const;


};


#endif /* BINTREE_H_ */