Skip to content

Commit

Permalink
Merge pull request #3 from robertfeldt/master
Browse files Browse the repository at this point in the history
update for Julia 0.4
  • Loading branch information
quinnj committed Jan 7, 2016
2 parents 25d11da + 2723e8e commit b6cc5b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/SuffixArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module SuffixArrays

export suffixsort

immutable SuffixArray{S<:String,N<:Signed}
immutable SuffixArray{S<:AbstractString,N<:Signed}
string::S
n::Int
index::Array{N,1}
Expand Down Expand Up @@ -30,7 +30,7 @@ end
#=contains(haystack, needle)
matchall(substring, s::String)=#
const MAXCHAR = char(255)
const MAXCHAR = Char(255)

function lcp2(SA,s)
inv = similar(SA)
Expand Down
35 changes: 18 additions & 17 deletions src/sais.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type IntArray
a::Array{Int,1}
pos::Int
end
import Base: getindex, setindex!
getindex(a::IntArray,key) = a.a[a.pos + key]
setindex!(a::IntArray,value,key) = a.a[a.pos + key] = value

Expand All @@ -44,7 +45,7 @@ function getcounts(T,C,n,k)
C[i] = 0
end
for i = 1:n
C[T[i]+1] += 1
C[Int(T[i])+1] += 1
end
end

Expand Down Expand Up @@ -115,7 +116,7 @@ function sais(T, SA, fs, n, k, isbwt)
end
if 1 <= i
0 <= b && (SA[b+1] = j)
b = (B[c1+1] -= 1)
b = (B[Int(c1)+1] -= 1)
j = i-1
m += 1
c1 = c0
Expand Down Expand Up @@ -195,7 +196,7 @@ function sais(T, SA, fs, n, k, isbwt)
c1 = T[p+1]
while true
c0 = c1
q = B[c0+1]
q = B[Int(c0)+1]
while q < j
j -= 1
SA[j+1] = 0
Expand Down Expand Up @@ -229,16 +230,16 @@ function LMSsort(T, SA, C, B, n, k)
getbuckets(C,B,k,false)
j = n - 1
c1 = T[j+1]
b = B[c1+1]
b = B[Int(c1)+1]
j -= 1
SA[b+1] = T[j+1] < c1 ? ~j : j
b += 1
for i = 1:n
if 0 < (j = SA[i])
if (c0 = T[j+1]) != c1
B[c1+1] = b
B[Int(c1)+1] = b
c1 = c0
b = B[c1+1]
b = B[Int(c1)+1]
end
j -= 1
SA[b+1] = T[j+1] < c1 ? ~j : j
Expand All @@ -258,7 +259,7 @@ function LMSsort(T, SA, C, B, n, k)
if c0 != c1
B[c1+1] = b
c1 = c0
b = B[c1+1]
b = B[Int(c1)+1]
end
j -= 1
b -= 1
Expand Down Expand Up @@ -336,7 +337,7 @@ function induceSA(T,SA,C,B,n,k)
getbuckets(C,B,k,false)
j = n - 1
c1 = T[j+1]
b = B[c1+1]
b = B[Int(c1)+1]
SA[b+1] = 0 < j && T[j] < c1 ? ~j : j
b += 1
for i = 1:n
Expand All @@ -345,9 +346,9 @@ function induceSA(T,SA,C,B,n,k)
if 0 < j
j -= 1
if (c0 = T[j+1]) != c1
B[c1+1] = b
B[Int(c1)+1] = b
c1 = c0
b = B[c1+1]
b = B[Int(c1)+1]
end
SA[b+1] = 0 < j && T[j] < c1 ? ~j : j
b += 1
Expand All @@ -361,9 +362,9 @@ function induceSA(T,SA,C,B,n,k)
if 0 < (j = SA[i])
j -= 1
if (c0 = T[j+1]) != c1
B[c1+1] = b
B[Int(c1)+1] = b
c1 = c0
b = B[c1+1]
b = B[Int(c1)+1]
end
b -= 1
SA[b+1] = j == 0 || T[j] > c1 ? ~j : j
Expand All @@ -379,7 +380,7 @@ function computeBWT(T,SA,C,B,n,k)
getbuckets(C,B,k,false)
j = n-1
c1 = T[j+1]
b = B[c1+1]
b = B[Int(c1)+1]
SA[b+1] = 0 < j && T[j] < c1 ? ~j : j
b += 1
for i = 1:n
Expand All @@ -388,7 +389,7 @@ function computeBWT(T,SA,C,B,n,k)
c0 = T[j+1]
SA[i] = ~c0
if c0 != c1
B[c1+1] = b
B[Int(c1)+1] = b
c1 = c0
b = B[c1+1]
end
Expand All @@ -401,16 +402,16 @@ function computeBWT(T,SA,C,B,n,k)
C == B && getcounts(T,C,n,k)
getbuckets(C,B,k,true)
c1 = 0
b = B[c1+1]
b = B[Int(c1)+1]
for i = n:-1:1
if 0 < (j = SA[i])
j -= 1
c0 = T[j+1]
SA[i] = c0
if c0 != c1
B[c1+1] = b
B[Int(c1)+1] = b
c1 = c0
b = B[c1+1]
b = B[Int(c1)+1]
end
b -= 1
SA[b+1] = 0 < j && T[j] > c1 ? ~(T[j]) : j
Expand Down

0 comments on commit b6cc5b8

Please sign in to comment.