Skip to main content

Table 2

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 ( I i j = [ s t a r t , e n d ] ) 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