BedPlusInterval.h 1.99 KB
Newer Older
nkindlon's avatar
nkindlon committed
1
2
3
4
5
6
7
8
9
10
/*
 * BedPlusInterval.h
 *
 *  Created on: Nov 13, 2012
 *      Author: nek3d
 */

#ifndef BEDPLUSINTERVAL_H_
#define BEDPLUSINTERVAL_H_

11
#include "Bed3Interval.h"
nkindlon's avatar
nkindlon committed
12
13
14
15
#include <vector>

class SingleLineDelimTextFileReader;

16
class BedPlusInterval : public Bed3Interval {
nkindlon's avatar
nkindlon committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public:
	friend class FreeList<BedPlusInterval>;

	BedPlusInterval();
	virtual bool initFromFile(SingleLineDelimTextFileReader *);
	virtual void clear();
	virtual void print(QuickString &outBuf) const;
	virtual void print(QuickString &outBuf, int start, int end) const;
	virtual void print(QuickString &outBuf, const QuickString & start, const QuickString & end) const;
	virtual void printNull(QuickString &outBuf) const;
	virtual FileRecordTypeChecker::RECORD_TYPE getType() const { return FileRecordTypeChecker::BED_PLUS_RECORD_TYPE; }

	//Note: using the assignment operator in a BedPlusInterval can potentially be a performance hit,
	//if the number of fields frequently differ between this object and the one being copied.
	const BedPlusInterval &operator=(const BedPlusInterval &other);

33
34
35
	virtual const QuickString &getField(int fieldNum) const;
	virtual int getNumFields() const  { return startOtherIdx + _otherIdxs.size(); }

nkindlon's avatar
nkindlon committed
36
37
38
39
40
	virtual void setField(int fieldNum, const QuickString &str) { (*(_otherIdxs[fieldNum])) = str; }
	virtual void setField(int fieldNum, const string &str) { (*(_otherIdxs[fieldNum])) = str; }
	virtual void setField(int fieldNum, const char *str) { (*(_otherIdxs[fieldNum])) = str; }
	virtual void setNumPrintFields(int num) { _numPrintFields = num; }
	virtual int getNumPrintFields() const { return _numPrintFields; }
41
42
	static bool isNumericField(int fieldNum);

nkindlon's avatar
nkindlon committed
43
44
45

protected:
	vector<QuickString *> _otherIdxs;
46
	static const int startOtherIdx = 3; //first six fields have names, and are not stored in otherIdxs.
nkindlon's avatar
nkindlon committed
47
	int _numPrintFields;
48
49
50
51

	virtual ~BedPlusInterval();
	bool initOtherFieldsFromFile(SingleLineDelimTextFileReader *fileReader);
	virtual void printOtherFields(QuickString &outBuf) const;
nkindlon's avatar
nkindlon committed
52
53
54
55
56
};



#endif /* BEDPLUSINTERVAL_H_ */