github.com/Schaudge/hts@v0.0.0-20240223063651-737b4d69d68c/tabix/tabix_test.go (about)

     1  package tabix
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  
     7  	"gopkg.in/check.v1"
     8  )
     9  
    10  func Test(t *testing.T) { check.TestingT(t) }
    11  
    12  type S struct{}
    13  
    14  var _ = check.Suite(&S{})
    15  
    16  // Generated by `echo $'chr1\t1\t100' | bgzip -c > t.bed.gz; tabix t.bed.gz'.
    17  // See https://github.com/biogo/hts/issues/19.
    18  var issue19TestData = []byte{
    19  	0x54, 0x42, 0x49, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, // |TBI.............|
    20  	0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // |........#.......|
    21  	0x05, 0x00, 0x00, 0x00, 0x63, 0x68, 0x72, 0x31, 0x00, 0x02, 0x00, 0x00, 0x00, 0x49, 0x12, 0x00, // |....chr1.....I..|
    22  	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, // |...............%|
    23  	0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // |.....J..........|
    24  	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // |.......%........|
    25  	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // |................|
    26  	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // |................|
    27  	0x00, /*                                                                                     */ // |.|
    28  }
    29  
    30  func (s *S) TestIssue19(c *check.C) {
    31  	idx, err := ReadFrom(bytes.NewReader(issue19TestData))
    32  	c.Assert(err, check.Equals, nil)
    33  
    34  	chunks, err := idx.Chunks("chr1", 1, 19999999)
    35  	c.Assert(err, check.Equals, nil)
    36  	c.Check(len(chunks), check.Not(check.Equals), 0)
    37  }