Skip to content

Commit

Permalink
unikmer diff: fix bug of hanging when the first file having no Kmers.
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Oct 13, 2018
1 parent 390463f commit d225cb7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- v0.4.3
- `unikmer diff`: fix bug of hanging when the first file having no Kmers.
- v0.4.2
- `unikmer stats/diff`: more intuitional output
- v0.4.1
- Better performance of writing and reading binary files
- v0.4.0
Expand Down
46 changes: 46 additions & 0 deletions unikmer/cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,52 @@ Tips:
if opt.Verbose {
log.Infof("%d Kmers loaded", len(m))
}

if len(m) == 0 {
if opt.Verbose {
log.Infof("export Kmers")
}

if !isStdout(outFile) {
outFile += extDataFile
}
outfh, gw, w, err := outStream(outFile, opt.Compress)
checkError(err)
defer func() {
outfh.Flush()
if gw != nil {
gw.Close()
}
w.Close()
}()

var mode uint32
if opt.Compact {
mode |= unikmer.UNIK_COMPACT
}
if canonical {
mode |= unikmer.UNIK_CANONICAL
}
if sortKmers {
mode |= unikmer.UNIK_SORTED
}

writer, err := unikmer.NewWriter(outfh, k, mode)
checkError(err)

if sortKmers {
writer.Number = 0
}

writer.Number = 0
checkError(writer.WriteHeader())
checkError(writer.Flush())

if opt.Verbose {
log.Infof("%d Kmers saved", 0)
}
return
}
// -----------------------------------------------------------------------

done := make(chan int)
Expand Down
2 changes: 1 addition & 1 deletion unikmer/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

// VERSION is the version
var VERSION = "0.4.2"
var VERSION = "0.4.3"

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Expand Down

0 comments on commit d225cb7

Please sign in to comment.