From: Multiple genome comparison based on overlap regions of pairwise local alignments
Algorithm 4 (LinearWeightedMOI) |
---|
Input: sorted list of intervals interval [1 ..n ]; number of collections k ; weight of the collections weight [1 ..k ]; length l of the target genome; minimum weight a weighted MOI must have minWeight |
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: openWeight ← 0 |
5: c[0..l] ← 0 |
6: for all ∈ interval[1..n] do |
7: if end >endPoint[j] then |
8: c[endPoint[j]] ← c[endPoint[j]] - weight[j] |
9: c[end] ← c[end] + weight[j] |
10: if endPoint[j] < min and end ≥ min then |
11: openWeight ← openWeight + weight[j] |
12: end if |
13: endPoint[j] = end |
14: end if |
15: if all intervals with recent start position processed then |
16: while openWeight-c[min] ≥ minWeight do |
17: openWeight ← openWeight - c[min] |
18: min ← min + 1 |
19: end while |
20: if prevEnd < min and min ≥ start then |
21: output MOI(start, min) |
22: prevEnd ← min |
23: end if |
24: end if |
25: end for |