bool ContextBase::determineOutputType() { if (_outputTypeDetermined) { return true; } //test whether output should be BED or BAM. //If the user explicitly requested BED, then it's BED. if (getExplicitBedOutput()) { setOutputFileType(FileRecordTypeChecker::SINGLE_LINE_DELIM_TEXT_FILE_TYPE); _outputTypeDetermined = true; return true; } //Otherwise, if the input is BAM, then the output is BAM int fileIdx = hasIntersectMethods() ? _queryFileIdx : 0; if (_files[fileIdx]->getFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) { setOutputFileType(FileRecordTypeChecker::BAM_FILE_TYPE); return true; } //Okay, it's bed. setOutputFileType(FileRecordTypeChecker::SINGLE_LINE_DELIM_TEXT_FILE_TYPE); _outputTypeDetermined = true; return true; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (_program != GROUP_BY && _files[0]->getRecordType() == FileRecordTypeChecker::NO_POS_PLUS_RECORD_TYPE) { _errorMsg = "ERROR: file "; _errorMsg.append(_files[0]->getFileName()); _errorMsg.append(" has non positional records, which are only valid for \n"); _errorMsg.append(" the groupBy tool. Perhaps you are using a header"); _errorMsg.append(" line(s) that starts with \n"); _errorMsg.append(" something other than \"#\", \"chrom\", or \"chr\" (any case)?"); return false; } if (getObeySplits()) { _splitBlockInfo = new BlockMgr(_overlapFractionA, _reciprocalFraction); } if (hasColumnOpsMethods()) { if (hasIntersectMethods()) { for (int i=0; i < (int)_dbFileIdxs.size(); i++) { FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } } else { FileRecordMgr *dbFile = getFile(0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } //if user specified a precision, pass it to //keyList ops if (_reportPrecision != -1) { _keyListOps->setPrecision(_reportPrecision); } } return true; }
int ContextBase::getBamHeaderAndRefIdx() { if (_bamHeaderAndRefIdx != -1) { //already found which BAM file to use for the header return _bamHeaderAndRefIdx; } if (hasIntersectMethods()) { if (_files[_queryFileIdx]->getFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) { _bamHeaderAndRefIdx = _queryFileIdx; } else { _bamHeaderAndRefIdx = _dbFileIdxs[0]; } return _bamHeaderAndRefIdx; } if (_files[0]->getFileType() == FileRecordTypeChecker::BAM_FILE_TYPE) { _bamHeaderAndRefIdx = 0; return _bamHeaderAndRefIdx; } return _bamHeaderAndRefIdx; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (hasColumnOpsMethods()) { FileRecordMgr *dbFile = getFile(hasIntersectMethods() ? _databaseFileIdx : 0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } return true; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (getObeySplits()) { _splitBlockInfo = new BlockMgr(_overlapFraction, _reciprocal); } if (hasColumnOpsMethods()) { if (hasIntersectMethods()) { for (int i=0; i < (int)_dbFileIdxs.size(); i++) { FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } } else { FileRecordMgr *dbFile = getFile(0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } //if user specified a precision, pass it to //keyList ops if (_reportPrecision != -1) { _keyListOps->setPrecision(_reportPrecision); } } return true; }