aboutsummaryrefslogtreecommitdiff
path: root/src/nbc/genome.sml
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-03-15 15:26:20 -0400
committerCalvin <calvin@EESI>2013-03-15 15:26:20 -0400
commitb632667ce57af89691407bb8668e1512775278ae (patch)
treeb5742cef185f1cc4a7ba6005b5b4116ce7558a01 /src/nbc/genome.sml
parent39e39f82cc38d71018882b0aaaf58255858a7c56 (diff)
nbc added
Diffstat (limited to 'src/nbc/genome.sml')
-rw-r--r--src/nbc/genome.sml33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nbc/genome.sml b/src/nbc/genome.sml
new file mode 100644
index 0000000..81f3183
--- /dev/null
+++ b/src/nbc/genome.sml
@@ -0,0 +1,33 @@
+signature GENOME = sig
+ exception Bad
+ type t
+ val load: string * int -> t
+ val get: t * string -> int option
+end
+
+structure Genome :> GENOME = struct
+ exception Bad
+ fun |> (x, f) = f x
+ infix |>
+
+ type t = (string, int) HashTable.hash_table
+ fun load (gname, order) =
+ let
+ val h = HashTable.mkTable
+ (HashString.hashString, op =)
+ (1024 * 1024, Fail "")
+ in
+ Options.genomeText (order, gname) |> Gzip.openIn |> Misc.sequenceLines
+ |> Sequence.map (fn s => (
+ case Misc.split2 s of
+ SOME (count, nmer) => (
+ nmer
+ , case Int.fromString count of
+ NONE => raise Bad
+ | SOME x => x
+ ) | NONE => raise Bad
+ )) |> Sequence.app (HashTable.insert h)
+ ; h
+ end
+ fun get (h, nmer) = HashTable.find h nmer
+end