Skip to content

Commit

Permalink
Update for latest msgpack4nim
Browse files Browse the repository at this point in the history
* jangko/msgpack4nim#18

And update both msgpack4nim and cligen.
  • Loading branch information
Christopher Dunn committed May 22, 2018
1 parent 9089276 commit d1cff6f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
[submodule "repos/nim-DAZZ_DB"]
path = repos/nim-DAZZ_DB
url = https://github.com/bio-nim/nim-DAZZ_DB
ignore=dirty
branch = dev
[submodule "repos/nim-htslib"]
path = repos/nim-htslib
url = https://github.com/bio-nim/nim-htslib
ignore=dirty
[submodule "repos/nim-DALIGNER"]
path = repos/nim-DALIGNER
url = https://github.com/bio-nim/nim-DALIGNER
ignore=dirty
branch = dev
[submodule "repos/nim-heap"]
path = repos/nim-heap
url = https://github.com/bio-nim/nim-heap
ignore=dirty
[submodule "repos/cligen"]
path = repos/cligen
url = https://github.com/c-blake/cligen
ignore=dirty
branch = master
[submodule "repos/msgpack4nim"]
path = repos/msgpack4nim
url = https://github.com/jangko/msgpack4nim
ignore=dirty
#branch = master
2 changes: 1 addition & 1 deletion repos/msgpack4nim
16 changes: 10 additions & 6 deletions src/falcon/rr_hctg_track.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# vim: sw=2 ts=2 sts=2 tw=80 et:
# Nim re-write of FALCON_unzip/falcon_unzip/rr_hctg_track.py
import "../msgpack4nim/msgpack4nim.nim"
import "../msgpack4nim/msgpack4collection.nim"
from "../nim-heap/binaryheap" import nil
from sys import log

Expand Down Expand Up @@ -60,16 +61,16 @@ proc tostring(src: str9, dst: var string) =
proc hash(x: str9): hashes.Hash =
return hashes.hash(tostring(x))

proc unpack_type*(ss: streams.Stream, x: var str9) =
proc unpack_type*(ss: var msgpack4nim.MsgStream, x: var str9) =
var str: string
msgpack4nim.unpack(ss, str)
copyMem(addr x[0], addr str[0], 9)

proc pack_type*(ss: streams.Stream, x: str9) =
proc pack_type*(ss: var msgpack4nim.MsgStream, x: str9) =
let str: string = tostring(x)
msgpack4nim.pack(ss, str)

proc pack_type*(ss: streams.Stream, x: binaryheap.Heap[mytuple]) =
proc pack_type*(ss: var msgpack4nim.MsgStream, x: binaryheap.Heap[mytuple]) =
let xseq: seq[mytuple] = sequtils.toSeq(binaryheap.items(x)) # unsorted
msgpack4nim.pack(ss, xseq)
proc `$`(x: str9): string =
Expand Down Expand Up @@ -409,10 +410,11 @@ proc run_tr_stage1(db_fn, fn: string, min_len, bestn: int): string =
osproc.close(la4falcon_proc)
let fn_rtn = "$#.rr_hctg_track.partial.msgpack" % [fn]
log("Serialize '$#'" % [fn_rtn])
var msgss = msgpack4nim.initMsgStream() #you can pass some buffer capacity here https://github.com/jangko/msgpack4nim/issues/18
msgpack4nim.pack(msgss, rtn)
var ss = streams.newFileStream(fn_rtn, system.fmWrite)
defer: ss.close()
#ss.write($rtn)
msgpack4nim.pack(ss, rtn)
ss.write(msgss.data)
return fn_rtn

proc spawned_tr_stage1(db_fn, fn: string, min_len, bestn: int): string {.thread} =
Expand Down Expand Up @@ -498,8 +500,10 @@ proc run_stage2*(
let infile = streams.newFileStream(fn_rtn, system.fmRead)
defer:
infile.close()
var msgss = msgpack4nim.initMsgStream()
msgss.data = infile.readAll()
var res: mytable
msgpack4nim.unpack(infile, res)
msgpack4nim.unpack(msgss, res)
log(" Updating bread_to_areads table with ", len(res), " breads.")
for k,v in res.pairs:
if not bread_to_areads.contains(k):
Expand Down

0 comments on commit d1cff6f

Please sign in to comment.