| 1 | bix |
| 2 | === |
| 3 | |
| 4 | Tabix files in go. |
| 5 | |
| 6 | [](https://godoc.org/github.com/brentp/bix) |
| 7 | |
| 8 | |
| 9 | `Bix`is a pure go tabix reader. Tabix has a minimum resolution of 16K bases. So, for dense annotations |
| 10 | like ExAC, repeated queries will have to re-parse the same intervals. To mitigate this, `Bix` caches |
| 11 | all annotations for the blocks from each query and re-uses them for later querires to the same block. |
| 12 | In practice, this results in 10X-100X speedup for any type of data. |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | ```go |
| 18 | tbx, err := bix.New(f) |
| 19 | |
| 20 | // Query returns an io.Reader |
| 21 | ph := true // print header ? |
| 22 | rdr, err := tbx.Query(chrom, start, end, ph) |
| 23 | buf := bufio.NewReader(rdr) |
| 24 | for { |
| 25 | line, err := bufr.ReadString('\n') |
| 26 | if err == io.EOF { |
| 27 | break |
| 28 | } |
| 29 | fmt.Println(line) |
| 30 | } |
| 31 | // or |
| 32 | |
| 33 | intervals := tbx.Get(chrom, start, end) |
| 34 | |
| 35 | |
| 36 | ``` |
| 37 | |
| 38 | where intervals will be either a vcfgo.Variant or an Interval object with a Chrom(), Start(), and End() method. |