Last active
March 15, 2017 14:38
-
-
Save TransGirlCodes/1c550e345b742f3287da4f9a2c2fda08 to your computer and use it in GitHub Desktop.
Parameterising MinHashSketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From this: | |
type MinHashSketch | |
sketch::Vector{UInt64} | |
kmersize::Int | |
function MinHashSketch(sketch::Vector, kmersize::Int) | |
length(sketch) > 0 || error("Sketch cannot be empty") | |
kmersize > 0 || error("Kmersize must be greater than 0") | |
new(sketch, kmersize) | |
end | |
end | |
# To this: | |
type MinHashSketch{k} | |
sketch::Vector{UInt64} | |
function MinHashSketch{k}(sketch::Vector) | |
length(sketch) > 0 || error("Sketch cannot be empty") | |
k > 0 || error("Kmersize must be greater than 0") # This could even be reworked into a generated function, or I believe more complex "where" syntax is comming to parametric functions. | |
new(sketch, kmersize) | |
end | |
end | |
# With k as a type parameter, you can do MinHashSketch{10}(myvector), and some descisions about K size can be relegated to compile time with generated functions, or otherwise removes the need to pass k as a value. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment