예제 #1
0
bool RecordOutputMgr::printKeyAndTerminate(RecordKeyVector &keyList) {
	if (_context->getProgram() == ContextBase::MERGE) {
		//when printing merged records, we want to force the printing into
		//bed3 format, which is surprisingly difficult to do. Had to use the following:
		const Bed3Interval *bed3 = static_cast<const Bed3Interval *>(keyList.getKey());
		bed3->Bed3Interval::print(_outBuf);

		//in addition, if we're doing stranded merges, we need to print the strand sign.
		if (_context->getDesiredStrand() != FileRecordMergeMgr::ANY_STRAND) {
			_outBuf.append("\t");
			_outBuf.append(keyList.getKey()->getStrand());
		}
		return false;
	}
	printBamType bamCode = printBamRecord(keyList);
	if (bamCode == BAM_AS_BAM) {
		return true;
	} else if (bamCode == NOT_BAM) {
		keyList.getKey()->print(_outBuf);
		return false;
	}
	//otherwise, it was BAM_AS_BED, and the key was printed.
	return false;

}
예제 #2
0
bool RecordOutputMgr::printKeyAndTerminate(RecordKeyVector &keyList) {
    if (_context->getProgram() == ContextBase::MERGE) {
        //when printing merged records, we want to force the printing into
        //bed3 format, which is surprisingly difficult to do. Had to use the following:
        const Bed3Interval *bed3 = static_cast<const Bed3Interval *>(keyList.getKey());
        bed3->Bed3Interval::print(_outBuf);
        return false;
    }
    printBamType bamCode = printBamRecord(keyList);
    if (bamCode == BAM_AS_BAM) {
        return true;
    } else if (bamCode == NOT_BAM) {
        keyList.getKey()->print(_outBuf);
        return false;
    }
    //otherwise, it was BAM_AS_BED, and the key was printed.
    return false;

}
예제 #3
0
void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blockList)
{
    if (needsFlush()) {
        flush();
    }
    //The first time we print a record is when we print any header, because the header
    //hasn't been read from the query file until after the first record has also been read.
    checkForHeader();

    const_cast<Record *>(keyList.getKey())->undoZeroLength();
    _currBamBlockList = blockList;

    if (_context->getProgram() == ContextBase::INTERSECT) {
        if (_printable) {
            if (keyList.empty()) {
                if ((static_cast<ContextIntersect *>(_context))->getWriteAllOverlap()) {
                    // -wao the user wants to force the reporting of 0 overlap
                    if (printKeyAndTerminate(keyList)) {

                        _currBamBlockList = NULL;
                        return;
                    }
                    tab();
                    null(false, true);
                    tab();
                    _outBuf.append('0');
                    newline();
                    if (needsFlush()) flush();
                }
                else if ((static_cast<ContextIntersect *>(_context))->getLeftJoin()) {
                    if (printKeyAndTerminate(keyList)) {
                        _currBamBlockList = NULL;

                        return;
                    }
                    tab();
                    null(false, true);
                    newline();
                    if (needsFlush()) flush();
                    _currBamBlockList = NULL;

                    return;
                }
            } else {
                if (printBamRecord(keyList, true) == BAM_AS_BAM) {
                    _currBamBlockList = NULL;

                    return;
                }
                int hitIdx = 0;
                for (RecordKeyVector::const_iterator_type iter = keyList.begin(); iter != keyList.end(); iter = keyList.next()) {
                    reportOverlapDetail(keyList.getKey(), *iter, hitIdx);
                    hitIdx++;
                }
            }
        } else { // not printable
            reportOverlapSummary(keyList);
        }
        _currBamBlockList = NULL;
    } else if (_context->getProgram() == ContextBase::SAMPLE) {
        if (!printKeyAndTerminate(keyList)) {
            newline();
        }
        _currBamBlockList = NULL;

        return;
    } else if (_context->getProgram() == ContextBase::MAP) {
        printKeyAndTerminate(keyList);
        _currBamBlockList = NULL;

        return;
    } else if (_context->getProgram() == ContextBase::MERGE) {
        printKeyAndTerminate(keyList);
        _currBamBlockList = NULL;

        return;
    }
}