From: Multiple genome comparison based on overlap regions of pairwise local alignments
Algorithm 2 (CircularMOI) |
---|
Input: sorted list of intervals interval [1 ..n ]; number of collections k ; length of the longest interval ℓ |
Variables: largest end point seen so far in each collection endPoint [1 ..k ]; c [0 ..l ] |
1: endPoint[1..k] ← 0 |
2: prevEnd ← 0 |
3: min ← 0 |
4: c[0..ℓ] ← 0 |
5: open ← 0 |
6: for all ∈ interval[1..n] do |
7: while min < start do |
8: open ← open - c[min mod ℓ] |
9: c[min mod ℓ] ← 0 |
10: min ← min + 1 |
11: end while |
12: if end > endPoint[j] then |
13: if endPoint[j] ≥ min then |
14: c[endPoint[j] mod ℓ] ← c[endPoint[j] mod ℓ] - 1 |
15: else |
16: open ← open + 1 |
17: end if |
18: c[end mod ℓ] ← c[end mod ℓ] + 1 |
19: endPoint[j] ← end |
20: end if |
21: if all intervals with recent start position processed and open = k then |
22: while c[min mod ℓ] = 0 do |
23: min ← min + 1 |
24: end while |
25: if prevEnd < min then |
26: output MOI(start, min) |
27: prevEnd ← min |
28: end if |
29: end if |
30: end for |