Ejemplo n.º 1
0
void BedCoverage::CollectCoverageBed() {

    // load the "B" bed file into a map so
    // that we can easily compare "A" to it for overlaps
    _bedB->loadBedCovFileIntoMap();

    int lineNum = 0;                    // current input line number
    BED a, nullBed;
    BedLineStatus bedStatus;

    _bedA->Open();
    // process each entry in A
    while ((bedStatus = _bedA->GetNextBed(a, lineNum)) != BED_INVALID) {
        if (bedStatus == BED_VALID) {
            // process the BED entry as a single block
            if (_obeySplits == false)
                _bedB->countHits(a, _forceStrand);
            // split the BED into discrete blocksand process each independently.
            else {
                bedVector bedBlocks;
                splitBedIntoBlocks(a, lineNum, bedBlocks);

                // use countSplitHits to avoid over-counting each split chunk
                // as distinct read coverage.
                _bedB->countSplitHits(bedBlocks, _forceStrand);
            }
            a = nullBed;
        }
    }
    _bedA->Close();

    // report the coverage (summary or histogram) for BED B.
    ReportCoverage();
}
Ejemplo n.º 2
0
void BedIntersect::IntersectBed() {

	// load the "B" file into a map in order to 
	// compare each entry in A to it in search of overlaps.
	_bedB->loadBedFileIntoMap();                                                                                                                 
	
	int lineNum = 0;
	vector<BED> hits;
	hits.reserve(100);
	BED a, nullBed;	
	BedLineStatus bedStatus;
	
	// open the "A" file, process each BED entry and searh for overlaps.
	_bedA->Open();
	while ((bedStatus = _bedA->GetNextBed(a, lineNum)) != BED_INVALID) {
		if (bedStatus == BED_VALID) {
		    // treat the BED as a single "block"
		    if (_obeySplits == false) {
    			FindOverlaps(a, hits);
    			hits.clear();
    			a = nullBed;
			}
			// split the BED12 into blocks and look for overlaps in each discrete block
            else {
                bedVector bedBlocks;  // vec to store the discrete BED "blocks"
                splitBedIntoBlocks(a, lineNum, bedBlocks);
                
                vector<BED>::const_iterator bedItr  = bedBlocks.begin();
            	vector<BED>::const_iterator bedEnd  = bedBlocks.end();
            	for (; bedItr != bedEnd; ++bedItr) {
        	        FindOverlaps(*bedItr, hits);
                    hits.clear();
        	    }
        	    a = nullBed;  
            }
		}
	}
	_bedA->Close();
}