Commit 1a9b2f6c authored by Aaron's avatar Aaron
Browse files

Added isBed12 attr. and overlap fraction support for blocked intervals.

parent 2f6dfe9c
......@@ -87,6 +87,8 @@ private:
bool processHits(const BED &a, const vector<BED> &hits);
bool FindOverlaps(const BED &a, vector<BED> &hits);
bool FindBlockedOverlaps(const BED &a, vector<BED> &hits);
void ReportOverlapDetail(int overlapBases, const BED &a, const BED &b, CHRPOS s, CHRPOS e);
......
......@@ -64,9 +64,10 @@ void GetBamBlocks(const BamAlignment &bam,
void GetBedBlocks(const BED &bed, bedVector &bedBlocks) {
if (bed.fields.size() < 6) {
cerr << "Input error: Cannot split into blocks. Found interval with fewer than 12 columns." << endl;
exit(1);
// nothing to do if it is not a BED12 intervals
if (bed.fields.size() != 12) {
bedBlocks.push_back(bed);
return;
}
int blockCount = atoi(bed.fields[9].c_str());
......@@ -102,4 +103,15 @@ void GetBedBlocks(const BED &bed, bedVector &bedBlocks) {
bedBlocks.push_back(currBedBlock);
}
}
}
int GetTotalBlockLength(const bedVector &bedBlocks) {
int total_size = 0;
bedVector::const_iterator blockItr = bedBlocks.begin();
bedVector::const_iterator blockEnd = bedBlocks.end();
for (; blockItr != blockEnd; ++blockItr) {
total_size += blockItr->end - blockItr->start;
}
return total_size;
}
\ No newline at end of file
......@@ -26,4 +26,7 @@ void GetBamBlocks(const BamAlignment &bam,
bool breakOnDeletionOps = false);
/* break a BED12 record into discrete BED6 blocks. */
void GetBedBlocks(const BED &bed, bedVector &bedBlocks);
\ No newline at end of file
void GetBedBlocks(const BED &bed, bedVector &bedBlocks);
/* compute the total forprint of a set of BED blocks */
int GetTotalBlockLength(const bedVector &bedBlocks);
\ No newline at end of file
......@@ -559,7 +559,6 @@ void BedFile::setZeroBased(bool zeroBased) { this->isZeroBased = zeroBased; }
void BedFile::setGff (bool gff) { this->_isGff = gff; }
void BedFile::setVcf (bool vcf) { this->_isVcf = vcf; }
......@@ -569,10 +568,8 @@ void BedFile::setFileType (FileType type) {
}
void BedFile::setBedType (int colNums) {
bedType = colNums;
}
void BedFile::setBedType (int colNums) { bedType = colNums; }
void BedFile::setBed12 (bool isBed12) { this->isBed12 = isBed12; }
void BedFile::loadBedFileIntoMap() {
......
......@@ -469,6 +469,7 @@ public:
string bedFile;
unsigned int bedType; // 3-6, 12 for BED
// 9 for GFF
bool isBed12; // is it file of true blocked BED12 records?
bool isZeroBased;
// Main data structires used by BEDTools
......@@ -504,6 +505,7 @@ private:
void setVcf (bool isVcf);
void setFileType (FileType type);
void setBedType (int colNums);
void setBed12 (bool isBed12);
/************ Private utilities ***********************/
void GetHeader(void);
......@@ -559,6 +561,21 @@ private:
setZeroBased(true);
setFileType(BED_FILETYPE);
setBedType(numFields); // we now expect numFields columns in each line
// test to see if the file has true blocked BED12 records
if (numFields == 12) {
int cdsStart = atoi(lineVector[6].c_str());
int cdsEnd = atoi(lineVector[7].c_str());
int numExons = atoi(lineVector[9].c_str());
if (cdsStart > 0 && cdsEnd > 0&& numExons > 0 &&
lineVector[10].find(",") == 0 &&
lineVector[11].find(",") == 0)
{
setBed12(true);
}
else setBed12(false);
}
if (parseBedLine(bed, lineVector, _lineNum, numFields) == true) return BED_VALID;
}
// it's VCF, assuming the second column is numeric and there are at least 8 fields.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment