Skip to content

Commit

Permalink
Fix always falling back to non-bgzip reader (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
zamaudio authored and brentp committed Jun 7, 2019
1 parent 54bcc00 commit deeeee3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vcfanno.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,32 @@ see: https://github.com/brentp/vcfanno

var err error
var qrdr io.Reader
// try to parallelizing reading if we have plenty of CPUs and it's (possibly)
// try to parallelize reading if we have plenty of CPUs and it's (possibly)
// a bgzf file.
if len(config.Annotation) < runtime.GOMAXPROCS(0) && strings.HasSuffix(queryFile, ".gz") {
if len(config.Annotation) < runtime.GOMAXPROCS(0) && strings.HasSuffix(queryFile, ".gz") || strings.HasSuffix(queryFile, ".bgz") {
if rdr, err := os.Open(queryFile); err == nil {
if st, err := rdr.Stat(); err == nil && st.Size() > 2320303098 {
qrdr, err = bgzf.NewReader(rdr, 4)
if err == nil {
log.Printf("using 4 worker threads to decompress query file")
log.Printf("using 4 worker threads to decompress bgzip file")
} else {
qrdr = nil
}
qrdr = nil
} else {
qrdr, err = bgzf.NewReader(rdr, 2)
if err == nil {
log.Printf("using 2 worker threads to decompress query file")
log.Printf("using 2 worker threads to decompress bgzip file")
} else {
qrdr = nil
}
qrdr = nil
}
} else {
log.Fatal(err)
}
}
if qrdr == nil {
qrdr, err = xopen.Ropen(queryFile)
log.Printf("falling back to non-bgzip")
}
if err != nil {
log.Fatal(fmt.Errorf("error opening query file %s: %s", queryFile, err))
Expand Down

0 comments on commit deeeee3

Please sign in to comment.