Did I find the right examples for you? yes no

# util.overlap

All Samples(9)  |  Call(9)  |  Derive(0)  |  Import(0)
```Checks if one interval contains any overlap with another interval.

Keyword arguments:
t1 -- First tuple.
t2 -- Second tuple.

Returns:
Returns -1 if i1 is before i2; 1 if i1 is after i2; and 0 if there is any overlap.
```

```        def overlap(t1, t2):
"""Checks if one interval contains any overlap with another interval.

Keyword arguments:
t1 -- First tuple.
t2 -- Second tuple.

Returns:
Returns -1 if i1 is before i2; 1 if i1 is after i2; and 0 if there is any overlap.
"""
if(t1[1] <= t2[0]): return -1 # interval1 is before interval2
if(t2[1] <= t1[0]): return 1 # interval1 is after interval2
return 0 # interval1 overlaps interval2
```

```                            l0, h0 = strand0.idxs()
l1, h1 = strand1.idxs()
oLow, oHigh = util.overlap(l0, h0, l1, h1)
try:
lList = filter(lambda x:x>oLow and x<oHigh, part.getPreXoversLow(strandType, p0))
```

```
# get the ovelap
lowIdx, highIdx = util.overlap(sLowIdx, sHighIdx, cLowIdx, cHighIdx)

# only get the characters we're using, while we're at it, make it the
```

```            didBreak = False
while(counter < len(assocDict[chrName])):
check = util.overlap(coord,assocDict[chrName][counter])
if(check == 0): # Contain overlap
didBreak = True
```
```                else: geneCoord = [assocDict[chrName][counter][0],assocDict[chrName][counter][1]+promoterLength]

check = util.overlap(coord,geneCoord) # Check overlap between coordinate and gene+promoter

if(check == 0): # If contain overlap, then check if the coordinate also contains overlap with the next gene
```
```                        if(assocDict[chrName][counter+1][4] == "+"): geneCoordNext = [assocDict[chrName][counter+1][0]-promoterLength,assocDict[chrName][counter+1][1]]
else: geneCoordNext = [assocDict[chrName][counter+1][0],assocDict[chrName][counter+1][1]+promoterLength]
checkNext = util.overlap(coord,geneCoordNext) # Verify overlap between coordinate and next gene
if(checkNext == 0): genesList.append(assocDict[chrName][counter+1][2]+"_PROX") # If there is an overlap then add this gene to association list
#else: # If this is the last gene (there is no 'next') then dont verify overlap
```
```                    genesList = [] # List of overlapping genes
maxGeneCoord = [geneCoord[0]-threshDist,geneCoord[1]+threshDist]
maxCheck = util.overlap(coord,maxGeneCoord)
if(maxCheck == 0): genesList.append(assocDict[chrName][counter][2]+"_DIST") # If it overlapped then put current gene in overlap list

```
```                        else: geneCoordPrev = [assocDict[chrName][counter-1][0],assocDict[chrName][counter-1][1]+promoterLength]
maxGeneCoordPrev = [geneCoordPrev[0]-threshDist,geneCoordPrev[1]+threshDist]
maxCheckPrev = util.overlap(coord,maxGeneCoordPrev)
if(maxCheckPrev == 0): genesList.append(assocDict[chrName][counter-1][2]+"_DIST") # If it overlapped then put previous gene in overlap list

```

```                while(counter[factorName] < len(allMpbsDict[factorName][chrName])):