int bode::DensitySet::lsearch(std::vector<struct IntervalIndex> &v,int left,int right) { int pos,top; top = v.size(); for (pos=0;pos<top;pos++) { if (olap(v[pos],left,right)) { return pos; } } return -1; }
void bode::DensitySet::add(std::string &chrom,int left,int right) { int i; int top; if (chrom2intervals.count(chrom) == 0) { return; } std::vector<struct IntervalIndex>& vii = chrom2intervals[chrom]; top = vii.size(); i = bsearch(vii,left,right); while (i != -1 && i < top && olap(vii[i],left,right)) { intervals[vii[i].index].dmap->set(left - vii[i].left,right - vii[i].left); i++; } }
void Read_Olaps(coParameters *G, gkStore *gkpStore) { ovStore *ovs = new ovStore(G->ovlStorePath, gkpStore); ovs->setRange(G->bgnID, G->endID); uint64 numolaps = ovs->numOverlapsInRange(); uint64 numNormal = 0; uint64 numInnie = 0; fprintf(stderr, "Read_Olaps()-- Loading "F_U64" overlaps from '%s' for reads "F_U32" to "F_U32"\n", numolaps, G->ovlStorePath, G->bgnID, G->endID); fprintf(stderr, "--Allocate "F_U64" MB for overlaps.\n", (sizeof(Olap_Info_t) * numolaps) >> 20); G->olaps = new Olap_Info_t [numolaps]; G->olapsLen = 0; ovOverlap olap(gkpStore); while (ovs->readOverlap(&olap)) { G->olaps[G->olapsLen].a_iid = olap.a_iid; G->olaps[G->olapsLen].b_iid = olap.b_iid; G->olaps[G->olapsLen].a_hang = olap.a_hang(); G->olaps[G->olapsLen].b_hang = olap.b_hang(); //G->olaps[G->olapsLen].orient = (olap.flipped()) ? INNIE : NORMAL; G->olaps[G->olapsLen].innie = (olap.flipped() == true); G->olaps[G->olapsLen].normal = (olap.flipped() == false); G->olaps[G->olapsLen].order = G->olapsLen; G->olaps[G->olapsLen].evalue = olap.evalue(); numNormal += (G->olaps[G->olapsLen].normal == true); numInnie += (G->olaps[G->olapsLen].innie == true); G->olapsLen++; } delete ovs; fprintf(stderr, "Read_Olaps()-- Loaded "F_U64" overlaps -- "F_U64" normal and "F_U64" innie.\n", G->olapsLen, numNormal, numInnie); }
int bode::DensitySet::bsearch(std::vector<struct IntervalIndex> &v,int left,int right) { int top,bot,mid; bot = 0; top = v.size() - 1; while (bot < top) { mid = (bot+top)/2; if (v[mid].right < left) { bot = mid+1; } else { top = mid; } } if (top == bot && olap(v[bot],left,right)) { return bot; } else { return -1; } }