File: FileRecordMergeMgr.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 (58 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download | duplicates (4)
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
/*
 * FileRecordMergeMgr.h
 *
 *  Created on: Mar 19, 2014
 *      Author: nek3d
 */

#ifndef FILERECORDMERGEMGR_H_
#define FILERECORDMERGEMGR_H_

#include "FileRecordMgr.h"
#include "StrandQueue.h"

class FileRecordMergeMgr : public FileRecordMgr {

public:
	FileRecordMergeMgr(const string & filename);

	//////////////////////////////////////////////////////////////////////////////////
	//
	// 			MERGED RECORDS
	//
	// This will give a single "meta" record containing "flattened" or merged records.
	//
	// Pass an empty RecordKeyVector. When done, will have a pair: 1st is the final merged record,
	//			second is list of constituent Records merged.
	//
	///////////////////////////////////////////////////////////////////////////////////

	Record *getNextRecord(RecordKeyVector *keyList = NULL);
	void deleteMergedRecord(RecordKeyVector &recList); // MUST use this method for cleanup!

	bool eof();


	typedef enum { SAME_STRAND_FORWARD, //must all be forward strand
			SAME_STRAND_REVERSE, //must all be reverse strand
			SAME_STRAND_EITHER, //must be same strand, but can be either forward or reverse
			ANY_STRAND } //do no care about strand (Default value)
	WANTED_STRAND_TYPE;

	void setStrandType(WANTED_STRAND_TYPE strand) { _desiredStrand = strand; }
	void setMaxDistance(int maxDistance) { _maxDistance = maxDistance; }

private:

	WANTED_STRAND_TYPE _desiredStrand;
	int _maxDistance;
	StrandQueue _storedRecords;

	void deleteAllMergedItemsButKey(RecordKeyVector &recList);
	void addToStorage(Record *record);
	Record *tryToTakeFromStorage();
	Record *tryToTakeFromStorage(Record::strandType strand);
};


#endif /* FILERECORDMERGEMGR_H_ */