Skip to content
Snippets Groups Projects
Commit 5c3d96db authored by Aaron's avatar Aaron
Browse files

Further nullBed tweaking.

parent 600a99ca
No related branches found
No related tags found
No related merge requests found
...@@ -198,7 +198,7 @@ void BedIntersect::IntersectBed() { ...@@ -198,7 +198,7 @@ void BedIntersect::IntersectBed() {
vector<BED> hits; vector<BED> hits;
hits.reserve(100); hits.reserve(100);
BED a, nullBed; BED a;
// open the "A" file, process each BED entry and searh for overlaps. // open the "A" file, process each BED entry and searh for overlaps.
_bedA->Open(); _bedA->Open();
...@@ -226,7 +226,6 @@ void BedIntersect::IntersectBed() { ...@@ -226,7 +226,6 @@ void BedIntersect::IntersectBed() {
} }
} }
} }
a = nullBed;
} }
_bedA->Close(); _bedA->Close();
} }
......
...@@ -481,6 +481,7 @@ private: ...@@ -481,6 +481,7 @@ private:
istream *_bedStream; istream *_bedStream;
string _bedLine; string _bedLine;
BED _nullBed;
string _header; string _header;
bool _firstLine; bool _firstLine;
vector<string> _bedFields; vector<string> _bedFields;
...@@ -509,14 +510,19 @@ private: ...@@ -509,14 +510,19 @@ private:
*/ */
template <typename T> template <typename T>
inline BedLineStatus parseLine (T &bed, const vector<string> &lineVector) { inline BedLineStatus parseLine (T &bed, const vector<string> &lineVector) {
// clear out the data from the last line.
bed = _nullBed;
unsigned int numFields = lineVector.size(); unsigned int numFields = lineVector.size();
// bail out if we have a blank line // bail out if we have a blank line
if (numFields == 0) { if (numFields == 0) {
return BED_BLANK; return BED_BLANK;
} }
// bail out if we have a comment line
if (lineVector[0].find("#") == 0) {
return BED_HEADER;
}
if (numFields >= 3) { if (numFields >= 3) {
// line parsing for all lines after the first non-header line // line parsing for all lines after the first non-header line
...@@ -623,7 +629,6 @@ private: ...@@ -623,7 +629,6 @@ private:
bed.name = lineVector[3]; bed.name = lineVector[3];
bed.score = lineVector[4]; bed.score = lineVector[4];
bed.strand = lineVector[5]; bed.strand = lineVector[5];
bed.otherFields.clear();
for (unsigned int i = 6; i < lineVector.size(); ++i) { for (unsigned int i = 6; i < lineVector.size(); ++i) {
bed.otherFields.push_back(lineVector[i]); bed.otherFields.push_back(lineVector[i]);
} }
...@@ -677,7 +682,6 @@ private: ...@@ -677,7 +682,6 @@ private:
} }
if (this->bedType > 2) { if (this->bedType > 2) {
bed.otherFields.clear();
for (unsigned int i = 2; i < numFields; ++i) for (unsigned int i = 2; i < numFields; ++i)
bed.otherFields.push_back(lineVector[i]); bed.otherFields.push_back(lineVector[i]);
} }
...@@ -717,7 +721,6 @@ private: ...@@ -717,7 +721,6 @@ private:
template <typename T> template <typename T>
inline bool parseGffLine (T &bed, const vector<string> &lineVector, int lineNum, unsigned int numFields) { inline bool parseGffLine (T &bed, const vector<string> &lineVector, int lineNum, unsigned int numFields) {
if (numFields == this->bedType) { if (numFields == this->bedType) {
bed.otherFields.clear();
if (this->bedType >= 8 && _isGff) { if (this->bedType >= 8 && _isGff) {
bed.chrom = lineVector[0]; bed.chrom = lineVector[0];
if (isInteger(lineVector[3])) if (isInteger(lineVector[3]))
......
...@@ -62,19 +62,17 @@ ChromSweep::~ChromSweep(void) { ...@@ -62,19 +62,17 @@ ChromSweep::~ChromSweep(void) {
void ChromSweep::ScanCache() { void ChromSweep::ScanCache() {
if (_query->_status != BED_INVALID) { vector<BED>::iterator c = _cache.begin();
vector<BED>::iterator c = _cache.begin(); while (c != _cache.end())
while (c != _cache.end()) {
{ if ((_curr_qy.chrom == c->chrom) && !(after(_curr_qy, *c))) {
if ((_curr_qy.chrom == c->chrom) && !(after(_curr_qy, *c))) { if (IsValidHit(_curr_qy, *c)) {
if (IsValidHit(_curr_qy, *c)) { _hits.push_back(*c);
_hits.push_back(*c);
}
++c;
}
else {
c = _cache.erase(c);
} }
++c;
}
else {
c = _cache.erase(c);
} }
} }
} }
...@@ -156,7 +154,6 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) { ...@@ -156,7 +154,6 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) {
_results.push(make_pair(_curr_qy, _hits)); _results.push(make_pair(_curr_qy, _hits));
// reset for the next query // reset for the next query
_hits.clear(); _hits.clear();
_curr_qy = _nullBed;
_query->GetNextBed(_curr_qy, true); _query->GetNextBed(_curr_qy, true);
_curr_chrom = _curr_qy.chrom; _curr_chrom = _curr_qy.chrom;
} }
...@@ -167,7 +164,8 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) { ...@@ -167,7 +164,8 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) {
_results.pop(); _results.pop();
return true; return true;
} }
// otherwise, the party is over. else {
else {return false;} return false;
}
} }
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