Skip to content
Snippets Groups Projects
Commit 1a0737df authored by Aaron Quinlan's avatar Aaron Quinlan
Browse files

Merge pull request #41 from nkindlon/master

Refactored KeyListOps, Context, mapFile to make KeyListOps reusable by other tools
parents 4793c986 af1113e7
No related branches found
No related tags found
No related merge requests found
Showing
with 231 additions and 330 deletions
...@@ -17,6 +17,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \ ...@@ -17,6 +17,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \
-I$(UTILITIES_DIR)/FileRecordTools/ \ -I$(UTILITIES_DIR)/FileRecordTools/ \
-I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \ -I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \
-I$(UTILITIES_DIR)/FileRecordTools/Records/ \ -I$(UTILITIES_DIR)/FileRecordTools/Records/ \
-I$(UTILITIES_DIR)/KeyListOps/ \
-I$(UTILITIES_DIR)/RecordOutputMgr/ \ -I$(UTILITIES_DIR)/RecordOutputMgr/ \
-I$(UTILITIES_DIR)/NewChromsweep \ -I$(UTILITIES_DIR)/NewChromsweep \
-I$(UTILITIES_DIR)/BinTree \ -I$(UTILITIES_DIR)/BinTree \
......
...@@ -21,14 +21,11 @@ const int PRECISION = 21; ...@@ -21,14 +21,11 @@ const int PRECISION = 21;
FileMap::FileMap(ContextMap *context) FileMap::FileMap(ContextMap *context)
: _context(context), : _context(context),
_blockMgr(NULL), _blockMgr(NULL),
_recordOutputMgr(NULL), _recordOutputMgr(NULL)
_colOps(_context->getColOps())
{ {
_blockMgr = new BlockMgr(_context->getOverlapFraction(), _context->getReciprocal()); _blockMgr = new BlockMgr(_context->getOverlapFraction(), _context->getReciprocal());
_recordOutputMgr = new RecordOutputMgr(); _recordOutputMgr = new RecordOutputMgr();
_recordOutputMgr->init(_context); _recordOutputMgr->init(_context);
_keyListOps.setNullValue(_context->getNullValue());
_keyListOps.setDelimStr(_context->getDelim());
} }
FileMap::~FileMap(void) { FileMap::~FileMap(void) {
...@@ -46,174 +43,15 @@ bool FileMap::mapFiles() ...@@ -46,174 +43,15 @@ bool FileMap::mapFiles()
} }
RecordKeyList hitSet; RecordKeyList hitSet;
while (sweep.next(hitSet)) { while (sweep.next(hitSet)) {
_outputValues.clear();
if (_context->getObeySplits()) { if (_context->getObeySplits()) {
RecordKeyList keySet(hitSet.getKey()); RecordKeyList keySet(hitSet.getKey());
RecordKeyList resultSet(hitSet.getKey()); RecordKeyList resultSet(hitSet.getKey());
_blockMgr->findBlockedOverlaps(keySet, hitSet, resultSet); _blockMgr->findBlockedOverlaps(keySet, hitSet, resultSet);
calculateOutput(resultSet); _recordOutputMgr->printRecord(resultSet.getKey(), _context->getColumnOpsVal(resultSet));
_recordOutputMgr->printRecord(resultSet.getKey(), _outputValues);
} else { } else {
calculateOutput(hitSet); _recordOutputMgr->printRecord(hitSet.getKey(), _context->getColumnOpsVal(hitSet));
_recordOutputMgr->printRecord(hitSet.getKey(), _outputValues);
} }
} }
return true; return true;
} }
void FileMap::calculateOutput(RecordKeyList &hits)
{
//loop through all requested columns, and for each one, call the method needed
//for the operation specified.
_keyListOps.setKeyList(&hits);
double val = 0.0;
for (int i=0; i < (int)_colOps.size(); i++) {
int col = _colOps[i].first;
KeyListOps::OP_TYPES opCode = _colOps[i].second;
_keyListOps.setColumn(col);
switch (opCode) {
case KeyListOps::SUM:
val = _keyListOps.getSum();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::MEAN:
val = _keyListOps.getMean();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::STDDEV:
val = _keyListOps.getStddev();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::SAMPLE_STDDEV:
val = _keyListOps.getSampleStddev();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::MEDIAN:
val = _keyListOps.getMedian();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::MODE:
_outputValues.append(_keyListOps.getMode());
break;
case KeyListOps::ANTIMODE:
_outputValues.append(_keyListOps.getAntiMode());
break;
case KeyListOps::MIN:
val = _keyListOps.getMin();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::MAX:
val = _keyListOps.getMax();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::ABSMIN:
val = _keyListOps.getAbsMin();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::ABSMAX:
val = _keyListOps.getAbsMax();
if (isnan(val)) {
_outputValues.append(_context->getNullValue());
} else {
_outputValues.append(val);
}
break;
case KeyListOps::COUNT:
_outputValues.append(_keyListOps.getCount());
break;
case KeyListOps::DISTINCT:
_outputValues.append(_keyListOps.getDistinct());
break;
case KeyListOps::COUNT_DISTINCT:
_outputValues.append(_keyListOps.getCountDistinct());
break;
case KeyListOps::DISTINCT_ONLY:
_outputValues.append(_keyListOps.getDistinctOnly());
break;
case KeyListOps::COLLAPSE:
_outputValues.append(_keyListOps.getCollapse());
break;
case KeyListOps::CONCAT:
_outputValues.append(_keyListOps.getConcat());
break;
case KeyListOps::FREQ_ASC:
_outputValues.append(_keyListOps.getFreqAsc());
break;
case KeyListOps::FREQ_DESC:
_outputValues.append(_keyListOps.getFreqDesc());
break;
case KeyListOps::FIRST:
_outputValues.append(_keyListOps.getFirst());
break;
case KeyListOps::LAST:
_outputValues.append(_keyListOps.getLast());
break;
case KeyListOps::INVALID:
default:
// Any unrecognized operation should have been handled already in the context validation.
// It's thus unnecessary to handle it here, but throw an error to help us know if future
// refactoring or code changes accidentally bypass the validation phase.
cerr << "ERROR: Invalid operation given for column " << col << ". Exiting..." << endl;
break;
}
//if this isn't the last column, add a tab.
if (i < (int)_colOps.size() -1) {
_outputValues.append('\t');
}
}
}
...@@ -38,11 +38,6 @@ private: ...@@ -38,11 +38,6 @@ private:
ContextMap *_context; ContextMap *_context;
BlockMgr *_blockMgr; BlockMgr *_blockMgr;
RecordOutputMgr *_recordOutputMgr; RecordOutputMgr *_recordOutputMgr;
KeyListOps _keyListOps;
const ContextMap::colOpsType & _colOps;
QuickString _outputValues; // placeholder for the results of mapping B to each a in A.
void calculateOutput(RecordKeyList &hits);
}; };
#endif /* MAPFILE_H */ #endif /* MAPFILE_H */
...@@ -10,6 +10,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \ ...@@ -10,6 +10,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \
-I$(UTILITIES_DIR)/FileRecordTools/ \ -I$(UTILITIES_DIR)/FileRecordTools/ \
-I$(UTILITIES_DIR)/FileRecordTools/FileReaders \ -I$(UTILITIES_DIR)/FileRecordTools/FileReaders \
-I$(UTILITIES_DIR)/FileRecordTools/Records \ -I$(UTILITIES_DIR)/FileRecordTools/Records \
-I$(UTILITIES_DIR)/KeyListOps/ \
-I$(UTILITIES_DIR)/general \ -I$(UTILITIES_DIR)/general \
-I$(UTILITIES_DIR)/NewChromsweep \ -I$(UTILITIES_DIR)/NewChromsweep \
-I$(UTILITIES_DIR)/GenomeFile/ \ -I$(UTILITIES_DIR)/GenomeFile/ \
......
...@@ -18,6 +18,7 @@ INCLUDES = -I$(UTILITIES_DIR)/bedFile/ \ ...@@ -18,6 +18,7 @@ INCLUDES = -I$(UTILITIES_DIR)/bedFile/ \
-I$(UTILITIES_DIR)/FileRecordTools/ \ -I$(UTILITIES_DIR)/FileRecordTools/ \
-I$(UTILITIES_DIR)/FileRecordTools/FileReaders \ -I$(UTILITIES_DIR)/FileRecordTools/FileReaders \
-I$(UTILITIES_DIR)/FileRecordTools/Records \ -I$(UTILITIES_DIR)/FileRecordTools/Records \
-I$(UTILITIES_DIR)/KeyListOps/ \
-I$(UTILITIES_DIR)/general -I$(UTILITIES_DIR)/general
# ---------------------------------- # ----------------------------------
......
...@@ -17,6 +17,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \ ...@@ -17,6 +17,7 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \
-I$(UTILITIES_DIR)/FileRecordTools/ \ -I$(UTILITIES_DIR)/FileRecordTools/ \
-I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \ -I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \
-I$(UTILITIES_DIR)/FileRecordTools/Records/ \ -I$(UTILITIES_DIR)/FileRecordTools/Records/ \
-I$(UTILITIES_DIR)/KeyListOps/ \
-I$(UTILITIES_DIR)/RecordOutputMgr/ \ -I$(UTILITIES_DIR)/RecordOutputMgr/ \
-I$(UTILITIES_DIR)/version/ -I$(UTILITIES_DIR)/version/
......
...@@ -11,6 +11,7 @@ INCLUDES = -I$(UTILITIES_DIR)/general/ \ ...@@ -11,6 +11,7 @@ INCLUDES = -I$(UTILITIES_DIR)/general/ \
-I$(UTILITIES_DIR)/FileRecordTools/ \ -I$(UTILITIES_DIR)/FileRecordTools/ \
-I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \ -I$(UTILITIES_DIR)/FileRecordTools/FileReaders/ \
-I$(UTILITIES_DIR)/FileRecordTools/Records/ \ -I$(UTILITIES_DIR)/FileRecordTools/Records/ \
-I$(UTILITIES_DIR)/KeyListOps/ \
-I$(UTILITIES_DIR)/BamTools/include \ -I$(UTILITIES_DIR)/BamTools/include \
-I$(UTILITIES_DIR)/BamTools/src/ \ -I$(UTILITIES_DIR)/BamTools/src/ \
-I$(UTILITIES_DIR)/version/ -I$(UTILITIES_DIR)/version/
......
...@@ -52,11 +52,16 @@ ContextBase::ContextBase() ...@@ -52,11 +52,16 @@ ContextBase::ContextBase()
_hasConstantSeed(false), _hasConstantSeed(false),
_seed(0), _seed(0),
_forwardOnly(false), _forwardOnly(false),
_reverseOnly(false) _reverseOnly(false),
_hasColumnOpsMethods(false)
{ {
_programNames["intersect"] = INTERSECT; _programNames["intersect"] = INTERSECT;
_programNames["sample"] = SAMPLE; _programNames["sample"] = SAMPLE;
_programNames["map"] = MAP; _programNames["map"] = MAP;
if (hasColumnOpsMethods()) {
_keyListOps = new KeyListOps();
}
} }
ContextBase::~ContextBase() ContextBase::~ContextBase()
...@@ -70,6 +75,11 @@ ContextBase::~ContextBase() ...@@ -70,6 +75,11 @@ ContextBase::~ContextBase()
delete _files[i]; delete _files[i];
_files[i] = NULL; _files[i] = NULL;
} }
if (hasColumnOpsMethods()) {
delete _keyListOps;
_keyListOps = NULL;
}
} }
bool ContextBase::determineOutputType() { bool ContextBase::determineOutputType() {
...@@ -167,6 +177,19 @@ bool ContextBase::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { ...@@ -167,6 +177,19 @@ bool ContextBase::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
else if (strcmp(_argv[_i], "-seed") == 0) { else if (strcmp(_argv[_i], "-seed") == 0) {
if (!handle_seed()) return false; if (!handle_seed()) return false;
} }
else if (strcmp(_argv[_i], "-o") == 0) {
if (!handle_o()) return false;
}
else if (strcmp(_argv[_i], "-c") == 0) {
if (!handle_c()) return false;
}
else if (strcmp(_argv[_i], "-null") == 0) {
if (!handle_null()) return false;
}
else if (strcmp(_argv[_i], "-delim") == 0) {
if (!handle_delim()) return false;
}
} }
return true; return true;
} }
...@@ -182,6 +205,12 @@ bool ContextBase::isValidState() ...@@ -182,6 +205,12 @@ bool ContextBase::isValidState()
if (!determineOutputType()) { if (!determineOutputType()) {
return false; return false;
} }
if (hasColumnOpsMethods()) {
FileRecordMgr *dbFile = getFile(hasIntersectMethods() ? _databaseFileIdx : 0);
if (!_keyListOps->isValidColumnOps(dbFile)) {
return false;
}
}
return true; return true;
} }
...@@ -354,3 +383,85 @@ bool ContextBase::handle_ubam() ...@@ -354,3 +383,85 @@ bool ContextBase::handle_ubam()
markUsed(_i - _skipFirstArgs); markUsed(_i - _skipFirstArgs);
return true; return true;
} }
// Methods specific to column operations.
// for col ops, -c is the string of columns upon which to operate
bool ContextBase::handle_c()
{
if (!hasColumnOpsMethods()) {
return false;
}
if ((_i+1) < _argc) {
_keyListOps->setColumns(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
// for col ops, -o is the string of operations to apply to the columns (-c)
bool ContextBase::handle_o()
{
if (!hasColumnOpsMethods()) {
return false;
}
if ((_i+1) < _argc) {
_keyListOps->setOperations(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
// for col ops, -null is a NULL vakue assigned
// when no overlaps are detected.
bool ContextBase::handle_null()
{
if (!hasColumnOpsMethods()) {
return false;
}
if ((_i+1) < _argc) {
_keyListOps->setNullValue(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
//for col ops, delimStr will appear between each item in
//a collapsed but delimited list.
bool ContextBase::handle_delim()
{
if (!hasColumnOpsMethods()) {
return false;
}
if ((_i+1) < _argc) {
_keyListOps->setDelimStr(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
void ContextBase::setColumnOpsMethods(bool val)
{
_hasColumnOpsMethods = val;
if (val) {
_keyListOps = new KeyListOps();
}
}
const QuickString &ContextBase::getColumnOpsVal(RecordKeyList &keyList) const {
if (!hasColumnOpsMethods()) {
return _nullStr;
}
return _keyListOps->getOpVals(keyList);
}
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "NewGenomeFile.h" #include "NewGenomeFile.h"
#include "api/BamReader.h" #include "api/BamReader.h"
#include "api/BamAux.h" #include "api/BamAux.h"
#include "KeyListOps.h"
class ContextBase { class ContextBase {
...@@ -144,6 +145,13 @@ public: ...@@ -144,6 +145,13 @@ public:
//methods. //methods.
virtual bool hasIntersectMethods() const { return false; } virtual bool hasIntersectMethods() const { return false; }
// determine whether column operations like those used in map
// are available.
void setColumnOpsMethods(bool val);
virtual bool hasColumnOpsMethods() const { return _hasColumnOpsMethods; }
const QuickString &getColumnOpsVal(RecordKeyList &keyList) const;
//methods applicable only to column operations.
protected: protected:
PROGRAM_TYPE _program; PROGRAM_TYPE _program;
...@@ -204,6 +212,10 @@ protected: ...@@ -204,6 +212,10 @@ protected:
bool _forwardOnly; bool _forwardOnly;
bool _reverseOnly; bool _reverseOnly;
bool _hasColumnOpsMethods;
KeyListOps *_keyListOps;
QuickString _nullStr; //placeholder return value when col ops aren't valid.
void markUsed(int i) { _argsProcessed[i] = true; } void markUsed(int i) { _argsProcessed[i] = true; }
bool isUsed(int i) const { return _argsProcessed[i]; } bool isUsed(int i) const { return _argsProcessed[i]; }
bool cmdArgsValid(); bool cmdArgsValid();
...@@ -227,6 +239,11 @@ protected: ...@@ -227,6 +239,11 @@ protected:
virtual bool handle_split(); virtual bool handle_split();
virtual bool handle_sorted(); virtual bool handle_sorted();
virtual bool handle_ubam(); virtual bool handle_ubam();
virtual bool handle_c();
virtual bool handle_o();
virtual bool handle_null();
virtual bool handle_delim();
}; };
#endif /* CONTEXTBASE_H_ */ #endif /* CONTEXTBASE_H_ */
...@@ -8,18 +8,11 @@ ...@@ -8,18 +8,11 @@
#include "ContextMap.h" #include "ContextMap.h"
ContextMap::ContextMap() ContextMap::ContextMap()
: _delimStr(",")
{ {
// map requires sorted input // map requires sorted input
setSortedInput(true); setSortedInput(true);
setLeftJoin(true); setLeftJoin(true);
setColumnOpsMethods(true);
// default to BED score column
setColumns("5");
// default to "sum"
setOperations("sum");
// default to "." as a NULL value
setNullValue('.');
} }
ContextMap::~ContextMap() ContextMap::~ContextMap()
...@@ -45,131 +38,22 @@ bool ContextMap::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { ...@@ -45,131 +38,22 @@ bool ContextMap::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
if (isUsed(_i - _skipFirstArgs)) { if (isUsed(_i - _skipFirstArgs)) {
continue; continue;
} }
else if (strcmp(_argv[_i], "-o") == 0) { if (strcmp(_argv[_i], "-c") == 0) {
if (!handle_o()) return false; //bypass intersect's use of the -c option, because -c
} //means writeCount for intersect, but means columns for map.
else if (strcmp(_argv[_i], "-c") == 0) { if (!ContextBase::handle_c()) return false;
if (!handle_c()) return false; }
}
else if (strcmp(_argv[_i], "-null") == 0) {
if (!handle_null()) return false;
}
else if (strcmp(_argv[_i], "-delim") == 0) {
if (!handle_delim()) return false;
}
} }
return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs); return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
} }
//
//
bool ContextMap::isValidState() //bool ContextMap::isValidState()
{ //{
if (!ContextIntersect::isValidState()) { // if (!ContextIntersect::isValidState()) {
return false; // return false;
} // }
//}
if (getDatabaseFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) { //
//throw Error //
cerr << endl << "*****" << endl
<< "***** ERROR: BAM database file not currently supported for the map tool."
<< endl;
exit(1);
}
//get the strings from context containing the comma-delimited lists of columns
//and operations. Split both of these into vectors. Get the operation code
//for each operation string. Finally, make a vector of pairs, where the first
//member of each pair is a column number, and the second member is the code for the
//operation to perform on that column.
vector<QuickString> columnsVec;
vector<QuickString> opsVec;
int numCols = Tokenize(_columns, columnsVec, ',');
int numOps = Tokenize(_operations, opsVec, ',');
if (numOps < 1 || numCols < 1) {
cerr << endl << "*****" << endl
<< "***** ERROR: There must be at least one column and at least one operation named." << endl;
return false;
}
if (numOps > 1 && numCols != numOps) {
cerr << endl << "*****" << endl
<< "***** ERROR: There are " << numCols <<" columns given, but there are " << numOps << " operations. " << endl;
cerr << "\tPlease provide either a single operation that will be applied to all listed columns, " << endl;
cerr << "\tor an operation for each column." << endl;
return false;
}
KeyListOps keyListOps;
for (int i=0; i < (int)columnsVec.size(); i++) {
int col = str2chrPos(columnsVec[i]);
//check that the column number is valid
if (col < 1 || col > getDatabaseFile()->getNumFields()) {
cerr << endl << "*****" << endl << "***** ERROR: Requested column " << col << ", but database file "
<< getDatabaseFileName() << " only has fields 1 - " << getDatabaseFile()->getNumFields() << "." << endl;
return false;
}
const QuickString &operation = opsVec.size() > 1 ? opsVec[i] : opsVec[0];
KeyListOps::OP_TYPES opCode = keyListOps.getOpCode(operation);
if (opCode == KeyListOps::INVALID) {
cerr << endl << "*****" << endl
<< "***** ERROR: " << operation << " is not a valid operation. " << endl;
return false;
}
_colOps.push_back(pair<int, KeyListOps::OP_TYPES>(col, opCode));
}
return true;
}
// for map, -c is the string of columns upon which to operate
bool ContextMap::handle_c()
{
if ((_i+1) < _argc) {
setColumns(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
// for map, -o is the string of operations to apply to the columns (-c)
bool ContextMap::handle_o()
{
if ((_i+1) < _argc) {
setOperations(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
// for map, -null is a NULL vakue assigned
// when no overlaps are detected.
bool ContextMap::handle_null()
{
if ((_i+1) < _argc) {
setNullValue(_argv[_i + 1]);
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
bool ContextMap::handle_delim()
{
if ((_i+1) < _argc) {
_delimStr = _argv[_i + 1];
markUsed(_i - _skipFirstArgs);
_i++;
markUsed(_i - _skipFirstArgs);
}
return true;
}
...@@ -15,37 +15,14 @@ class ContextMap : public ContextIntersect { ...@@ -15,37 +15,14 @@ class ContextMap : public ContextIntersect {
public: public:
ContextMap(); ContextMap();
virtual ~ContextMap(); virtual ~ContextMap();
virtual bool isValidState(); // virtual bool isValidState();
//
virtual bool parseCmdArgs(int argc, char **argv, int skipFirstArgs); virtual bool parseCmdArgs(int argc, char **argv, int skipFirstArgs);
//
const QuickString &getColumns() const { return _columns; }
void setColumns(const QuickString &columns) { _columns = columns; }
const QuickString & getOperations() const { return _operations; }
void setOperations(const QuickString & operation) { _operations = operation; }
const QuickString & getNullValue() const { return _nullValue; }
void setNullValue(const QuickString & nullValue) { _nullValue = nullValue; }
const QuickString &getDelim() const { return _delimStr; }
virtual bool hasIntersectMethods() const { return true; } virtual bool hasIntersectMethods() const { return true; }
//
typedef vector<pair<int, KeyListOps::OP_TYPES> > colOpsType;
const colOpsType &getColOps() const { return _colOps; }
private: private:
QuickString _operations;
QuickString _columns;
QuickString _nullValue;
KeyListOps _keyListOps;
colOpsType _colOps;
QuickString _delimStr;
virtual bool handle_c();
virtual bool handle_o();
virtual bool handle_null();
virtual bool handle_delim();
}; };
......
...@@ -172,5 +172,10 @@ const QuickString &BamRecord::getField(int fieldNum) const ...@@ -172,5 +172,10 @@ const QuickString &BamRecord::getField(int fieldNum) const
return Bed6Interval::getField(fieldNum); return Bed6Interval::getField(fieldNum);
} }
bool BamRecord::isNumericField(int fieldNum) {
//TBD: As with getField, this isn't defined for BAM.
return (fieldNum > 6 ? false : Bed6Interval::isNumericField(fieldNum));
}
...@@ -40,6 +40,7 @@ public: ...@@ -40,6 +40,7 @@ public:
virtual const QuickString &getField(int fieldNum) const; virtual const QuickString &getField(int fieldNum) const;
virtual int getNumFields() const { return 12; } virtual int getNumFields() const { return 12; }
static bool isNumericField(int fieldNum);
protected: protected:
BamTools::BamAlignment _bamAlignment; BamTools::BamAlignment _bamAlignment;
......
...@@ -146,3 +146,29 @@ const QuickString &Bed12Interval::getField(int fieldNum) const ...@@ -146,3 +146,29 @@ const QuickString &Bed12Interval::getField(int fieldNum) const
} }
} }
bool Bed12Interval::isNumericField(int fieldNum) {
switch (fieldNum) {
case 7:
return true;
break;
case 8:
return true;
break;
case 9:
return false;
break;
case 10:
return true;
break;
case 11:
return false;
break;
case 12:
return false;
break;
default:
return Bed6Interval::isNumericField(fieldNum);
break;
}
}
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
virtual const QuickString &getField(int fieldNum) const; virtual const QuickString &getField(int fieldNum) const;
virtual int getNumFields() const { return 12; } virtual int getNumFields() const { return 12; }
static bool isNumericField(int fieldNum);
protected: protected:
......
...@@ -79,3 +79,23 @@ const QuickString &Bed3Interval::getField(int fieldNum) const ...@@ -79,3 +79,23 @@ const QuickString &Bed3Interval::getField(int fieldNum) const
break; break;
} }
} }
bool Bed3Interval::isNumericField(int fieldNum) {
switch (fieldNum) {
case 1:
return false; //chrom
break;
case 2:
return true; //startPos
break;
case 3:
return true; //endPos
break;
default:
cerr << endl << "*****" << endl
<< "*****ERROR: requested invalid column " << fieldNum << ". Exiting." << endl
<< endl << "*****" << endl;
exit(1);
break;
}
}
...@@ -32,6 +32,8 @@ public: ...@@ -32,6 +32,8 @@ public:
virtual const QuickString &getField(int fieldNum) const; virtual const QuickString &getField(int fieldNum) const;
virtual int getNumFields() const { return 3; } virtual int getNumFields() const { return 3; }
static bool isNumericField(int fieldNum);
protected: protected:
virtual ~Bed3Interval(); virtual ~Bed3Interval();
......
...@@ -60,3 +60,8 @@ const QuickString &Bed4Interval::getField(int fieldNum) const ...@@ -60,3 +60,8 @@ const QuickString &Bed4Interval::getField(int fieldNum) const
} }
} }
bool Bed4Interval::isNumericField(int fieldNum) {
return (fieldNum == 4 ? false : Bed3Interval::isNumericField(fieldNum));
}
...@@ -28,6 +28,7 @@ public: ...@@ -28,6 +28,7 @@ public:
virtual const QuickString &getField(int fieldNum) const; virtual const QuickString &getField(int fieldNum) const;
virtual int getNumFields() const { return 4; } virtual int getNumFields() const { return 4; }
static bool isNumericField(int fieldNum);
protected: protected:
......
...@@ -70,3 +70,16 @@ const QuickString &Bed5Interval::getField(int fieldNum) const ...@@ -70,3 +70,16 @@ const QuickString &Bed5Interval::getField(int fieldNum) const
break; break;
} }
} }
bool Bed5Interval::isNumericField(int fieldNum) {
switch (fieldNum) {
case 4:
return false;
break;
case 5:
return true;
break;
default:
return Bed3Interval::isNumericField(fieldNum);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment