INNER CODE UNIT · C
compareRegions
dpryan79/MethylDackel · bed.c:11
static inline int64_t compareRegions(int32_t tid0, int32_t start0, int32_t end0, int32_t tid1, int32_t start1, int32_t end1) {
if(tid0 != tid1) return ((int64_t) tid0)-((int64_t) tid1);
if(start0 < start1 && end0 >= start1) return 0;
if(start0 >= start1 && start0 < end1) return 0;
return ((int64_t) start0)-((int64_t) start1);
}
//1: Overlaps
//0: No Overlap
//-1: End of BED file
//This should eventually be modified to use a hash
int spanOverlapsBED(int32_t tid, int32_t start, int32_t end, bedRegions *regs, int32_t *idx) {
bedRegion *reg = regs->region;
int64_t rv = -1;
int i;
//First, test the last position we probed.
if(compareRegions(reg[*idx].tid, reg[*idx].start, reg[*idx].end-1, tid, start, end) == 0) return 1;