1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <alignment/datastructures/anchoring/ClusterList.hpp>
ClusterList::ClusterList()
{
lowerSizeLimit = 20;
lowerSizeLimitNumAnchors = 1;
curp = cure = 0;
onContigStart = true;
curIndex = 0;
}
void ClusterList::Clear()
{
onContigStart = true;
numBases.clear();
startPos.clear();
numAnchors.clear();
}
bool ClusterList::Store(int n, DNALength p, DNALength e, int b)
{
bool intervalIsEclipsed = true;
bool intervalEclipses = false;
if (onContigStart == true) {
curp = p;
cure = e;
intervalIsEclipsed = false;
} else {
if (curp <= p and cure >= e) {
intervalIsEclipsed = true;
} else {
if (p <= curp and e >= cure) {
intervalEclipses = true;
}
intervalIsEclipsed = false;
}
}
if (intervalIsEclipsed == false) {
//
// The current interval is unique: it does not eclipse any
// other intervals and is not eclipsed by any.
//
if (n >= lowerSizeLimit) {
if (intervalEclipses == false or onContigStart) {
numBases.push_back(n);
startPos.push_back(p);
numAnchors.push_back(b);
onContigStart = false;
//
// Record where the last interval is. Since ther intervals
// are sorted by position, only need to compare against the
// current interval to make sure they are not overlapping
// other intervals.
//
curp = p;
cure = e;
} else {
//
// The new interval eclipses the last one added.
//
if (n > numBases[numBases.size() - 1]) {
numBases[numBases.size() - 1] = n;
startPos[startPos.size() - 1] = p;
numAnchors[numAnchors.size() - 1] = b;
curp = p;
cure = e;
}
}
}
}
return !intervalIsEclipsed;
}
void ClusterList::ResetCoordinates() { onContigStart = true; }
|