1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"testing"
"github.com/BurntSushi/toml"
"github.com/brentp/irelate"
"github.com/brentp/irelate/interfaces"
"github.com/brentp/irelate/parsers"
"github.com/brentp/vcfanno/api"
"github.com/brentp/vcfanno/shared"
"github.com/shenwei356/xopen"
)
func benchmarkAnno(b *testing.B) {
var configs shared.Config
if _, err := toml.DecodeFile("example/conf.toml", &configs); err != nil {
panic(err)
}
out := bufio.NewWriter(ioutil.Discard)
Lua, _ := xopen.Ropen("example/custom.lua")
lbytes, _ := ioutil.ReadAll(Lua)
l_string := string(lbytes)
srcs, err := configs.Sources()
if err != nil {
log.Fatal(err)
}
empty := make([]api.PostAnnotation, 0)
for n := 0; n < b.N; n++ {
if err != nil {
log.Fatal(err)
}
a := api.NewAnnotator(srcs, l_string, false, true, empty)
qrdr, err := xopen.Ropen("example/query.vcf.gz")
if err != nil {
log.Fatal(err)
}
qstream, query, err := parsers.VCFIterator(qrdr)
queryables, err := a.Setup(query)
if err != nil {
log.Fatal(err)
}
//files := []string{"example/cadd.sub.txt.gz", "example/query.vcf.gz", "example/fitcons.bed.gz"}
//files := []string{"example/query.vcf.gz", "example/fitcons.bed.gz"}
fn := func(v interfaces.Relatable) {
a.AnnotateEnds(v, api.INTERVAL)
}
stream := irelate.PIRelate(6000, 20000, qstream, false, fn, queryables...)
for interval := range stream {
fmt.Fprintf(out, "%s\n", interval)
}
out.Flush()
}
}
func BenchmarkNormal(b *testing.B) { benchmarkAnno(b) }
|