BedPlusInterval.h 1.93 KB
Newer Older
nkindlon's avatar
nkindlon committed
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
/*
 * BedPlusInterval.h
 *
 *  Created on: Nov 13, 2012
 *      Author: nek3d
 */

#ifndef BEDPLUSINTERVAL_H_
#define BEDPLUSINTERVAL_H_

#include "Bed6Interval.h"
#include <vector>

class SingleLineDelimTextFileReader;

class BedPlusInterval : public Bed6Interval {
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
46
47
48
49
50
51
52
53
54
55
56

protected:
	virtual ~BedPlusInterval();
	bool initOtherFieldsFromFile(SingleLineDelimTextFileReader *fileReader);


	vector<QuickString *> _otherIdxs;
	static const int startOtherIdx = 6; //first six fields have names, and are not stored in otherIdxs.
	int _numPrintFields;
};



#endif /* BEDPLUSINTERVAL_H_ */