Esempio n. 1
0
func (s *TBXSuite) TestRead(c *C) {
	t, err := cgotbx.New("data/vt.norm.vcf.gz")
	c.Assert(err, IsNil)
	rdr, err := t.Get("chr1", 50000, 90000)
	c.Assert(err, IsNil)

	str, err := ioutil.ReadAll(rdr)
	c.Assert(err, IsNil)
	c.Assert(len(str) != 0, Equals, true)

}
Esempio n. 2
0
func main2() {

	/*
		f, err := os.Create("q.pprof")
		if err != nil {
			panic(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	*/

	t, err := cgotbx.New(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	var rdr io.Reader
	for i := 0; i < 1000; i++ {
		tot := 0
		f, err := xopen.Ropen(os.Args[1])
		check(err)
		vcf, err := vcfgo.NewReader(f, true)
		check(err)
		t0 := 0
		for {
			v := vcf.Read()
			if v == nil {
				break
			}

			ts := time.Now()
			for k := 0; k < 100; k++ {
				rdr, err = t.Get(v.Chrom(), int(v.Start()), int(v.Start())+1)
				check(err)
				brdr := bufio.NewReader(rdr)
				//fmt.Fprintln(os.Stderr, v.Chrom(), v.Start(), v.Start()+1)
				j := 0
				for l, err := brdr.ReadString('\n'); err == nil; l, err = brdr.ReadString('\n') {
					//fmt.Fprintln(os.Stderr, "...", l[:20])
					_ = l
					tot += 1
					j += 1
				}
				if j == 0 {
					log.Fatal("should have found something")
				}
			}
			t0 += int(time.Since(ts).Nanoseconds())
		}
		log.Println(tot, float64(t0)*1e-9)
	}
}
Esempio n. 3
0
func (s *TBXSuite) TestLongLine(c *C) {
	t, err := cgotbx.New("data/vt.norm.vcf.gz")
	c.Assert(err, IsNil)
	rdr, err := t.Get("chr1", 915415, 915428)
	c.Assert(err, IsNil)

	b := bufio.NewReader(rdr)
	line, e := b.ReadString('\n')
	log.Println(line)
	c.Assert(e, IsNil)
	line, e = b.ReadString('\n')
	log.Println(line[:20])
	c.Assert(e, IsNil)
	line, e = b.ReadString('\n')
	c.Assert(e, Equals, io.EOF)

}