| 1 |
// Copyright ©2013 The bíogo Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package bam |
| 6 |
|
| 7 |
import ( |
| 8 |
"bytes" |
| 9 |
"compress/gzip" |
| 10 |
"flag" |
| 11 |
"fmt" |
| 12 |
"io" |
| 13 |
"os" |
| 14 |
"reflect" |
| 15 |
"testing" |
| 16 |
"time" |
| 17 |
|
| 18 |
"github.com/biogo/hts/bgzf" |
| 19 |
"github.com/biogo/hts/bgzf/index" |
| 20 |
"github.com/biogo/hts/internal" |
| 21 |
"github.com/biogo/hts/sam" |
| 22 |
|
| 23 |
"gopkg.in/check.v1" |
| 24 |
) |
| 25 |
|
| 26 |
var ( |
| 27 |
bam = flag.Bool("bam", false, "output failing bam data for inspection") |
| 28 |
allbam = flag.Bool("allbam", false, "output all bam data for inspection") |
| 29 |
) |
| 30 |
|
| 31 |
type failure bool |
| 32 |
|
| 33 |
func (f failure) String() string { |
| 34 |
if f { |
| 35 |
return "fail" |
| 36 |
} |
| 37 |
return "ok" |
| 38 |
} |
| 39 |
|
| 40 |
func clonedRefs(refs []*sam.Reference) []*sam.Reference { |
| 41 |
c := make([]*sam.Reference, len(refs)) |
| 42 |
for i, r := range refs { |
| 43 |
c[i] = r.Clone() |
| 44 |
} |
| 45 |
return c |
| 46 |
} |
| 47 |
|
| 48 |
func clonedRGs(rgs []*sam.ReadGroup) []*sam.ReadGroup { |
| 49 |
c := make([]*sam.ReadGroup, len(rgs)) |
| 50 |
for i, r := range rgs { |
| 51 |
c[i] = r.Clone() |
| 52 |
} |
| 53 |
return c |
| 54 |
} |
| 55 |
|
| 56 |
func clonedProgs(progs []*sam.Program) []*sam.Program { |
| 57 |
c := make([]*sam.Program, len(progs)) |
| 58 |
for i, p := range progs { |
| 59 |
c[i] = p.Clone() |
| 60 |
} |
| 61 |
return c |
| 62 |
} |
| 63 |
|
| 64 |
func Test(t *testing.T) { check.TestingT(t) } |
| 65 |
|
| 66 |
type S struct{} |
| 67 |
|
| 68 |
var _ = check.Suite(&S{}) |
| 69 |
|
| 70 |
const maxInt = int(^uint(0) >> 1) |
| 71 |
|
| 72 |
var ( |
| 73 |
file = flag.String("bench.file", "", "file to read for benchmarking") |
| 74 |
findex = flag.String("bench.index", "", "index file to read for benchmarking") |
| 75 |
conc = flag.Int("conc", 1, "sets the level of concurrency for compression") |
| 76 |
) |
| 77 |
|
| 78 |
func (s *S) TestRead(c *check.C) { |
| 79 |
for i, t := range []struct { |
| 80 |
in []byte |
| 81 |
header *sam.Header |
| 82 |
lines int |
| 83 |
}{ |
| 84 |
{ |
| 85 |
in: bamHG00096_1000, |
| 86 |
header: headerHG00096_1000, |
| 87 |
lines: 1000, |
| 88 |
}, |
| 89 |
} { |
| 90 |
for omit := None; omit <= AllVariableLengthData; omit++ { |
| 91 |
br, err := NewReader(bytes.NewBuffer(t.in), *conc) |
| 92 |
c.Assert(err, check.Equals, nil) |
| 93 |
|
| 94 |
c.Check(br.Header().Version, check.Equals, t.header.Version) |
| 95 |
c.Check(br.Header().SortOrder, check.Equals, t.header.SortOrder) |
| 96 |
c.Check(br.Header().GroupOrder, check.Equals, t.header.GroupOrder) |
| 97 |
c.Check(br.Header().Comments, check.DeepEquals, t.header.Comments) |
| 98 |
c.Check(clonedRefs(br.Header().Refs()), check.DeepEquals, clonedRefs(t.header.Refs())) |
| 99 |
c.Check(clonedRGs(br.Header().RGs()), check.DeepEquals, clonedRGs(t.header.RGs())) |
| 100 |
c.Check(clonedProgs(br.Header().Progs()), check.DeepEquals, clonedProgs(t.header.Progs())) |
| 101 |
|
| 102 |
var lines int |
| 103 |
for { |
| 104 |
_, err := br.Read() |
| 105 |
if err != nil { |
| 106 |
c.Assert(err, check.Equals, io.EOF) |
| 107 |
break |
| 108 |
} |
| 109 |
lines++ |
| 110 |
} |
| 111 |
c.Check(lines, check.Equals, t.lines, |
| 112 |
check.Commentf("got:%d expected:%d when omit=%d", lines, t.lines, omit)) |
| 113 |
if ok := reflect.DeepEqual(br.Header(), t.header) && lines == t.lines; *bam && !ok || *allbam { |
| 114 |
bf, err := os.Create(fmt.Sprintf("read-%d-%s.bam", i, failure(!ok))) |
| 115 |
c.Assert(err, check.Equals, nil) |
| 116 |
bf.Write(t.in) |
| 117 |
bf.Close() |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
func headerText(h *sam.Header) []byte { |
| 124 |
b, _ := h.MarshalText() |
| 125 |
return b |
| 126 |
} |
| 127 |
|
| 128 |
func (s *S) TestRoundTrip(c *check.C) { |
| 129 |
for i, t := range []struct { |
| 130 |
in []byte |
| 131 |
header *sam.Header |
| 132 |
conc int |
| 133 |
lines int |
| 134 |
}{ |
| 135 |
{ |
| 136 |
in: bamHG00096_1000, |
| 137 |
header: headerHG00096_1000, |
| 138 |
conc: 2, |
| 139 |
lines: 1000, |
| 140 |
}, |
| 141 |
} { |
| 142 |
br, err := NewReader(bytes.NewBuffer(t.in), *conc) |
| 143 |
c.Assert(err, check.Equals, nil) |
| 144 |
|
| 145 |
var buf bytes.Buffer |
| 146 |
bw, err := NewWriter(&buf, br.Header().Clone(), t.conc) |
| 147 |
for { |
| 148 |
r, err := br.Read() |
| 149 |
if err != nil { |
| 150 |
c.Assert(err, check.Equals, io.EOF) |
| 151 |
break |
| 152 |
} |
| 153 |
bw.Write(r) |
| 154 |
} |
| 155 |
c.Assert(bw.Close(), check.Equals, nil) |
| 156 |
|
| 157 |
br, err = NewReader(bytes.NewBuffer(t.in), *conc) |
| 158 |
c.Assert(err, check.Equals, nil) |
| 159 |
brr, err := NewReader(&buf, *conc) |
| 160 |
c.Assert(err, check.Equals, nil) |
| 161 |
c.Check(headerText(brr.Header()), check.DeepEquals, headerText(br.Header())) |
| 162 |
c.Check(brr.Header(), check.DeepEquals, br.Header()) |
| 163 |
if !reflect.DeepEqual(brr.Header(), br.Header()) { |
| 164 |
c.Check(brr.Header().Refs(), check.DeepEquals, br.Header().Refs()) |
| 165 |
c.Check(brr.Header().RGs(), check.DeepEquals, br.Header().RGs()) |
| 166 |
c.Check(brr.Header().Progs(), check.DeepEquals, br.Header().Progs()) |
| 167 |
c.Check(brr.Header().Comments, check.DeepEquals, br.Header().Comments) |
| 168 |
} |
| 169 |
allOK := true |
| 170 |
for { |
| 171 |
r, err := br.Read() |
| 172 |
if err != nil { |
| 173 |
c.Assert(err, check.Equals, io.EOF) |
| 174 |
} |
| 175 |
rr, err := brr.Read() |
| 176 |
if err != nil { |
| 177 |
c.Assert(err, check.Equals, io.EOF) |
| 178 |
break |
| 179 |
} |
| 180 |
c.Check(rr, check.DeepEquals, r) |
| 181 |
if !reflect.DeepEqual(rr, r) { |
| 182 |
allOK = false |
| 183 |
} |
| 184 |
} |
| 185 |
if ok := reflect.DeepEqual(br.Header(), brr.Header()) && allOK; *bam && !ok || *allbam { |
| 186 |
bf, err := os.Create(fmt.Sprintf("roundtrip-%d-%s.bam", i, failure(!ok))) |
| 187 |
c.Assert(err, check.Equals, nil) |
| 188 |
bf.Write(t.in) |
| 189 |
bf.Close() |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
func BenchmarkRead(b *testing.B) { |
| 195 |
if *file == "" { |
| 196 |
b.Skip("no file specified") |
| 197 |
} |
| 198 |
b.StopTimer() |
| 199 |
f, err := os.Open(*file) |
| 200 |
if err != nil { |
| 201 |
b.Fatalf("Open failed: %v", err) |
| 202 |
} |
| 203 |
br, err := NewReader(f, *conc) |
| 204 |
if err != nil { |
| 205 |
b.Fatalf("NewReader failed: %v", err) |
| 206 |
} |
| 207 |
b.StartTimer() |
| 208 |
|
| 209 |
for i := 0; i < b.N; i++ { |
| 210 |
for { |
| 211 |
_, err := br.Read() |
| 212 |
if err != nil { |
| 213 |
break |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
f.Close() |
| 218 |
} |
| 219 |
|
| 220 |
func BenchmarkReadIndex(b *testing.B) { |
| 221 |
if *findex == "" { |
| 222 |
b.Skip("no index file specified") |
| 223 |
} |
| 224 |
buf, err := os.ReadFile(*findex) |
| 225 |
if err != nil { |
| 226 |
b.Fatalf("Index read failed: %v", err) |
| 227 |
} |
| 228 |
r := bytes.NewReader(buf) |
| 229 |
|
| 230 |
b.ResetTimer() |
| 231 |
for i := 0; i < b.N; i++ { |
| 232 |
r.Seek(0, io.SeekStart) |
| 233 |
_, err = ReadIndex(r) |
| 234 |
if err != nil { |
| 235 |
b.Fatal(err) |
| 236 |
} |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
func BenchmarkReadCoreAndSeq(b *testing.B) { |
| 241 |
if *file == "" { |
| 242 |
b.Skip("no file specified") |
| 243 |
} |
| 244 |
b.StopTimer() |
| 245 |
f, err := os.Open(*file) |
| 246 |
if err != nil { |
| 247 |
b.Fatalf("Open failed: %v", err) |
| 248 |
} |
| 249 |
br, err := NewReader(f, *conc) |
| 250 |
if err != nil { |
| 251 |
b.Fatalf("NewReader failed: %v", err) |
| 252 |
} |
| 253 |
b.StartTimer() |
| 254 |
|
| 255 |
br.Omit(AuxTags) |
| 256 |
for i := 0; i < b.N; i++ { |
| 257 |
for { |
| 258 |
_, err := br.Read() |
| 259 |
if err != nil { |
| 260 |
break |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
f.Close() |
| 265 |
} |
| 266 |
|
| 267 |
func BenchmarkReadCoreOnly(b *testing.B) { |
| 268 |
if *file == "" { |
| 269 |
b.Skip("no file specified") |
| 270 |
} |
| 271 |
b.StopTimer() |
| 272 |
f, err := os.Open(*file) |
| 273 |
if err != nil { |
| 274 |
b.Fatalf("Open failed: %v", err) |
| 275 |
} |
| 276 |
br, err := NewReader(f, *conc) |
| 277 |
if err != nil { |
| 278 |
b.Fatalf("NewReader failed: %v", err) |
| 279 |
} |
| 280 |
b.StartTimer() |
| 281 |
|
| 282 |
br.Omit(AllVariableLengthData) |
| 283 |
for i := 0; i < b.N; i++ { |
| 284 |
for { |
| 285 |
_, err := br.Read() |
| 286 |
if err != nil { |
| 287 |
break |
| 288 |
} |
| 289 |
} |
| 290 |
} |
| 291 |
f.Close() |
| 292 |
} |
| 293 |
|
| 294 |
func BenchmarkWrite(b *testing.B) { |
| 295 |
b.StopTimer() |
| 296 |
br, err := NewReader(bytes.NewReader(bamHG00096_1000), *conc) |
| 297 |
if err != nil { |
| 298 |
b.Fatalf("NewReader failed: %v", err) |
| 299 |
} |
| 300 |
r, err := br.Read() |
| 301 |
if err != nil { |
| 302 |
b.Fatalf("Read failed: %v", err) |
| 303 |
} |
| 304 |
bw, err := NewWriter(io.Discard, br.Header().Clone(), *conc) |
| 305 |
if err != nil { |
| 306 |
b.Fatalf("NewWriter failed: %v", err) |
| 307 |
} |
| 308 |
b.StartTimer() |
| 309 |
|
| 310 |
for i := 0; i < b.N; i++ { |
| 311 |
err = bw.Write(r) |
| 312 |
if err != nil { |
| 313 |
b.Fatalf("Write failed: %v", err) |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
func BenchmarkReadFile(b *testing.B) { |
| 319 |
if *file == "" { |
| 320 |
b.Skip("no file specified") |
| 321 |
} |
| 322 |
|
| 323 |
for i := 0; i < b.N; i++ { |
| 324 |
f, err := os.Open(*file) |
| 325 |
if err != nil { |
| 326 |
b.Fatalf("Open failed: %v", err) |
| 327 |
} |
| 328 |
br, err := NewReader(f, *conc) |
| 329 |
if err != nil { |
| 330 |
b.Fatalf("NewReader failed: %v", err) |
| 331 |
} |
| 332 |
for { |
| 333 |
_, err := br.Read() |
| 334 |
if err != nil { |
| 335 |
break |
| 336 |
} |
| 337 |
} |
| 338 |
f.Close() |
| 339 |
} |
| 340 |
} |
| 341 |
|
| 342 |
// The is to comparable to `time samtools view -b $file > /dev/null'. |
| 343 |
func BenchmarkRoundtripFile(b *testing.B) { |
| 344 |
if *file == "" { |
| 345 |
b.Skip("no file specified") |
| 346 |
} |
| 347 |
|
| 348 |
for i := 0; i < b.N; i++ { |
| 349 |
f, err := os.Open(*file) |
| 350 |
if err != nil { |
| 351 |
b.Fatalf("Open failed: %v", err) |
| 352 |
} |
| 353 |
br, err := NewReader(f, *conc) |
| 354 |
if err != nil { |
| 355 |
b.Fatalf("NewReader failed: %v", err) |
| 356 |
} |
| 357 |
bw, err := NewWriter(io.Discard, br.Header().Clone(), *conc) |
| 358 |
if err != nil { |
| 359 |
b.Fatalf("NewWriter failed: %v", err) |
| 360 |
} |
| 361 |
for { |
| 362 |
r, err := br.Read() |
| 363 |
if err != nil { |
| 364 |
break |
| 365 |
} |
| 366 |
err = bw.Write(r) |
| 367 |
if err != nil { |
| 368 |
b.Fatalf("Write failed: %v", err) |
| 369 |
} |
| 370 |
} |
| 371 |
f.Close() |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
func (s *S) TestSpecExamples(c *check.C) { |
| 376 |
br, err := NewReader(bytes.NewReader(specExamples.data), *conc) |
| 377 |
c.Assert(err, check.Equals, nil) |
| 378 |
bh := br.Header() |
| 379 |
c.Check(bh.Version, check.Equals, specExamples.header.Version) |
| 380 |
c.Check(bh.SortOrder, check.Equals, specExamples.header.SortOrder) |
| 381 |
c.Check(bh.GroupOrder, check.Equals, specExamples.header.GroupOrder) |
| 382 |
c.Check(bh.Comments, check.DeepEquals, specExamples.header.Comments) |
| 383 |
for i, expect := range specExamples.records { |
| 384 |
r, err := br.Read() |
| 385 |
if err != nil { |
| 386 |
c.Errorf("Unexpected early error: %v", err) |
| 387 |
} |
| 388 |
c.Check(r.Name, check.Equals, expect.Name) |
| 389 |
c.Check(r.Pos, check.Equals, expect.Pos) // Zero-based here. |
| 390 |
c.Check(r.Flags, check.Equals, expect.Flags) |
| 391 |
if r.Flags&sam.Unmapped == 0 { |
| 392 |
c.Check(r.Ref, check.Not(check.Equals), nil) |
| 393 |
if r.Ref != nil { |
| 394 |
c.Check(r.Ref.Name(), check.Equals, bh.Refs()[0].Name()) |
| 395 |
} |
| 396 |
} else { |
| 397 |
c.Check(r.Ref, check.Equals, nil) |
| 398 |
} |
| 399 |
c.Check(r.MatePos, check.Equals, expect.MatePos) // Zero-based here. |
| 400 |
c.Check(r.Cigar, check.DeepEquals, expect.Cigar) |
| 401 |
c.Check(r.Cigar.IsValid(r.Seq.Length), check.Equals, true) |
| 402 |
c.Check(r.TempLen, check.Equals, expect.TempLen) |
| 403 |
c.Check(r.Seq, check.DeepEquals, expect.Seq, check.Commentf("got:%q expected:%q", r.Seq.Expand(), expect.Seq.Expand())) |
| 404 |
c.Check(r.Qual, check.DeepEquals, expect.Qual) // No valid qualities here. |
| 405 |
c.Check(r.End(), check.Equals, specExamples.readEnds[i], check.Commentf("unexpected end position for %q at %v, got:%d expected:%d", r.Name, r.Pos, r.End(), specExamples.readEnds[i])) |
| 406 |
c.Check(r.AuxFields, check.DeepEquals, expect.AuxFields) |
| 407 |
|
| 408 |
parsedCigar, err := sam.ParseCigar([]byte(specExamples.cigars[i])) |
| 409 |
c.Check(err, check.Equals, nil) |
| 410 |
c.Check(parsedCigar, check.DeepEquals, expect.Cigar) |
| 411 |
|
| 412 |
// In all the examples the last base of the read and the last |
| 413 |
// base of the ref are valid, so we can check this. |
| 414 |
expSeq := r.Seq.Expand() |
| 415 |
c.Check(specExamples.ref[r.End()-1], check.Equals, expSeq[len(expSeq)-1]) |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
func (s *S) TestSpecExamplesIterator(c *check.C) { |
| 420 |
br, err := NewReader(bytes.NewReader(specExamples.data), *conc) |
| 421 |
c.Assert(err, check.Equals, nil) |
| 422 |
it, err := NewIterator(br, nil) |
| 423 |
c.Assert(err, check.Equals, nil) |
| 424 |
i := 0 |
| 425 |
for ; it.Next(); i++ { |
| 426 |
expect := specExamples.records[i] |
| 427 |
r := it.Record() |
| 428 |
c.Check(r.Name, check.Equals, expect.Name) |
| 429 |
c.Check(r.Pos, check.Equals, expect.Pos) |
| 430 |
} |
| 431 |
c.Assert(i, check.Equals, len(specExamples.records)) |
| 432 |
c.Assert(it.Error(), check.Equals, nil) |
| 433 |
} |
| 434 |
|
| 435 |
func mustAux(a sam.Aux, err error) sam.Aux { |
| 436 |
if err != nil { |
| 437 |
panic(err) |
| 438 |
} |
| 439 |
return a |
| 440 |
} |
| 441 |
|
| 442 |
// The following data is the BAM file created from the following SAM using: |
| 443 |
// |
| 444 |
// samtools view -Sb spec-example.sam > spec-example.bam |
| 445 |
// |
| 446 |
// @HD VN:1.5 SO:coordinate |
| 447 |
// @SQ SN:ref LN:45 |
| 448 |
// @CO -------------------------------------------------------- |
| 449 |
// @CO Coor 12345678901234 5678901234567890123456789012345 |
| 450 |
// @CO ref AGCATGTTAGATAA**GATAGCTGTGCTAGTAGGCAGTCAGCGCCAT |
| 451 |
// @CO -------------------------------------------------------- |
| 452 |
// @CO +r001/1 TTAGATAAAGGATA*CTG |
| 453 |
// @CO +r002 aaaAGATAA*GGATA |
| 454 |
// @CO +r003 gcctaAGCTAA |
| 455 |
// @CO +r004 ATAGCT..............TCAGC |
| 456 |
// @CO -r003 ttagctTAGGC |
| 457 |
// @CO -r001/2 CAGCGGCAT |
| 458 |
// @CO -------------------------------------------------------- |
| 459 |
// r001 99 ref 7 30 8M2I4M1D3M = 37 39 TTAGATAAAGGATACTG * |
| 460 |
// r002 0 ref 9 30 3S6M1P1I4M * 0 0 AAAAGATAAGGATA * |
| 461 |
// r003 0 ref 9 30 5S6M * 0 0 GCCTAAGCTAA * SA:Z:ref,29,-,6H5M,17,0; |
| 462 |
// r004 0 ref 16 30 6M14N5M * 0 0 ATAGCTTCAGC * |
| 463 |
// r003 2064 ref 29 17 6H5M * 0 0 TAGGC * SA:Z:ref,9,+,5S6M,30,1; |
| 464 |
// r001 147 ref 37 30 9M = 7 -39 CAGCGGCAT * NM:i:1 |
| 465 |
var specExamples = struct { |
| 466 |
ref string |
| 467 |
data []byte |
| 468 |
header sam.Header |
| 469 |
records []*sam.Record |
| 470 |
cigars []string |
| 471 |
readEnds []int |
| 472 |
}{ |
| 473 |
ref: "AGCATGTTAGATAAGATAGCTGTGCTAGTAGGCAGTCAGCGCCAT", |
| 474 |
data: []byte{ |
| 475 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 476 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 477 |
0xf7, 0x00, 0xa5, 0x51, 0xcb, 0x0a, 0xc2, 0x30, |
| 478 |
0x10, 0x8c, 0xe2, 0x25, 0xfd, 0x8a, 0x9c, 0x2b, |
| 479 |
0x6a, 0x53, 0x5b, 0x1f, 0x3d, 0x75, 0x8d, 0x10, |
| 480 |
0x0f, 0x5a, 0x91, 0x06, 0xef, 0xa1, 0x56, 0xf1, |
| 481 |
0xa2, 0x50, 0xf2, 0xff, 0xb8, 0x4d, 0x5f, 0x0a, |
| 482 |
0xc5, 0x83, 0x0e, 0x49, 0x76, 0xc9, 0xce, 0x64, |
| 483 |
0x1f, 0xd9, 0xc0, 0x61, 0x90, 0x0f, 0x09, 0x89, |
| 484 |
0x77, 0x5b, 0x7a, 0x4e, 0x22, 0x3e, 0x0d, 0x69, |
| 485 |
0x7a, 0x8c, 0xb2, 0xe7, 0xb3, 0xb8, 0xdc, 0x1f, |
| 486 |
0xda, 0xe4, 0x4e, 0x9c, 0x9e, 0x68, 0x9a, 0x44, |
| 487 |
0x45, 0x7e, 0xa5, 0xfb, 0x24, 0x0a, 0x42, 0x27, |
| 488 |
0x16, 0x47, 0x3a, 0xf9, 0x11, 0x56, 0x2c, 0xf0, |
| 489 |
0x71, 0x56, 0x82, 0xfb, 0xf3, 0x20, 0x5c, 0x2c, |
| 490 |
0x57, 0x6b, 0xaf, 0xf4, 0x18, 0xeb, 0xfc, 0x5e, |
| 491 |
0xcf, 0x8a, 0xb1, 0x0e, 0xab, 0x65, 0x20, 0x05, |
| 492 |
0x28, 0xa9, 0x14, 0x48, 0x50, 0x00, 0xae, 0x5b, |
| 493 |
0x1a, 0x29, 0xf0, 0x06, 0x0f, 0x90, 0xb8, 0x30, |
| 494 |
0x2e, 0x15, 0x6e, 0x21, 0x05, 0x32, 0xff, 0x2f, |
| 495 |
0x7b, 0x5c, 0x78, 0x1e, 0x9f, 0x71, 0x56, 0xa3, |
| 496 |
0xc9, 0x8c, 0x89, 0xd0, 0xb8, 0x98, 0xb9, 0x65, |
| 497 |
0xf9, 0x0d, 0x87, 0x69, 0xad, 0xeb, 0xfa, 0x2c, |
| 498 |
0xab, 0x65, 0xcc, 0xeb, 0xf8, 0x2d, 0xcb, 0x8c, |
| 499 |
0x2e, 0xcb, 0x86, 0x2e, 0x16, 0xb0, 0x3e, 0x54, |
| 500 |
0xdd, 0x4d, 0x3f, 0x60, 0xbb, 0xab, 0x1a, 0x7b, |
| 501 |
0x7b, 0xb3, 0x17, 0xc6, 0xe8, 0x5b, 0x66, 0xec, |
| 502 |
0x54, 0x5a, 0x01, 0x9f, 0xf9, 0xdf, 0x24, 0xef, |
| 503 |
0xb0, 0x63, 0x94, 0x7f, 0x8f, 0x71, 0x40, 0x08, |
| 504 |
0x19, 0xe1, 0xc6, 0x4f, 0x24, 0x13, 0xb4, 0x2f, |
| 505 |
0x02, 0xfe, 0x37, 0xdf, 0x7d, 0x02, 0x00, 0x00, |
| 506 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 507 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 508 |
0x01, 0x01, 0x0b, 0x66, 0x80, 0x00, 0x36, 0x20, |
| 509 |
0x66, 0x95, 0xf3, 0x14, 0x62, 0x65, 0x48, 0x66, |
| 510 |
0x10, 0x84, 0x8a, 0xa9, 0x00, 0xb1, 0x3a, 0x10, |
| 511 |
0x17, 0x19, 0x18, 0x18, 0x32, 0x34, 0x00, 0x19, |
| 512 |
0x8a, 0x40, 0xec, 0x00, 0xc4, 0x42, 0x40, 0x6c, |
| 513 |
0x00, 0xc4, 0x1d, 0x22, 0x12, 0x82, 0x22, 0x8e, |
| 514 |
0x8d, 0x1a, 0x0e, 0xff, 0xd1, 0x81, 0x1f, 0xd4, |
| 515 |
0x08, 0x0e, 0xb8, 0xb1, 0x0c, 0x0c, 0x7c, 0x40, |
| 516 |
0x0c, 0x93, 0x67, 0x80, 0x18, 0x6b, 0xc4, 0x60, |
| 517 |
0x02, 0x64, 0x24, 0x00, 0xb1, 0x18, 0x10, 0x0b, |
| 518 |
0x42, 0x8d, 0x17, 0x14, 0x74, 0x6c, 0x04, 0x1a, |
| 519 |
0x8b, 0x6a, 0x62, 0x28, 0x9a, 0x89, 0x4c, 0x40, |
| 520 |
0x9a, 0x1b, 0xd3, 0x44, 0x63, 0x86, 0x10, 0xa8, |
| 521 |
0x89, 0x4e, 0x1a, 0x82, 0x4e, 0x8d, 0x02, 0x48, |
| 522 |
0x26, 0x04, 0x3b, 0x46, 0x15, 0xa5, 0xa6, 0xe9, |
| 523 |
0x18, 0x59, 0xea, 0xe8, 0xea, 0x98, 0x79, 0x98, |
| 524 |
0xfa, 0xea, 0x18, 0x9a, 0xeb, 0x18, 0x58, 0x33, |
| 525 |
0x38, 0x41, 0x0d, 0xe6, 0x87, 0x1a, 0xcc, 0x8c, |
| 526 |
0xdd, 0x60, 0x13, 0xb0, 0xa1, 0x8f, 0x81, 0x38, |
| 527 |
0x00, 0x88, 0x25, 0x44, 0x34, 0x9a, 0x44, 0x14, |
| 528 |
0x90, 0x0c, 0xf7, 0x86, 0x9a, 0x22, 0x03, 0x32, |
| 529 |
0x45, 0x10, 0xe4, 0x3c, 0x01, 0x0e, 0x56, 0x6c, |
| 530 |
0xce, 0x4b, 0x85, 0x9a, 0xd0, 0xe8, 0xa2, 0x80, |
| 531 |
0xec, 0x2a, 0x4b, 0x1d, 0x6d, 0x1d, 0xd3, 0x60, |
| 532 |
0x33, 0x5f, 0x1d, 0x63, 0x03, 0x1d, 0x43, 0x6b, |
| 533 |
0x06, 0x6b, 0xa4, 0x28, 0x00, 0x39, 0x8a, 0x91, |
| 534 |
0x61, 0x32, 0x03, 0x27, 0x52, 0x54, 0xdd, 0x04, |
| 535 |
0xea, 0x04, 0x47, 0xcb, 0x04, 0x50, 0xb4, 0x38, |
| 536 |
0xb9, 0x28, 0x36, 0x20, 0x82, 0xde, 0xd7, 0x99, |
| 537 |
0x11, 0x00, 0x9e, 0x55, 0xee, 0x4f, 0xd6, 0x01, |
| 538 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 539 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 540 |
0x02, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x00, 0x00, |
| 541 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 542 |
}, |
| 543 |
header: sam.Header{ |
| 544 |
Version: "1.5", |
| 545 |
SortOrder: sam.Coordinate, |
| 546 |
GroupOrder: sam.GroupUnspecified, |
| 547 |
Comments: []string{ |
| 548 |
"--------------------------------------------------------", |
| 549 |
"Coor 12345678901234 5678901234567890123456789012345", |
| 550 |
"ref AGCATGTTAGATAA**GATAGCTGTGCTAGTAGGCAGTCAGCGCCAT", |
| 551 |
"--------------------------------------------------------", |
| 552 |
"+r001/1 TTAGATAAAGGATA*CTG", |
| 553 |
"+r002 aaaAGATAA*GGATA", |
| 554 |
"+r003 gcctaAGCTAA", |
| 555 |
"+r004 ATAGCT..............TCAGC", |
| 556 |
"-r003 ttagctTAGGC", |
| 557 |
"-r001/2 CAGCGGCAT", |
| 558 |
"--------------------------------------------------------", |
| 559 |
}, |
| 560 |
}, |
| 561 |
records: []*sam.Record{ |
| 562 |
{ |
| 563 |
Name: "r001", |
| 564 |
Pos: 6, |
| 565 |
MapQ: 30, |
| 566 |
Cigar: sam.Cigar{ |
| 567 |
sam.NewCigarOp(sam.CigarMatch, 8), |
| 568 |
sam.NewCigarOp(sam.CigarInsertion, 2), |
| 569 |
sam.NewCigarOp(sam.CigarMatch, 4), |
| 570 |
sam.NewCigarOp(sam.CigarDeletion, 1), |
| 571 |
sam.NewCigarOp(sam.CigarMatch, 3), |
| 572 |
}, |
| 573 |
Flags: sam.Paired | sam.ProperPair | sam.MateReverse | sam.Read1, |
| 574 |
MatePos: 36, |
| 575 |
TempLen: 39, |
| 576 |
Seq: sam.NewSeq([]byte("TTAGATAAAGGATACTG")), |
| 577 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
| 578 |
}, |
| 579 |
{ |
| 580 |
Name: "r002", |
| 581 |
Pos: 8, |
| 582 |
MapQ: 30, |
| 583 |
Cigar: sam.Cigar{ |
| 584 |
sam.NewCigarOp(sam.CigarSoftClipped, 3), |
| 585 |
sam.NewCigarOp(sam.CigarMatch, 6), |
| 586 |
sam.NewCigarOp(sam.CigarPadded, 1), |
| 587 |
sam.NewCigarOp(sam.CigarInsertion, 1), |
| 588 |
sam.NewCigarOp(sam.CigarMatch, 4), |
| 589 |
}, |
| 590 |
MatePos: -1, |
| 591 |
TempLen: 0, |
| 592 |
Seq: sam.NewSeq([]byte("AAAAGATAAGGATA")), |
| 593 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
| 594 |
}, |
| 595 |
{ |
| 596 |
Name: "r003", |
| 597 |
Pos: 8, |
| 598 |
MapQ: 30, |
| 599 |
Cigar: sam.Cigar{ |
| 600 |
sam.NewCigarOp(sam.CigarSoftClipped, 5), |
| 601 |
sam.NewCigarOp(sam.CigarMatch, 6), |
| 602 |
}, |
| 603 |
MatePos: -1, |
| 604 |
TempLen: 0, |
| 605 |
Seq: sam.NewSeq([]byte("GCCTAAGCTAA")), |
| 606 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
| 607 |
AuxFields: []sam.Aux{ |
| 608 |
mustAux(sam.NewAux(sam.NewTag("SA"), "ref,29,-,6H5M,17,0;")), |
| 609 |
}, |
| 610 |
}, |
| 611 |
{ |
| 612 |
Name: "r004", |
| 613 |
Pos: 15, |
| 614 |
MapQ: 30, |
| 615 |
Cigar: sam.Cigar{ |
| 616 |
sam.NewCigarOp(sam.CigarMatch, 6), |
| 617 |
sam.NewCigarOp(sam.CigarSkipped, 14), |
| 618 |
sam.NewCigarOp(sam.CigarMatch, 5), |
| 619 |
}, |
| 620 |
MatePos: -1, |
| 621 |
TempLen: 0, |
| 622 |
Seq: sam.NewSeq([]byte("ATAGCTTCAGC")), |
| 623 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
| 624 |
}, |
| 625 |
{ |
| 626 |
Name: "r003", |
| 627 |
Pos: 28, |
| 628 |
MapQ: 17, |
| 629 |
Cigar: sam.Cigar{ |
| 630 |
sam.NewCigarOp(sam.CigarHardClipped, 6), |
| 631 |
sam.NewCigarOp(sam.CigarMatch, 5), |
| 632 |
}, |
| 633 |
Flags: sam.Reverse | sam.Supplementary, |
| 634 |
MatePos: -1, |
| 635 |
TempLen: 0, |
| 636 |
Seq: sam.NewSeq([]byte("TAGGC")), |
| 637 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff}, |
| 638 |
AuxFields: []sam.Aux{ |
| 639 |
mustAux(sam.NewAux(sam.NewTag("SA"), "ref,9,+,5S6M,30,1;")), |
| 640 |
}, |
| 641 |
}, |
| 642 |
{ |
| 643 |
Name: "r001", |
| 644 |
Pos: 36, |
| 645 |
MapQ: 30, |
| 646 |
Cigar: sam.Cigar{ |
| 647 |
sam.NewCigarOp(sam.CigarMatch, 9), |
| 648 |
}, |
| 649 |
Flags: sam.Paired | sam.ProperPair | sam.Reverse | sam.Read2, |
| 650 |
MatePos: 6, |
| 651 |
TempLen: -39, |
| 652 |
Seq: sam.NewSeq([]byte("CAGCGGCAT")), |
| 653 |
Qual: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
| 654 |
AuxFields: []sam.Aux{ |
| 655 |
mustAux(sam.NewAux(sam.NewTag("NM"), uint(1))), |
| 656 |
}, |
| 657 |
}, |
| 658 |
}, |
| 659 |
cigars: []string{ |
| 660 |
"8M2I4M1D3M", |
| 661 |
"3S6M1P1I4M", |
| 662 |
"5S6M", |
| 663 |
"6M14N5M", |
| 664 |
"6H5M", |
| 665 |
"9M", |
| 666 |
}, |
| 667 |
// These coordinates are all open (and zero-based) so that |
| 668 |
// a slice of the reference doesn't need any alteration. |
| 669 |
readEnds: []int{ |
| 670 |
22, |
| 671 |
18, |
| 672 |
14, |
| 673 |
40, |
| 674 |
33, |
| 675 |
45, |
| 676 |
}, |
| 677 |
} |
| 678 |
|
| 679 |
func (s *S) TestIssue3(c *check.C) { |
| 680 |
for _, test := range issue3 { |
| 681 |
br, err := NewReader(bytes.NewReader(test), *conc) |
| 682 |
c.Assert(err, check.Equals, nil, check.Commentf("Failed to open BAM")) |
| 683 |
|
| 684 |
for { |
| 685 |
_, err := br.Read() |
| 686 |
if err != nil { |
| 687 |
c.Check(err, check.Equals, io.EOF) |
| 688 |
break |
| 689 |
} |
| 690 |
} |
| 691 |
} |
| 692 |
} |
| 693 |
|
| 694 |
var issue3 = [][]byte{ |
| 695 |
// Specific case posted at https://code.google.com/p/biogo/issues/detail?id=3#c6 |
| 696 |
// edited to a minimal reproducer. |
| 697 |
{ |
| 698 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 699 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 700 |
0x61, 0x00, 0x73, 0x72, 0xf4, 0x65, 0x34, 0x62, |
| 701 |
0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, 0x0c, 0xf3, |
| 702 |
0xb3, 0x32, 0xd4, 0x33, 0xe0, 0x0c, 0xf6, 0xb7, |
| 703 |
0x4a, 0xce, 0xcf, 0x2f, 0x4a, 0xc9, 0xcc, 0x4b, |
| 704 |
0x2c, 0x49, 0xe5, 0x72, 0x08, 0x0e, 0xe4, 0x0c, |
| 705 |
0xf6, 0xb3, 0x8a, 0x2a, 0xb3, 0x8c, 0xf7, 0x73, |
| 706 |
0x34, 0x34, 0xe0, 0xf4, 0xf1, 0xb3, 0x32, 0xb1, |
| 707 |
0x30, 0x30, 0x33, 0xe2, 0x62, 0x04, 0xea, 0xe2, |
| 708 |
0x04, 0x62, 0x98, 0x0c, 0xc3, 0xbe, 0xdd, 0x0c, |
| 709 |
0x0c, 0x00, 0xaa, 0x89, 0xab, 0xc2, 0x4f, 0x00, |
| 710 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 711 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 712 |
0x02, 0x00, 0xa2, 0x00, 0x9b, 0xc5, 0x00, 0x01, |
| 713 |
0xb3, 0xa5, 0x19, 0x18, 0xf8, 0x19, 0x3c, 0x85, |
| 714 |
0x18, 0x19, 0x18, 0x18, 0x25, 0x81, 0xfc, 0xff, |
| 715 |
0x50, 0x00, 0x92, 0x33, 0x34, 0x28, 0x30, 0x30, |
| 716 |
0xcc, 0x4a, 0x4b, 0xce, 0x53, 0x76, 0x76, 0x76, |
| 717 |
0x0f, 0x61, 0x98, 0x00, 0x54, 0x23, 0xd4, 0x01, |
| 718 |
0x05, 0x4a, 0x1d, 0x1d, 0x0d, 0xaa, 0xca, 0xca, |
| 719 |
0xca, 0x8a, 0xaa, 0xea, 0xea, 0xea, 0x1a, 0x9a, |
| 720 |
0x9a, 0x9a, 0x1a, 0x40, 0x52, 0x55, 0x59, 0x51, |
| 721 |
0x45, 0x55, 0x55, 0x45, 0xc9, 0x31, 0x38, 0xf9, |
| 722 |
0x77, 0x84, 0x9f, 0x33, 0x43, 0x84, 0xaf, 0x33, |
| 723 |
0x63, 0x84, 0x3f, 0x90, 0x76, 0x77, 0x66, 0xf0, |
| 724 |
0x03, 0xb2, 0x7d, 0x5d, 0xa2, 0x8c, 0x8c, 0x1d, |
| 725 |
0x0d, 0x19, 0x22, 0x43, 0xa2, 0x42, 0x43, 0x19, |
| 726 |
0xfc, 0x3c, 0x9c, 0x45, 0x9c, 0x9d, 0xa3, 0x92, |
| 727 |
0x33, 0x8a, 0x0c, 0x19, 0x9c, 0x03, 0x3c, 0xf7, |
| 728 |
0x9a, 0x3f, 0x67, 0x8a, 0x08, 0x76, 0xd4, 0xf6, |
| 729 |
0xf0, 0x74, 0x66, 0x00, 0x00, 0xa6, 0xdc, 0x77, |
| 730 |
0x77, 0x9e, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, |
| 731 |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, |
| 732 |
0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, |
| 733 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 734 |
0x00, |
| 735 |
}, |
| 736 |
|
| 737 |
// More general testing: sequence lengths range from 19 to 26 inclusive. |
| 738 |
{ |
| 739 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 740 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 741 |
0x61, 0x00, 0x73, 0x72, 0xf4, 0x65, 0x34, 0x62, |
| 742 |
0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, 0x0c, 0xf3, |
| 743 |
0xb3, 0x32, 0xd4, 0x33, 0xe0, 0x0c, 0xf6, 0xb7, |
| 744 |
0x4a, 0xce, 0xcf, 0x2f, 0x4a, 0xc9, 0xcc, 0x4b, |
| 745 |
0x2c, 0x49, 0xe5, 0x72, 0x08, 0x0e, 0xe4, 0x0c, |
| 746 |
0xf6, 0xb3, 0x8a, 0x2a, 0xb3, 0x8c, 0xf7, 0x73, |
| 747 |
0x34, 0x34, 0xe0, 0xf4, 0xf1, 0xb3, 0x32, 0xb1, |
| 748 |
0x30, 0x30, 0x33, 0xe2, 0x62, 0x04, 0xea, 0xe2, |
| 749 |
0x04, 0x62, 0x98, 0x0c, 0xc3, 0xbe, 0xdd, 0x0c, |
| 750 |
0x0c, 0x00, 0xaa, 0x89, 0xab, 0xc2, 0x4f, 0x00, |
| 751 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 752 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 753 |
0x02, 0x00, 0x12, 0x01, 0x9b, 0xc8, 0x00, 0x01, |
| 754 |
0xb3, 0xa5, 0x19, 0x18, 0xf8, 0x19, 0x3c, 0x85, |
| 755 |
0x18, 0x19, 0x18, 0x18, 0x85, 0x81, 0xfc, 0xff, |
| 756 |
0x50, 0x00, 0x92, 0x33, 0x34, 0x28, 0x30, 0x30, |
| 757 |
0xcc, 0x4a, 0x4b, 0xce, 0x53, 0x76, 0x76, 0x76, |
| 758 |
0x0f, 0x61, 0x30, 0x00, 0xaa, 0x11, 0xea, 0x80, |
| 759 |
0x02, 0x05, 0x55, 0x65, 0x65, 0x65, 0x45, 0x55, |
| 760 |
0x75, 0x75, 0x75, 0x0d, 0x4d, 0x4d, 0x4d, 0x0d, |
| 761 |
0x20, 0xa9, 0xaa, 0xec, 0x18, 0x9c, 0xfc, 0x3b, |
| 762 |
0xc2, 0xcf, 0x99, 0x21, 0xc2, 0xd7, 0x99, 0x31, |
| 763 |
0xc2, 0x1f, 0x48, 0xbb, 0x3b, 0x33, 0xf8, 0x01, |
| 764 |
0xd9, 0xbe, 0x2e, 0x51, 0x46, 0xc6, 0x8e, 0x86, |
| 765 |
0x0c, 0x91, 0x21, 0x51, 0xa1, 0xa1, 0x0c, 0x7e, |
| 766 |
0x1e, 0xce, 0x22, 0xce, 0xce, 0x51, 0xc9, 0x19, |
| 767 |
0x45, 0x86, 0x0c, 0xce, 0x01, 0x9e, 0x7b, 0xcd, |
| 768 |
0x9f, 0x33, 0x45, 0x04, 0x3b, 0x6a, 0x7b, 0x78, |
| 769 |
0x3a, 0x33, 0x4c, 0xc2, 0xe2, 0x28, 0x11, 0xfc, |
| 770 |
0x8e, 0x72, 0x40, 0x76, 0x94, 0x12, 0x16, 0x47, |
| 771 |
0x29, 0x52, 0xec, 0xaa, 0x29, 0x58, 0x5c, 0x25, |
| 772 |
0x8a, 0xdf, 0x55, 0x01, 0x28, 0xae, 0x6a, 0xc0, |
| 773 |
0xe6, 0x2c, 0x15, 0x8a, 0xdd, 0x35, 0x15, 0x8b, |
| 774 |
0xbb, 0xc4, 0xf0, 0xbb, 0x2b, 0x01, 0xc5, 0x5d, |
| 775 |
0x1d, 0x58, 0xdd, 0xa5, 0x4a, 0xb1, 0xc3, 0xa6, |
| 776 |
0x63, 0x71, 0x98, 0x38, 0x7e, 0x87, 0x15, 0xa0, |
| 777 |
0x3a, 0x0c, 0x7b, 0x88, 0xa9, 0x52, 0xee, 0xb4, |
| 778 |
0x19, 0x58, 0x9c, 0x26, 0x81, 0xdf, 0x69, 0x0d, |
| 779 |
0xa8, 0x4e, 0xc3, 0x11, 0x68, 0xaa, 0x94, 0xc7, |
| 780 |
0xe7, 0x2c, 0x2c, 0x6e, 0x93, 0xc4, 0xef, 0xb6, |
| 781 |
0x09, 0x68, 0x6e, 0xc3, 0x15, 0x6e, 0x2a, 0x4a, |
| 782 |
0x14, 0xbb, 0x6e, 0x36, 0x16, 0xd7, 0x49, 0xe1, |
| 783 |
0x77, 0xdd, 0x02, 0x34, 0xd7, 0xe1, 0x0c, 0x3a, |
| 784 |
0x25, 0xca, 0x9d, 0x07, 0x00, 0x31, 0x91, 0x24, |
| 785 |
0x5a, 0xd0, 0x04, 0x00, 0x00, 0x1f, 0x8b, 0x08, |
| 786 |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, |
| 787 |
0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, |
| 788 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 789 |
0x00, |
| 790 |
}, |
| 791 |
} |
| 792 |
|
| 793 |
func (s *S) TestIssue11(c *check.C) { |
| 794 |
for _, test := range issue11 { |
| 795 |
br, err := NewReader(bytes.NewReader(test.input), *conc) |
| 796 |
c.Check(err, check.Equals, nil) |
| 797 |
c.Check(br.Header().GroupOrder, check.Equals, test.expect) |
| 798 |
} |
| 799 |
} |
| 800 |
|
| 801 |
var issue11 = []struct { |
| 802 |
input []byte |
| 803 |
expect sam.GroupOrder |
| 804 |
}{ |
| 805 |
{ |
| 806 |
// 1000 genomes file hand edited to reduce number of Refs and reads; |
| 807 |
// no specified group ordering. |
| 808 |
input: []byte{ |
| 809 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 810 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 811 |
0xec, 0x01, 0xad, 0x92, 0xcd, 0x8e, 0xda, 0x30, |
| 812 |
0x10, 0xc7, 0xb3, 0xdd, 0x93, 0x79, 0x8a, 0x1c, |
| 813 |
0x38, 0xb4, 0x07, 0x1c, 0xe7, 0xc3, 0x81, 0x58, |
| 814 |
0xaa, 0xc4, 0x97, 0x04, 0x48, 0x21, 0x9b, 0x12, |
| 815 |
0xd1, 0x6a, 0x4f, 0x91, 0x93, 0xd8, 0xc1, 0x5a, |
| 816 |
0xe3, 0x00, 0x0e, 0xd0, 0xf6, 0x0d, 0xfa, 0xc4, |
| 817 |
0xbd, 0x55, 0x35, 0xd1, 0xb6, 0x5d, 0xb5, 0x3d, |
| 818 |
0xee, 0xc1, 0x23, 0xfb, 0x3f, 0x33, 0xbf, 0x19, |
| 819 |
0xdb, 0x33, 0x9d, 0xac, 0xef, 0xb2, 0x7b, 0xcb, |
| 820 |
0x1a, 0x2f, 0xe7, 0xe0, 0x63, 0x42, 0x5c, 0x88, |
| 821 |
0x40, 0xf6, 0x40, 0xca, 0xa6, 0x39, 0x55, 0x42, |
| 822 |
0xd1, 0x96, 0xf5, 0xc6, 0xd9, 0x07, 0x90, 0x25, |
| 823 |
0xe4, 0x11, 0xc4, 0x09, 0xc1, 0x91, 0x3f, 0xf4, |
| 824 |
0x71, 0x18, 0x82, 0x35, 0x26, 0x2e, 0xa7, 0x7e, |
| 825 |
0x30, 0x0c, 0x86, 0x18, 0x51, 0x8e, 0xa2, 0x60, |
| 826 |
0x54, 0x54, 0x3c, 0x1a, 0x56, 0x98, 0x22, 0xc6, |
| 827 |
0xb0, 0xc7, 0xb0, 0x0b, 0xb6, 0x1b, 0xc2, 0xdb, |
| 828 |
0x03, 0x71, 0x1c, 0x63, 0xa1, 0x8b, 0x10, 0xaa, |
| 829 |
0x99, 0x6a, 0xf6, 0x4c, 0x43, 0x56, 0x08, 0x48, |
| 830 |
0x4b, 0x78, 0x7e, 0x72, 0x2e, 0x8d, 0x74, 0x6f, |
| 831 |
0x6e, 0xa7, 0x65, 0xe5, 0x4e, 0x89, 0x92, 0x4a, |
| 832 |
0xe7, 0xc4, 0x38, 0x3b, 0x31, 0x55, 0x32, 0xe7, |
| 833 |
0xb0, 0xa3, 0x9a, 0x79, 0xf9, 0x6f, 0x21, 0xa7, |
| 834 |
0x5a, 0xb3, 0x7d, 0x21, 0xbf, 0xe4, 0x9a, 0x1d, |
| 835 |
0xcf, 0x5d, 0xc8, 0x4e, 0xfb, 0xa6, 0x24, 0xe4, |
| 836 |
0x14, 0xd6, 0x5f, 0xc1, 0x24, 0x23, 0xc9, 0x6c, |
| 837 |
0xba, 0xf2, 0x87, 0x20, 0x4b, 0xc9, 0xf2, 0xbc, |
| 838 |
0xa7, 0xaa, 0x37, 0xde, 0x2c, 0xc0, 0x6a, 0x4e, |
| 839 |
0xb2, 0xcd, 0x06, 0x85, 0x5e, 0xe8, 0x07, 0x20, |
| 840 |
0x9e, 0x12, 0x6f, 0x14, 0xe0, 0x11, 0x0e, 0x47, |
| 841 |
0xd8, 0x5c, 0x74, 0x4d, 0x96, 0x0b, 0xd3, 0x58, |
| 842 |
0x14, 0x82, 0x74, 0x45, 0x3c, 0x14, 0x82, 0x59, |
| 843 |
0x42, 0x3e, 0x6d, 0x17, 0xd9, 0x0c, 0xa4, 0x31, |
| 844 |
0x59, 0xc5, 0xf1, 0x76, 0xbd, 0x4a, 0x26, 0x60, |
| 845 |
0x9e, 0x19, 0x42, 0x8a, 0x90, 0xeb, 0x45, 0xc1, |
| 846 |
0xdf, 0x48, 0xfc, 0xea, 0xc8, 0xc0, 0x7d, 0x0d, |
| 847 |
0x64, 0xda, 0x21, 0x8b, 0x2b, 0xcd, 0x85, 0xaa, |
| 848 |
0xd8, 0x67, 0x90, 0x26, 0xb7, 0xc3, 0xed, 0x87, |
| 849 |
0x11, 0xc4, 0x30, 0x1a, 0x9c, 0x5c, 0x83, 0x89, |
| 850 |
0x6f, 0x9a, 0xdd, 0x05, 0xd8, 0x03, 0x6a, 0x17, |
| 851 |
0xd7, 0x56, 0x5f, 0xed, 0xfe, 0x9f, 0x07, 0xe7, |
| 852 |
0x54, 0xb7, 0xf4, 0x25, 0x8b, 0x4a, 0xd5, 0x89, |
| 853 |
0xc7, 0x5f, 0xbc, 0x34, 0x7d, 0x51, 0xe3, 0x7f, |
| 854 |
0x70, 0x93, 0x61, 0x0f, 0x8e, 0xb6, 0x8b, 0xed, |
| 855 |
0x01, 0xb7, 0xfb, 0x9a, 0x8a, 0x9c, 0x0b, 0xc9, |
| 856 |
0xfe, 0x29, 0x62, 0xf7, 0x3b, 0x6c, 0xe7, 0xec, |
| 857 |
0x8d, 0x67, 0x0f, 0xa0, 0xff, 0xa4, 0x9a, 0xab, |
| 858 |
0xea, 0xc0, 0x52, 0x77, 0xf2, 0x5b, 0xfd, 0xce, |
| 859 |
0x7e, 0x6f, 0xbf, 0xc6, 0x44, 0xed, 0xe9, 0xe1, |
| 860 |
0x20, 0x54, 0x6d, 0x26, 0x4b, 0x37, 0xe7, 0x53, |
| 861 |
0xc9, 0xb4, 0x33, 0x89, 0x63, 0x78, 0xad, 0x35, |
| 862 |
0x7c, 0x2e, 0xb7, 0x17, 0xd2, 0xd8, 0x8a, 0x5d, |
| 863 |
0x84, 0x62, 0xf9, 0xae, 0x76, 0xa3, 0x5c, 0x32, |
| 864 |
0xde, 0x4e, 0xa4, 0xa8, 0x15, 0xab, 0xf2, 0xb2, |
| 865 |
0x91, 0x92, 0x1e, 0xb4, 0xd9, 0x55, 0xcd, 0xb9, |
| 866 |
0x90, 0x26, 0x42, 0xb4, 0xcf, 0x99, 0x50, 0x8b, |
| 867 |
0xd6, 0xb4, 0x73, 0x29, 0xb9, 0x19, 0xc8, 0xde, |
| 868 |
0x9d, 0x65, 0x59, 0x6f, 0xcc, 0x7a, 0xb4, 0x7e, |
| 869 |
0x7c, 0xff, 0x76, 0xff, 0x13, 0x01, 0xfd, 0x62, |
| 870 |
0x77, 0x69, 0x03, 0x00, 0x00, 0x1f, 0x8b, 0x08, |
| 871 |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, |
| 872 |
0x00, 0x42, 0x43, 0x02, 0x00, 0xcf, 0x00, 0x4d, |
| 873 |
0xce, 0x31, 0x6a, 0xc3, 0x30, 0x18, 0x05, 0x60, |
| 874 |
0x41, 0x0f, 0x50, 0xd2, 0x66, 0x30, 0x74, 0x88, |
| 875 |
0xab, 0x18, 0xeb, 0x59, 0xb2, 0xa5, 0xff, 0xb7, |
| 876 |
0xa9, 0x93, 0x8c, 0x32, 0x82, 0x6a, 0x76, 0xb6, |
| 877 |
0xce, 0x3d, 0x40, 0x2e, 0x90, 0x41, 0xc1, 0x83, |
| 878 |
0x73, 0xc1, 0xdc, 0xa4, 0x74, 0xad, 0x4b, 0xa0, |
| 879 |
0xf4, 0x5b, 0xde, 0xe3, 0x4d, 0xef, 0x26, 0xee, |
| 880 |
0xbe, 0xbe, 0xaf, 0x0f, 0xcf, 0xe2, 0x94, 0x0b, |
| 881 |
0x71, 0x16, 0x9f, 0xff, 0xb6, 0xdf, 0x3c, 0x8e, |
| 882 |
0x23, 0xf5, 0x6d, 0xdf, 0xbd, 0x59, 0x3e, 0xf4, |
| 883 |
0xdd, 0x6e, 0xdf, 0xb6, 0x62, 0xb8, 0xc8, 0xe8, |
| 884 |
0x63, 0x98, 0x57, 0x29, 0x44, 0x9f, 0xbc, 0x9c, |
| 885 |
0xa6, 0x4c, 0x66, 0xc5, 0x94, 0x45, 0xa4, 0x39, |
| 886 |
0xad, 0x83, 0x7f, 0x8a, 0x31, 0x0c, 0x4b, 0x0d, |
| 887 |
0x98, 0xb3, 0x20, 0xe1, 0xd7, 0xe9, 0x55, 0xe6, |
| 888 |
0x79, 0xfe, 0x52, 0xa0, 0xd2, 0xa5, 0xde, 0x42, |
| 889 |
0xab, 0x2d, 0x60, 0xea, 0x1a, 0xc6, 0x28, 0x65, |
| 890 |
0xa1, 0x01, 0xab, 0x6c, 0xa9, 0x50, 0x35, 0x0a, |
| 891 |
0x1b, 0xc7, 0xda, 0xb0, 0x61, 0xaa, 0x1d, 0xa1, |
| 892 |
0xd4, 0xa6, 0x65, 0x36, 0x64, 0xa0, 0x1c, 0x3b, |
| 893 |
0x66, 0x22, 0x76, 0x8e, 0xc8, 0x71, 0x45, 0x0b, |
| 894 |
0x0b, 0xba, 0xb3, 0x4d, 0xa3, 0xf1, 0x38, 0xbe, |
| 895 |
0x7f, 0xfc, 0x7d, 0x15, 0x3f, 0xf2, 0x15, 0x80, |
| 896 |
0x8f, 0xda, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, |
| 897 |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, |
| 898 |
0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, |
| 899 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 900 |
0x00, |
| 901 |
}, |
| 902 |
expect: sam.GroupUnspecified, |
| 903 |
}, |
| 904 |
{ |
| 905 |
input: []byte{ |
| 906 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 907 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 908 |
0xf3, 0x01, 0xad, 0x92, 0xcd, 0x8e, 0xda, 0x30, |
| 909 |
0x10, 0xc7, 0xb3, 0xdd, 0x93, 0x79, 0x8a, 0x1c, |
| 910 |
0x38, 0xb4, 0x07, 0x1c, 0xe7, 0xc3, 0x81, 0x58, |
| 911 |
0xaa, 0xc4, 0x97, 0x04, 0x48, 0x21, 0xa4, 0x44, |
| 912 |
0xb4, 0x5a, 0xf5, 0x10, 0x39, 0x89, 0x13, 0xac, |
| 913 |
0x35, 0x0e, 0xe0, 0x00, 0xdb, 0xbe, 0xc1, 0x3e, |
| 914 |
0xf1, 0xde, 0xaa, 0x9a, 0x68, 0xdb, 0xae, 0xda, |
| 915 |
0x1e, 0x39, 0x78, 0x64, 0xff, 0x67, 0xe6, 0x37, |
| 916 |
0x63, 0x7b, 0xc6, 0xa3, 0xe5, 0xdd, 0xd7, 0x7b, |
| 917 |
0xc3, 0x18, 0xce, 0xa7, 0xe0, 0x73, 0x44, 0x6c, |
| 918 |
0x88, 0x40, 0xb2, 0x22, 0x79, 0x5d, 0x1f, 0x0b, |
| 919 |
0x2e, 0x69, 0xc3, 0xc0, 0x6c, 0x45, 0x64, 0x2d, |
| 920 |
0x59, 0x67, 0x98, 0x7c, 0x02, 0x49, 0x44, 0x1e, |
| 921 |
0x40, 0x18, 0x11, 0x1c, 0xb8, 0x7d, 0x17, 0xfb, |
| 922 |
0x3e, 0x58, 0x62, 0x62, 0x97, 0xd4, 0xf5, 0xfa, |
| 923 |
0x5e, 0x1f, 0x23, 0x5a, 0xa2, 0xc0, 0x1b, 0x64, |
| 924 |
0x45, 0x19, 0xf4, 0x0b, 0x4c, 0x11, 0x63, 0xd8, |
| 925 |
0x61, 0xd8, 0x06, 0x9b, 0x35, 0x29, 0x9b, 0x3d, |
| 926 |
0xb1, 0x2c, 0x6d, 0xa1, 0x8d, 0x10, 0xaa, 0x98, |
| 927 |
0xac, 0x77, 0x4c, 0x41, 0x96, 0x71, 0x48, 0x73, |
| 928 |
0x78, 0x7a, 0xb4, 0xce, 0xb5, 0xb0, 0xaf, 0x6e, |
| 929 |
0xab, 0x61, 0xf9, 0x56, 0xf2, 0x9c, 0x0a, 0xeb, |
| 930 |
0xc8, 0x4a, 0x76, 0x64, 0x32, 0x67, 0xd6, 0x7e, |
| 931 |
0x4b, 0x15, 0x73, 0xd2, 0xdf, 0x42, 0x4a, 0x95, |
| 932 |
0x62, 0xbb, 0x4c, 0x7c, 0x4b, 0x15, 0x3b, 0x9c, |
| 933 |
0xda, 0x90, 0xad, 0x72, 0x75, 0x49, 0x58, 0x52, |
| 934 |
0x58, 0x7d, 0x07, 0xa3, 0x84, 0x44, 0x93, 0xf1, |
| 935 |
0xc2, 0xed, 0x83, 0x24, 0x26, 0xf3, 0xd3, 0x8e, |
| 936 |
0xca, 0xce, 0x70, 0x3d, 0x03, 0x8b, 0x29, 0x49, |
| 937 |
0xd6, 0x6b, 0xe4, 0x3b, 0xbe, 0xeb, 0x81, 0x70, |
| 938 |
0x4c, 0x9c, 0x81, 0x87, 0x07, 0xd8, 0x1f, 0x60, |
| 939 |
0x7d, 0xe1, 0x25, 0x99, 0xcf, 0x74, 0x63, 0x81, |
| 940 |
0x0f, 0xe2, 0x05, 0x71, 0x90, 0x0f, 0x26, 0x11, |
| 941 |
0xf9, 0xb2, 0x99, 0x25, 0x13, 0x10, 0x87, 0x64, |
| 942 |
0x11, 0x86, 0x9b, 0xe5, 0x22, 0x1a, 0x81, 0x69, |
| 943 |
0xa2, 0x09, 0x31, 0x42, 0xb6, 0x13, 0x78, 0x7f, |
| 944 |
0x23, 0xf1, 0xcd, 0x91, 0x9e, 0x7d, 0x0b, 0x64, |
| 945 |
0xdc, 0x22, 0xb3, 0x0b, 0x4d, 0xb9, 0x2c, 0xd8, |
| 946 |
0x13, 0x88, 0xa3, 0xeb, 0xe1, 0xfa, 0xd3, 0x08, |
| 947 |
0x62, 0x18, 0xf4, 0x8e, 0xb6, 0xc6, 0x84, 0x57, |
| 948 |
0xcd, 0x6c, 0x03, 0xcc, 0x1e, 0x35, 0xb3, 0x4b, |
| 949 |
0xa3, 0x2e, 0x66, 0xf7, 0xcf, 0x83, 0x97, 0x54, |
| 950 |
0x35, 0xf4, 0x2d, 0x8b, 0x0a, 0xd9, 0x8a, 0x87, |
| 951 |
0x5f, 0xbc, 0x38, 0x7e, 0x53, 0xe3, 0x7f, 0x70, |
| 952 |
0x9d, 0x61, 0xf6, 0x0e, 0xa6, 0x8d, 0xcd, 0x5e, |
| 953 |
0x69, 0x76, 0x15, 0xe5, 0x69, 0xc9, 0x05, 0xfb, |
| 954 |
0xa7, 0x88, 0xd9, 0x6d, 0xb1, 0xad, 0xb3, 0x33, |
| 955 |
0x9c, 0xac, 0x40, 0xf7, 0x51, 0xd6, 0x17, 0xd9, |
| 956 |
0x82, 0x85, 0x6a, 0xe5, 0xf7, 0xea, 0x83, 0xf9, |
| 957 |
0xd1, 0xbc, 0xc5, 0x44, 0xed, 0xe8, 0x7e, 0xcf, |
| 958 |
0x65, 0xa5, 0x27, 0x4b, 0xd5, 0xa7, 0x63, 0xce, |
| 959 |
0x94, 0x35, 0x0a, 0x43, 0x78, 0xa9, 0x14, 0x7c, |
| 960 |
0x2d, 0xb7, 0xe3, 0x42, 0xdb, 0x82, 0x9d, 0xb9, |
| 961 |
0x64, 0xe9, 0xb6, 0xb2, 0x83, 0x54, 0xb0, 0xb2, |
| 962 |
0x19, 0x09, 0x5e, 0x49, 0x56, 0xa4, 0x79, 0x2d, |
| 963 |
0x04, 0xdd, 0x2b, 0xbd, 0x2b, 0xea, 0x53, 0x26, |
| 964 |
0x74, 0x04, 0x6f, 0x5e, 0x33, 0xa1, 0xe2, 0x8d, |
| 965 |
0x6e, 0xe7, 0x9c, 0x97, 0x7a, 0x20, 0x3b, 0x77, |
| 966 |
0x86, 0x61, 0xbc, 0xd3, 0xeb, 0xc1, 0xf8, 0xf1, |
| 967 |
0xf2, 0x7c, 0xff, 0x13, 0x5a, 0x38, 0x56, 0x0a, |
| 968 |
0x71, 0x03, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, |
| 969 |
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, 0x00, |
| 970 |
0x42, 0x43, 0x02, 0x00, 0xcf, 0x00, 0x4d, 0xce, |
| 971 |
0x31, 0x6a, 0xc3, 0x30, 0x18, 0x05, 0x60, 0x41, |
| 972 |
0x0f, 0x50, 0xd2, 0x66, 0x30, 0x74, 0x88, 0xab, |
| 973 |
0x18, 0xeb, 0x59, 0xb2, 0xa5, 0xff, 0xb7, 0xa9, |
| 974 |
0x93, 0x8c, 0x32, 0x82, 0x6a, 0x76, 0xb6, 0xce, |
| 975 |
0x3d, 0x40, 0x2e, 0x90, 0x41, 0xc1, 0x83, 0x73, |
| 976 |
0xc1, 0xdc, 0xa4, 0x74, 0xad, 0x4b, 0xa0, 0xf4, |
| 977 |
0x5b, 0xde, 0xe3, 0x4d, 0xef, 0x26, 0xee, 0xbe, |
| 978 |
0xbe, 0xaf, 0x0f, 0xcf, 0xe2, 0x94, 0x0b, 0x71, |
| 979 |
0x16, 0x9f, 0xff, 0xb6, 0xdf, 0x3c, 0x8e, 0x23, |
| 980 |
0xf5, 0x6d, 0xdf, 0xbd, 0x59, 0x3e, 0xf4, 0xdd, |
| 981 |
0x6e, 0xdf, 0xb6, 0x62, 0xb8, 0xc8, 0xe8, 0x63, |
| 982 |
0x98, 0x57, 0x29, 0x44, 0x9f, 0xbc, 0x9c, 0xa6, |
| 983 |
0x4c, 0x66, 0xc5, 0x94, 0x45, 0xa4, 0x39, 0xad, |
| 984 |
0x83, 0x7f, 0x8a, 0x31, 0x0c, 0x4b, 0x0d, 0x98, |
| 985 |
0xb3, 0x20, 0xe1, 0xd7, 0xe9, 0x55, 0xe6, 0x79, |
| 986 |
0xfe, 0x52, 0xa0, 0xd2, 0xa5, 0xde, 0x42, 0xab, |
| 987 |
0x2d, 0x60, 0xea, 0x1a, 0xc6, 0x28, 0x65, 0xa1, |
| 988 |
0x01, 0xab, 0x6c, 0xa9, 0x50, 0x35, 0x0a, 0x1b, |
| 989 |
0xc7, 0xda, 0xb0, 0x61, 0xaa, 0x1d, 0xa1, 0xd4, |
| 990 |
0xa6, 0x65, 0x36, 0x64, 0xa0, 0x1c, 0x3b, 0x66, |
| 991 |
0x22, 0x76, 0x8e, 0xc8, 0x71, 0x45, 0x0b, 0x0b, |
| 992 |
0xba, 0xb3, 0x4d, 0xa3, 0xf1, 0x38, 0xbe, 0x7f, |
| 993 |
0xfc, 0x7d, 0x15, 0x3f, 0xf2, 0x15, 0x80, 0x8f, |
| 994 |
0xda, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, |
| 995 |
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, 0x00, |
| 996 |
0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, 0x00, |
| 997 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 998 |
}, |
| 999 |
expect: sam.GroupNone, |
| 1000 |
}, |
| 1001 |
{ |
| 1002 |
input: []byte{ |
| 1003 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 1004 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 1005 |
0xf5, 0x01, 0xad, 0x92, 0xcb, 0x8e, 0xda, 0x30, |
| 1006 |
0x14, 0x86, 0x33, 0x9d, 0x95, 0x79, 0x8a, 0x2c, |
| 1007 |
0x58, 0xb4, 0x0b, 0x1c, 0xe7, 0xe2, 0x40, 0x2c, |
| 1008 |
0x55, 0xe2, 0x26, 0x01, 0x52, 0x08, 0x29, 0x11, |
| 1009 |
0xad, 0x46, 0xaa, 0x14, 0x39, 0x89, 0x13, 0xac, |
| 1010 |
0x31, 0x0e, 0x13, 0x07, 0xe8, 0xf4, 0x0d, 0xfa, |
| 1011 |
0xc4, 0xdd, 0x55, 0x35, 0xd1, 0xb4, 0x1d, 0xb5, |
| 1012 |
0x5d, 0xb2, 0xf0, 0x91, 0x7d, 0x2e, 0xdf, 0x7f, |
| 1013 |
0x6c, 0x9f, 0xe9, 0x64, 0x7d, 0xf7, 0xf9, 0xde, |
| 1014 |
0x30, 0xc6, 0xcb, 0x39, 0xf8, 0x18, 0x11, 0x1b, |
| 1015 |
0x22, 0x90, 0x6c, 0x48, 0x5e, 0xd7, 0x4d, 0xc1, |
| 1016 |
0x25, 0x6d, 0x19, 0x58, 0x6c, 0xc8, 0xd3, 0x89, |
| 1017 |
0x35, 0xcf, 0xbd, 0x71, 0xf2, 0x01, 0x24, 0x11, |
| 1018 |
0x79, 0x00, 0x61, 0x44, 0x70, 0xe0, 0x0e, 0x5d, |
| 1019 |
0xec, 0xfb, 0x60, 0x8d, 0x89, 0x5d, 0x52, 0xd7, |
| 1020 |
0x1b, 0x7a, 0x43, 0x8c, 0x68, 0x89, 0x02, 0x6f, |
| 1021 |
0x94, 0x15, 0x65, 0x30, 0x2c, 0x30, 0x45, 0x8c, |
| 1022 |
0x61, 0x87, 0x61, 0x1b, 0xec, 0xb6, 0xa4, 0x6c, |
| 1023 |
0x8f, 0xc4, 0xb2, 0xb4, 0x85, 0x36, 0x42, 0xa8, |
| 1024 |
0x62, 0xb2, 0x3e, 0x30, 0x05, 0x59, 0xc6, 0x21, |
| 1025 |
0xcd, 0xe1, 0xe9, 0xd1, 0x3a, 0xd7, 0xc2, 0xbe, |
| 1026 |
0x86, 0xad, 0x96, 0xe5, 0x7b, 0xc9, 0x73, 0x2a, |
| 1027 |
0xac, 0x86, 0x95, 0xac, 0x61, 0x32, 0x67, 0xd6, |
| 1028 |
0x71, 0x4f, 0x15, 0x73, 0xd2, 0xdf, 0x8e, 0x94, |
| 1029 |
0x2a, 0xc5, 0x0e, 0x99, 0x78, 0x4e, 0x15, 0xd3, |
| 1030 |
0xad, 0x5d, 0x53, 0xf6, 0xca, 0xd5, 0x92, 0xb0, |
| 1031 |
0xa4, 0xb0, 0xfa, 0x0a, 0x26, 0x09, 0x89, 0x66, |
| 1032 |
0xd3, 0x95, 0x3b, 0x04, 0x49, 0x4c, 0x96, 0xa7, |
| 1033 |
0x03, 0x95, 0xbd, 0xf1, 0x76, 0x01, 0x56, 0x73, |
| 1034 |
0x92, 0x6c, 0xb7, 0xc8, 0x77, 0x7c, 0xd7, 0x03, |
| 1035 |
0xe1, 0x94, 0x38, 0x23, 0x0f, 0x8f, 0xb0, 0x3f, |
| 1036 |
0xc2, 0xfa, 0xc6, 0x6b, 0xb2, 0x5c, 0xe8, 0xc6, |
| 1037 |
0x02, 0x1f, 0xc4, 0x2b, 0xe2, 0x20, 0x1f, 0xcc, |
| 1038 |
0x22, 0xf2, 0x69, 0xb7, 0x48, 0x66, 0x20, 0x0e, |
| 1039 |
0xc9, 0x2a, 0x0c, 0x77, 0xeb, 0x55, 0x34, 0x01, |
| 1040 |
0xf3, 0x44, 0x13, 0x62, 0x84, 0x6c, 0x27, 0xf0, |
| 1041 |
0xfe, 0x46, 0xe2, 0x9b, 0x23, 0x3d, 0xfb, 0x16, |
| 1042 |
0xc8, 0xb8, 0x43, 0x66, 0x17, 0x9a, 0x72, 0x59, |
| 1043 |
0xb0, 0x2f, 0x20, 0x8e, 0xae, 0x87, 0xeb, 0x57, |
| 1044 |
0x23, 0x88, 0x61, 0x30, 0x68, 0x6c, 0x8d, 0x09, |
| 1045 |
0xaf, 0x3e, 0xb3, 0x4b, 0x30, 0x07, 0xd4, 0xcc, |
| 1046 |
0x2e, 0xad, 0xba, 0x98, 0xfd, 0x3f, 0x0f, 0x5e, |
| 1047 |
0x52, 0xd5, 0xd2, 0xd7, 0x2c, 0x2a, 0x64, 0xe7, |
| 1048 |
0x7c, 0xfa, 0xc5, 0x8b, 0xe3, 0x57, 0x1a, 0xff, |
| 1049 |
0x83, 0xeb, 0x0a, 0x73, 0xf0, 0x64, 0xda, 0xd8, |
| 1050 |
0x1c, 0x94, 0x66, 0x5f, 0x51, 0x9e, 0x96, 0x5c, |
| 1051 |
0xb0, 0x7f, 0x44, 0xcc, 0x7e, 0x87, 0xed, 0x82, |
| 1052 |
0xbd, 0xf1, 0x6c, 0x03, 0xfa, 0x8f, 0xb2, 0xbe, |
| 1053 |
0xc8, 0x0e, 0x2c, 0x54, 0xe7, 0x7e, 0xab, 0xde, |
| 1054 |
0x99, 0xef, 0xcd, 0x5b, 0x4c, 0xd4, 0x81, 0x1e, |
| 1055 |
0x8f, 0x5c, 0x56, 0x7a, 0xb2, 0x54, 0x7d, 0x6a, |
| 1056 |
0x72, 0xa6, 0xac, 0x49, 0x18, 0xc2, 0x4b, 0xa5, |
| 1057 |
0xe0, 0x8b, 0xdc, 0x81, 0x0b, 0x6d, 0x0b, 0x76, |
| 1058 |
0xe6, 0x92, 0xa5, 0xfb, 0xca, 0x0e, 0x52, 0xc1, |
| 1059 |
0xca, 0x76, 0x22, 0x78, 0x25, 0x59, 0x91, 0xe6, |
| 1060 |
0xb5, 0x10, 0xf4, 0xa8, 0xf4, 0xae, 0xa8, 0x4f, |
| 1061 |
0x99, 0xd0, 0x19, 0xbc, 0x7d, 0xa9, 0x84, 0x8a, |
| 1062 |
0xb7, 0xba, 0x9d, 0x73, 0x5e, 0xea, 0x81, 0xec, |
| 1063 |
0xdd, 0x19, 0x86, 0xf1, 0x46, 0xaf, 0x07, 0xe3, |
| 1064 |
0xc7, 0xf7, 0x6f, 0xf7, 0x3f, 0x01, 0x63, 0x09, |
| 1065 |
0x85, 0xc2, 0x72, 0x03, 0x00, 0x00, 0x1f, 0x8b, |
| 1066 |
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1067 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0xcf, 0x00, |
| 1068 |
0x4d, 0xce, 0x31, 0x6a, 0xc3, 0x30, 0x18, 0x05, |
| 1069 |
0x60, 0x41, 0x0f, 0x50, 0xd2, 0x66, 0x30, 0x74, |
| 1070 |
0x88, 0xab, 0x18, 0xeb, 0x59, 0xb2, 0xa5, 0xff, |
| 1071 |
0xb7, 0xa9, 0x93, 0x8c, 0x32, 0x82, 0x6a, 0x76, |
| 1072 |
0xb6, 0xce, 0x3d, 0x40, 0x2e, 0x90, 0x41, 0xc1, |
| 1073 |
0x83, 0x73, 0xc1, 0xdc, 0xa4, 0x74, 0xad, 0x4b, |
| 1074 |
0xa0, 0xf4, 0x5b, 0xde, 0xe3, 0x4d, 0xef, 0x26, |
| 1075 |
0xee, 0xbe, 0xbe, 0xaf, 0x0f, 0xcf, 0xe2, 0x94, |
| 1076 |
0x0b, 0x71, 0x16, 0x9f, 0xff, 0xb6, 0xdf, 0x3c, |
| 1077 |
0x8e, 0x23, 0xf5, 0x6d, 0xdf, 0xbd, 0x59, 0x3e, |
| 1078 |
0xf4, 0xdd, 0x6e, 0xdf, 0xb6, 0x62, 0xb8, 0xc8, |
| 1079 |
0xe8, 0x63, 0x98, 0x57, 0x29, 0x44, 0x9f, 0xbc, |
| 1080 |
0x9c, 0xa6, 0x4c, 0x66, 0xc5, 0x94, 0x45, 0xa4, |
| 1081 |
0x39, 0xad, 0x83, 0x7f, 0x8a, 0x31, 0x0c, 0x4b, |
| 1082 |
0x0d, 0x98, 0xb3, 0x20, 0xe1, 0xd7, 0xe9, 0x55, |
| 1083 |
0xe6, 0x79, 0xfe, 0x52, 0xa0, 0xd2, 0xa5, 0xde, |
| 1084 |
0x42, 0xab, 0x2d, 0x60, 0xea, 0x1a, 0xc6, 0x28, |
| 1085 |
0x65, 0xa1, 0x01, 0xab, 0x6c, 0xa9, 0x50, 0x35, |
| 1086 |
0x0a, 0x1b, 0xc7, 0xda, 0xb0, 0x61, 0xaa, 0x1d, |
| 1087 |
0xa1, 0xd4, 0xa6, 0x65, 0x36, 0x64, 0xa0, 0x1c, |
| 1088 |
0x3b, 0x66, 0x22, 0x76, 0x8e, 0xc8, 0x71, 0x45, |
| 1089 |
0x0b, 0x0b, 0xba, 0xb3, 0x4d, 0xa3, 0xf1, 0x38, |
| 1090 |
0xbe, 0x7f, 0xfc, 0x7d, 0x15, 0x3f, 0xf2, 0x15, |
| 1091 |
0x80, 0x8f, 0xda, 0x00, 0x00, 0x00, 0x1f, 0x8b, |
| 1092 |
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1093 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, |
| 1094 |
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1095 |
0x00, 0x00, |
| 1096 |
}, |
| 1097 |
expect: sam.GroupQuery, |
| 1098 |
}, |
| 1099 |
{ |
| 1100 |
input: []byte{ |
| 1101 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 1102 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 1103 |
0xf1, 0x01, 0xad, 0x92, 0xcb, 0x8e, 0xda, 0x30, |
| 1104 |
0x14, 0x86, 0x33, 0x9d, 0x95, 0x79, 0x8a, 0x2c, |
| 1105 |
0x58, 0xb4, 0x0b, 0x1c, 0xe7, 0xe2, 0x40, 0x2c, |
| 1106 |
0x55, 0xe2, 0x26, 0x01, 0x52, 0x08, 0x29, 0x11, |
| 1107 |
0xad, 0x66, 0x95, 0x3a, 0x89, 0x13, 0xac, 0x31, |
| 1108 |
0x0e, 0xe0, 0x00, 0x6d, 0xdf, 0xa0, 0x4f, 0x3c, |
| 1109 |
0xbb, 0x51, 0x4d, 0x34, 0x9d, 0x8e, 0xda, 0x2e, |
| 1110 |
0x59, 0xf8, 0xc8, 0x3e, 0x97, 0xef, 0x3f, 0xb6, |
| 1111 |
0xcf, 0x78, 0xb4, 0xbc, 0xfb, 0x7a, 0x6f, 0x18, |
| 1112 |
0xc3, 0xf9, 0x14, 0x7c, 0x8e, 0x88, 0x0d, 0x11, |
| 1113 |
0x48, 0x56, 0x24, 0xaf, 0xeb, 0x63, 0xc1, 0x25, |
| 1114 |
0x6d, 0x18, 0x98, 0xad, 0xc8, 0x91, 0x95, 0xec, |
| 1115 |
0xc8, 0x64, 0xce, 0x3a, 0xc3, 0xe4, 0x13, 0x48, |
| 1116 |
0x22, 0xf2, 0x00, 0xc2, 0x88, 0xe0, 0xc0, 0xed, |
| 1117 |
0xbb, 0xd8, 0xf7, 0xc1, 0x12, 0x13, 0xbb, 0xa4, |
| 1118 |
0xae, 0xd7, 0xf7, 0xfa, 0x18, 0xd1, 0x12, 0x05, |
| 1119 |
0xde, 0x20, 0x2b, 0xca, 0xa0, 0x5f, 0x60, 0x8a, |
| 1120 |
0x18, 0xc3, 0x0e, 0xc3, 0x36, 0xd8, 0xac, 0x49, |
| 1121 |
0xd9, 0xec, 0x89, 0x65, 0x69, 0x0b, 0x6d, 0x84, |
| 1122 |
0x50, 0xc5, 0x64, 0xbd, 0x63, 0x0a, 0xb2, 0x8c, |
| 1123 |
0x43, 0x9a, 0xc3, 0xd3, 0xa3, 0x75, 0xae, 0x85, |
| 1124 |
0x7d, 0x0d, 0x5b, 0x0d, 0xcb, 0xb7, 0x92, 0xe7, |
| 1125 |
0x54, 0x58, 0xaf, 0xc2, 0xd6, 0x7e, 0x4b, 0x15, |
| 1126 |
0x73, 0xd2, 0x57, 0x47, 0x4a, 0x95, 0x62, 0xbb, |
| 1127 |
0x4c, 0x7c, 0x4f, 0x15, 0x3b, 0x9c, 0xda, 0x94, |
| 1128 |
0xad, 0x72, 0xb5, 0x24, 0x2c, 0x29, 0xac, 0x7e, |
| 1129 |
0x80, 0x51, 0x42, 0xa2, 0xc9, 0x78, 0xe1, 0xf6, |
| 1130 |
0x41, 0x12, 0x93, 0xf9, 0x69, 0x47, 0x65, 0x67, |
| 1131 |
0xb8, 0x9e, 0x81, 0xc5, 0x94, 0x24, 0xeb, 0x35, |
| 1132 |
0xf2, 0x1d, 0xdf, 0xf5, 0x40, 0x38, 0x26, 0xce, |
| 1133 |
0xc0, 0xc3, 0x03, 0xec, 0x0f, 0xb0, 0xbe, 0xf5, |
| 1134 |
0x92, 0xcc, 0x67, 0xba, 0xb1, 0xc0, 0x07, 0xf1, |
| 1135 |
0x82, 0x38, 0xc8, 0x07, 0x93, 0x88, 0x7c, 0xd9, |
| 1136 |
0xcc, 0x92, 0x09, 0x88, 0x43, 0xb2, 0x08, 0xc3, |
| 1137 |
0xcd, 0x72, 0x11, 0x8d, 0xc0, 0x34, 0xd1, 0x84, |
| 1138 |
0x18, 0x21, 0xdb, 0x09, 0xbc, 0xbf, 0x91, 0xf8, |
| 1139 |
0xe6, 0x48, 0xcf, 0xbe, 0x05, 0x32, 0x6e, 0x91, |
| 1140 |
0xd9, 0x85, 0xa6, 0x5c, 0x16, 0xec, 0x1b, 0x88, |
| 1141 |
0xa3, 0xeb, 0xe1, 0xfa, 0xdd, 0x08, 0x62, 0x18, |
| 1142 |
0xf4, 0x8e, 0xb6, 0xc6, 0x84, 0x57, 0x9f, 0xd9, |
| 1143 |
0x26, 0x98, 0x3d, 0x6a, 0x66, 0x97, 0x46, 0x5d, |
| 1144 |
0xcc, 0xee, 0x9f, 0x07, 0x2f, 0xa9, 0x6a, 0xe8, |
| 1145 |
0x5b, 0x16, 0x15, 0xb2, 0x75, 0x1e, 0x7e, 0xf3, |
| 1146 |
0xe2, 0xf8, 0x8d, 0xc6, 0xff, 0xe0, 0xba, 0xc2, |
| 1147 |
0xec, 0x1d, 0x4c, 0x1b, 0x9b, 0xbd, 0xd2, 0xec, |
| 1148 |
0x2a, 0xca, 0xd3, 0x92, 0x0b, 0xf6, 0x8f, 0x88, |
| 1149 |
0xd9, 0x6d, 0xb1, 0x6d, 0xb0, 0x33, 0x9c, 0xac, |
| 1150 |
0x40, 0xf7, 0x51, 0xd6, 0x17, 0xd9, 0x82, 0x85, |
| 1151 |
0x6a, 0xdd, 0xef, 0xd5, 0x07, 0xf3, 0xa3, 0x79, |
| 1152 |
0x8b, 0x89, 0xda, 0xd1, 0xfd, 0x9e, 0xcb, 0x4a, |
| 1153 |
0x4f, 0x96, 0xaa, 0x4f, 0xc7, 0x9c, 0x29, 0x6b, |
| 1154 |
0x14, 0x86, 0xf0, 0x52, 0x29, 0xf8, 0x22, 0xb7, |
| 1155 |
0xe3, 0x42, 0xdb, 0x82, 0x9d, 0xb9, 0x64, 0xe9, |
| 1156 |
0xb6, 0xb2, 0x83, 0x54, 0xb0, 0xb2, 0x19, 0x09, |
| 1157 |
0x5e, 0x49, 0x56, 0xa4, 0x79, 0x2d, 0x04, 0xdd, |
| 1158 |
0x2b, 0xbd, 0x2b, 0xea, 0x53, 0x26, 0x74, 0x06, |
| 1159 |
0x6f, 0x5e, 0x2a, 0xa1, 0xe2, 0x8d, 0x6e, 0xe7, |
| 1160 |
0x9c, 0x97, 0x7a, 0x20, 0x3b, 0x77, 0x86, 0x61, |
| 1161 |
0xbc, 0xd3, 0xeb, 0xc1, 0x78, 0x7e, 0xfa, 0x79, |
| 1162 |
0xff, 0x0b, 0xf6, 0x33, 0x1f, 0x79, 0x76, 0x03, |
| 1163 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 1164 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 1165 |
0x02, 0x00, 0xcf, 0x00, 0x4d, 0xce, 0x31, 0x6a, |
| 1166 |
0xc3, 0x30, 0x18, 0x05, 0x60, 0x41, 0x0f, 0x50, |
| 1167 |
0xd2, 0x66, 0x30, 0x74, 0x88, 0xab, 0x18, 0xeb, |
| 1168 |
0x59, 0xb2, 0xa5, 0xff, 0xb7, 0xa9, 0x93, 0x8c, |
| 1169 |
0x32, 0x82, 0x6a, 0x76, 0xb6, 0xce, 0x3d, 0x40, |
| 1170 |
0x2e, 0x90, 0x41, 0xc1, 0x83, 0x73, 0xc1, 0xdc, |
| 1171 |
0xa4, 0x74, 0xad, 0x4b, 0xa0, 0xf4, 0x5b, 0xde, |
| 1172 |
0xe3, 0x4d, 0xef, 0x26, 0xee, 0xbe, 0xbe, 0xaf, |
| 1173 |
0x0f, 0xcf, 0xe2, 0x94, 0x0b, 0x71, 0x16, 0x9f, |
| 1174 |
0xff, 0xb6, 0xdf, 0x3c, 0x8e, 0x23, 0xf5, 0x6d, |
| 1175 |
0xdf, 0xbd, 0x59, 0x3e, 0xf4, 0xdd, 0x6e, 0xdf, |
| 1176 |
0xb6, 0x62, 0xb8, 0xc8, 0xe8, 0x63, 0x98, 0x57, |
| 1177 |
0x29, 0x44, 0x9f, 0xbc, 0x9c, 0xa6, 0x4c, 0x66, |
| 1178 |
0xc5, 0x94, 0x45, 0xa4, 0x39, 0xad, 0x83, 0x7f, |
| 1179 |
0x8a, 0x31, 0x0c, 0x4b, 0x0d, 0x98, 0xb3, 0x20, |
| 1180 |
0xe1, 0xd7, 0xe9, 0x55, 0xe6, 0x79, 0xfe, 0x52, |
| 1181 |
0xa0, 0xd2, 0xa5, 0xde, 0x42, 0xab, 0x2d, 0x60, |
| 1182 |
0xea, 0x1a, 0xc6, 0x28, 0x65, 0xa1, 0x01, 0xab, |
| 1183 |
0x6c, 0xa9, 0x50, 0x35, 0x0a, 0x1b, 0xc7, 0xda, |
| 1184 |
0xb0, 0x61, 0xaa, 0x1d, 0xa1, 0xd4, 0xa6, 0x65, |
| 1185 |
0x36, 0x64, 0xa0, 0x1c, 0x3b, 0x66, 0x22, 0x76, |
| 1186 |
0x8e, 0xc8, 0x71, 0x45, 0x0b, 0x0b, 0xba, 0xb3, |
| 1187 |
0x4d, 0xa3, 0xf1, 0x38, 0xbe, 0x7f, 0xfc, 0x7d, |
| 1188 |
0x15, 0x3f, 0xf2, 0x15, 0x80, 0x8f, 0xda, 0x00, |
| 1189 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 1190 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 1191 |
0x02, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x00, 0x00, |
| 1192 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1193 |
}, |
| 1194 |
expect: sam.GroupReference, |
| 1195 |
}, |
| 1196 |
} |
| 1197 |
|
| 1198 |
func (s *S) TestIssue13(c *check.C) { |
| 1199 |
br, err := NewReader(bytes.NewReader(issue13), *conc) |
| 1200 |
c.Assert(err, check.Equals, nil, check.Commentf("Failed to open BAM")) |
| 1201 |
|
| 1202 |
r, err := br.Read() |
| 1203 |
c.Assert(err, check.Equals, nil, check.Commentf("Failed to read BAM record")) |
| 1204 |
|
| 1205 |
end := r.End() |
| 1206 |
c.Check(end, check.Equals, 4391) |
| 1207 |
} |
| 1208 |
|
| 1209 |
// This is BAM data provided in issue 12 [sic] from SAM file in comment 4. |
| 1210 |
// Issue 12 as described is working as intended. |
| 1211 |
// |
| 1212 |
// @HD VN:1.0 SO:coordinate |
| 1213 |
// @SQ SN:Zv9_NA129 LN:9079 |
| 1214 |
// 10 0 Zv9_NA129 4272 50 40M75N5M * 0 0 TGACGCAGAGGTGCGCAAGACCTCCAAGAAGCAGCTGAAGGACAC DDDDHGHHHJI<ABGGIHGIGGHIJEEEGGGCBFCEHIIFFHECI AS:i:-3 XN:i:0 XM:i:1 XO:i:0 XG:i:0 NM:i:1 MD:Z:0C44 YT:Z:UU XS:A:+ NH:i:1 |
| 1215 |
var issue13 = []byte{ |
| 1216 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 1217 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 1218 |
0x61, 0x00, 0x73, 0x72, 0xf4, 0x65, 0x34, 0x62, |
| 1219 |
0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, 0x0c, 0xf3, |
| 1220 |
0xb3, 0x32, 0xd4, 0x33, 0xe0, 0x0c, 0xf6, 0xb7, |
| 1221 |
0x4a, 0xce, 0xcf, 0x2f, 0x4a, 0xc9, 0xcc, 0x4b, |
| 1222 |
0x2c, 0x49, 0xe5, 0x72, 0x08, 0x0e, 0xe4, 0x0c, |
| 1223 |
0xf6, 0xb3, 0x8a, 0x2a, 0xb3, 0x8c, 0xf7, 0x73, |
| 1224 |
0x34, 0x34, 0xb2, 0xe4, 0xf4, 0xf1, 0xb3, 0xb2, |
| 1225 |
0x34, 0x30, 0xb7, 0xe4, 0x62, 0x04, 0xea, 0xe2, |
| 1226 |
0x02, 0x62, 0xb8, 0x0c, 0x43, 0xb9, 0x32, 0x03, |
| 1227 |
0x03, 0x00, 0x03, 0x99, 0x97, 0x23, 0x50, 0x00, |
| 1228 |
0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, |
| 1229 |
0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, |
| 1230 |
0x02, 0x00, 0xab, 0x00, 0x2d, 0x89, 0x41, 0x0a, |
| 1231 |
0xc2, 0x30, 0x10, 0x45, 0xa7, 0xd6, 0x03, 0xd8, |
| 1232 |
0x92, 0x9d, 0x9b, 0x26, 0xa6, 0x33, 0x53, 0x44, |
| 1233 |
0xa8, 0xd2, 0x0b, 0x24, 0x11, 0x6c, 0x17, 0xad, |
| 1234 |
0x42, 0x2d, 0xc4, 0x6e, 0xbd, 0x88, 0x88, 0x17, |
| 1235 |
0xf1, 0x04, 0x2e, 0x3c, 0x9f, 0x68, 0x44, 0x1f, |
| 1236 |
0x7c, 0xfe, 0xfb, 0xfc, 0x3b, 0xfc, 0x78, 0xcc, |
| 1237 |
0x00, 0xe2, 0x4d, 0x93, 0xc6, 0xc1, 0x57, 0x21, |
| 1238 |
0xef, 0x3f, 0xdf, 0x6f, 0x5d, 0xc2, 0x65, 0x02, |
| 1239 |
0xf0, 0x9c, 0x02, 0x1c, 0xc2, 0xbc, 0xa5, 0x56, |
| 1240 |
0x88, 0xda, 0xda, 0xc4, 0xa8, 0xab, 0x14, 0x89, |
| 1241 |
0x15, 0x6c, 0x84, 0x91, 0xd9, 0x22, 0x40, 0x48, |
| 1242 |
0x44, 0x05, 0xcf, 0x33, 0x89, 0xc8, 0x84, 0x8c, |
| 1243 |
0x48, 0x5c, 0x68, 0xad, 0x11, 0x51, 0xc9, 0x5c, |
| 1244 |
0x69, 0x62, 0xce, 0x73, 0xd2, 0x8a, 0x4d, 0x7f, |
| 1245 |
0x7e, 0xf9, 0xce, 0x81, 0x6f, 0x5d, 0xe4, 0xf7, |
| 1246 |
0xa1, 0x77, 0x0e, 0xba, 0xe0, 0xed, 0x76, 0x2c, |
| 1247 |
0x5d, 0x55, 0xc1, 0xe9, 0x38, 0x0e, 0x03, 0xf8, |
| 1248 |
0xde, 0x2c, 0xbb, 0xda, 0x45, 0x1f, 0xf4, 0x97, |
| 1249 |
0xb4, 0x05, 0xa5, 0x00, 0x00, 0x00, 0x1f, 0x8b, |
| 1250 |
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1251 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, |
| 1252 |
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1253 |
0x00, 0x00, |
| 1254 |
} |
| 1255 |
|
| 1256 |
func (s *S) TestIssueDate(c *check.C) { |
| 1257 |
br, err := NewReader(bytes.NewReader(issueDate), *conc) |
| 1258 |
c.Assert(err, check.Equals, nil, check.Commentf("Failed to open BAM")) |
| 1259 |
|
| 1260 |
rg := br.Header().RGs() |
| 1261 |
c.Assert(len(rg), check.Equals, 1) |
| 1262 |
expect := time.Date(2014, 03, 25, 12, 26, 51, 0, time.FixedZone("", -int(7*time.Hour/time.Second))) |
| 1263 |
c.Check(rg[0].Time(), check.DeepEquals, expect) |
| 1264 |
} |
| 1265 |
|
| 1266 |
// This is BAM data from the following SAM. |
| 1267 |
// |
| 1268 |
// @HD VN:1.0 |
| 1269 |
// @SQ SN:ref LN:1 |
| 1270 |
// @RG ID:rg DT:2014-03-25T12:26:51-0700 |
| 1271 |
// r1 125 ref -1 0 * = -1 0 A B RG:Z:rg |
| 1272 |
var issueDate = []byte{ |
| 1273 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 1274 |
0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 1275 |
0x6d, 0x00, 0x73, 0x72, 0xf4, 0x65, 0x74, 0x64, |
| 1276 |
0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, 0x0c, 0xf3, |
| 1277 |
0xb3, 0x32, 0xd4, 0x33, 0xe0, 0x72, 0x08, 0x0e, |
| 1278 |
0xe4, 0x0c, 0xf6, 0xb3, 0x2a, 0x4a, 0x4d, 0xe3, |
| 1279 |
0xf4, 0x01, 0x8a, 0x70, 0x39, 0x04, 0xb9, 0x73, |
| 1280 |
0x7a, 0xba, 0x58, 0x15, 0xa5, 0x73, 0xba, 0x84, |
| 1281 |
0x58, 0x19, 0x19, 0x18, 0x9a, 0xe8, 0x1a, 0x18, |
| 1282 |
0xeb, 0x1a, 0x99, 0x86, 0x18, 0x1a, 0x59, 0x19, |
| 1283 |
0x99, 0x59, 0x99, 0x1a, 0xea, 0x1a, 0x98, 0x1b, |
| 1284 |
0x18, 0x70, 0x31, 0x02, 0x0d, 0x61, 0x01, 0x62, |
| 1285 |
0xa0, 0x36, 0x06, 0x10, 0x1b, 0x00, 0x38, 0x08, |
| 1286 |
0xd9, 0xec, 0x59, 0x00, 0x00, 0x00, 0x1f, 0x8b, |
| 1287 |
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1288 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x38, 0x00, |
| 1289 |
0xd3, 0x66, 0x80, 0x80, 0xff, 0x40, 0xc0, 0xcc, |
| 1290 |
0xe0, 0x21, 0xc4, 0xc0, 0x50, 0xcb, 0xc0, 0x88, |
| 1291 |
0x24, 0x06, 0xa2, 0x8b, 0x0c, 0x19, 0x04, 0x14, |
| 1292 |
0x83, 0xdc, 0xa3, 0x8a, 0xd2, 0x19, 0x00, 0xe6, |
| 1293 |
0x18, 0xef, 0x3c, 0x2f, 0x00, 0x00, 0x00, 0x1f, |
| 1294 |
0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1295 |
0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, |
| 1296 |
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1297 |
0x00, 0x00, 0x00, |
| 1298 |
} |
| 1299 |
|
| 1300 |
var baiTestData = []struct { |
| 1301 |
data []byte |
| 1302 |
expect *Index |
| 1303 |
err error |
| 1304 |
}{ |
| 1305 |
{ |
| 1306 |
/* |
| 1307 |
0x42, 0x41, 0x49, 0x01, // BAI\1 |
| 1308 |
0x01, 0x00, 0x00, 0x00, // n_ref |
| 1309 |
|
| 1310 |
0x02, 0x00, 0x00, 0x00, // n_bin |
| 1311 |
|
| 1312 |
0x49, 0x12, 0x00, 0x00, // bin |
| 1313 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1314 |
|
| 1315 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1316 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1317 |
|
| 1318 |
0x4a, 0x92, 0x00, 0x00, // bin - always 0x924a |
| 1319 |
0x02, 0x00, 0x00, 0x00, // n_chunk - always 2 |
| 1320 |
|
| 1321 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_beg |
| 1322 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // unmapped_end |
| 1323 |
|
| 1324 |
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mapped_count |
| 1325 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_count |
| 1326 |
|
| 1327 |
0x01, 0x00, 0x00, 0x00, // n_intv |
| 1328 |
|
| 1329 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // ioffset |
| 1330 |
|
| 1331 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // n_no_coor |
| 1332 |
*/ |
| 1333 |
data: []byte{ |
| 1334 |
0x42, 0x41, 0x49, 0x01, 0x01, 0x00, 0x00, 0x00, |
| 1335 |
0x02, 0x00, 0x00, 0x00, 0x49, 0x12, 0x00, 0x00, |
| 1336 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1337 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1338 |
0x00, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, |
| 1339 |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1340 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1341 |
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 1342 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1343 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1344 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1345 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1346 |
}, |
| 1347 |
expect: &Index{idx: internal.Index{ |
| 1348 |
Refs: []internal.RefIndex{ |
| 1349 |
{ |
| 1350 |
Bins: []internal.Bin{ |
| 1351 |
{ |
| 1352 |
Bin: 4681, Chunks: []bgzf.Chunk{ |
| 1353 |
{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1354 |
}, |
| 1355 |
}, |
| 1356 |
}, |
| 1357 |
Stats: &internal.ReferenceStats{ |
| 1358 |
Chunk: bgzf.Chunk{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1359 |
Mapped: 8, |
| 1360 |
Unmapped: 1, |
| 1361 |
}, |
| 1362 |
Intervals: []bgzf.Offset{{File: 98, Block: 0}}, |
| 1363 |
}, |
| 1364 |
}, |
| 1365 |
Unmapped: uint64ptr(1), |
| 1366 |
IsSorted: true, |
| 1367 |
LastRecord: maxInt, |
| 1368 |
}}, |
| 1369 |
err: nil, |
| 1370 |
}, |
| 1371 |
{ |
| 1372 |
/* |
| 1373 |
0x42, 0x41, 0x49, 0x01, // BAI\1 |
| 1374 |
0x01, 0x00, 0x00, 0x00, // n_ref |
| 1375 |
|
| 1376 |
0x02, 0x00, 0x00, 0x00, // n_bin |
| 1377 |
|
| 1378 |
0x49, 0x12, 0x00, 0x00, // bin |
| 1379 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1380 |
|
| 1381 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1382 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1383 |
|
| 1384 |
0x4a, 0x92, 0x00, 0x00, // bin - always 0x924a |
| 1385 |
0x02, 0x00, 0x00, 0x00, // n_chunk - always 2 |
| 1386 |
|
| 1387 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_beg |
| 1388 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // unmapped_end |
| 1389 |
|
| 1390 |
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mapped_count |
| 1391 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_count |
| 1392 |
|
| 1393 |
0x01, 0x00, 0x00, 0x00, // n_intv |
| 1394 |
|
| 1395 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // ioffset |
| 1396 |
*/ |
| 1397 |
data: []byte{ |
| 1398 |
0x42, 0x41, 0x49, 0x01, 0x01, 0x00, 0x00, 0x00, |
| 1399 |
0x02, 0x00, 0x00, 0x00, 0x49, 0x12, 0x00, 0x00, |
| 1400 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1401 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1402 |
0x00, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, |
| 1403 |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1404 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1405 |
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 1406 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1407 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1408 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1409 |
}, |
| 1410 |
expect: &Index{idx: internal.Index{ |
| 1411 |
Refs: []internal.RefIndex{ |
| 1412 |
{ |
| 1413 |
Bins: []internal.Bin{ |
| 1414 |
{ |
| 1415 |
Bin: 4681, Chunks: []bgzf.Chunk{ |
| 1416 |
{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1417 |
}, |
| 1418 |
}, |
| 1419 |
}, |
| 1420 |
Stats: &internal.ReferenceStats{ |
| 1421 |
Chunk: bgzf.Chunk{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1422 |
Mapped: 8, |
| 1423 |
Unmapped: 1, |
| 1424 |
}, |
| 1425 |
Intervals: []bgzf.Offset{{File: 98, Block: 0}}, |
| 1426 |
}, |
| 1427 |
}, |
| 1428 |
Unmapped: nil, |
| 1429 |
IsSorted: true, |
| 1430 |
LastRecord: maxInt, |
| 1431 |
}}, |
| 1432 |
err: nil, |
| 1433 |
}, |
| 1434 |
{ |
| 1435 |
/* |
| 1436 |
0x42, 0x41, 0x49, 0x01, // BAI\1 |
| 1437 |
0x01, 0x00, 0x00, 0x00, // n_ref |
| 1438 |
|
| 1439 |
0x01, 0x00, 0x00, 0x00, // n_bin |
| 1440 |
|
| 1441 |
0x49, 0x12, 0x00, 0x00, // bin |
| 1442 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1443 |
|
| 1444 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1445 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1446 |
|
| 1447 |
0x01, 0x00, 0x00, 0x00, // n_intv |
| 1448 |
|
| 1449 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // ioffset |
| 1450 |
|
| 1451 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // n_no_coor |
| 1452 |
*/ |
| 1453 |
data: []byte{ |
| 1454 |
0x42, 0x41, 0x49, 0x01, 0x01, 0x00, 0x00, 0x00, |
| 1455 |
0x01, 0x00, 0x00, 0x00, 0x49, 0x12, 0x00, 0x00, |
| 1456 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1457 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1458 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1459 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1460 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1461 |
}, |
| 1462 |
expect: &Index{idx: internal.Index{ |
| 1463 |
Refs: []internal.RefIndex{ |
| 1464 |
{ |
| 1465 |
Bins: []internal.Bin{ |
| 1466 |
{ |
| 1467 |
Bin: 4681, Chunks: []bgzf.Chunk{ |
| 1468 |
{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1469 |
}, |
| 1470 |
}, |
| 1471 |
}, |
| 1472 |
Stats: nil, |
| 1473 |
Intervals: []bgzf.Offset{{File: 98, Block: 0}}, |
| 1474 |
}, |
| 1475 |
}, |
| 1476 |
Unmapped: uint64ptr(1), |
| 1477 |
IsSorted: true, |
| 1478 |
LastRecord: maxInt, |
| 1479 |
}}, |
| 1480 |
err: nil, |
| 1481 |
}, |
| 1482 |
{ |
| 1483 |
/* |
| 1484 |
0x42, 0x41, 0x49, 0x01, // BAI\1 |
| 1485 |
0x01, 0x00, 0x00, 0x00, // n_ref |
| 1486 |
|
| 1487 |
0x01, 0x00, 0x00, 0x00, // n_bin |
| 1488 |
|
| 1489 |
0x49, 0x12, 0x00, 0x00, // bin |
| 1490 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1491 |
|
| 1492 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1493 |
0x00, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1494 |
|
| 1495 |
0x01, 0x00, 0x00, 0x00, // n_intv |
| 1496 |
|
| 1497 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // ioffset |
| 1498 |
*/ |
| 1499 |
data: []byte{ |
| 1500 |
0x42, 0x41, 0x49, 0x01, 0x01, 0x00, 0x00, 0x00, |
| 1501 |
0x01, 0x00, 0x00, 0x00, 0x49, 0x12, 0x00, 0x00, |
| 1502 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, |
| 1503 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, |
| 1504 |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 1505 |
0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1506 |
}, |
| 1507 |
expect: &Index{idx: internal.Index{ |
| 1508 |
Refs: []internal.RefIndex{ |
| 1509 |
{ |
| 1510 |
Bins: []internal.Bin{ |
| 1511 |
{ |
| 1512 |
Bin: 4681, Chunks: []bgzf.Chunk{ |
| 1513 |
{Begin: bgzf.Offset{File: 98, Block: 0}, End: bgzf.Offset{File: 401, Block: 0}}, |
| 1514 |
}, |
| 1515 |
}, |
| 1516 |
}, |
| 1517 |
Stats: nil, |
| 1518 |
Intervals: []bgzf.Offset{{File: 98, Block: 0}}, |
| 1519 |
}, |
| 1520 |
}, |
| 1521 |
Unmapped: nil, |
| 1522 |
IsSorted: true, |
| 1523 |
LastRecord: maxInt, |
| 1524 |
}}, |
| 1525 |
err: nil, |
| 1526 |
}, |
| 1527 |
{ |
| 1528 |
/* |
| 1529 |
0x42, 0x41, 0x49, 0x01, // BAI\1 |
| 1530 |
0x56, 0x00, 0x00, 0x00, // n_ref |
| 1531 |
|
| 1532 |
0x00, 0x00, 0x00, 0x00, // empty bins |
| 1533 |
[ lines removed ] |
| 1534 |
0x00, 0x00, 0x00, 0x00, // empty intervals |
| 1535 |
|
| 1536 |
0x02, 0x00, 0x00, 0x00, // n_bins - ref 23 |
| 1537 |
0x4a, 0x92, 0x00, 0x00, // bin - always 0x924a |
| 1538 |
0x02, 0x00, 0x00, 0x00, // n_chunk - always 2 |
| 1539 |
0x00, 0x00, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_beg |
| 1540 |
0xf9, 0x1c, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_end |
| 1541 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mapped_count |
| 1542 |
0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_count |
| 1543 |
|
| 1544 |
0x70, 0x20, 0x00, 0x00, // bin |
| 1545 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1546 |
0x00, 0x00, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1547 |
0xf9, 0x1c, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1548 |
|
| 1549 |
0x00, 0x00, 0x00, 0x00, // n_intv - ref 23 |
| 1550 |
|
| 1551 |
0x02, 0x00, 0x00, 0x00, // n_bins - ref 24 |
| 1552 |
0x4a, 0x92, 0x00, 0x00, // bin - always 0x924a |
| 1553 |
0x02, 0x00, 0x00, 0x00, // n_chunk - always 2 |
| 1554 |
0xf9, 0x1c, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_beg |
| 1555 |
0x1d, 0x40, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_end |
| 1556 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mapped_count |
| 1557 |
0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_count |
| 1558 |
|
| 1559 |
0x4a, 0x12, 0x00, 0x00, // bin |
| 1560 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1561 |
0xf9, 0x1c, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1562 |
0x1d, 0x40, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1563 |
|
| 1564 |
0x00, 0x00, 0x00, 0x00, // n_intv - ref 24 |
| 1565 |
|
| 1566 |
0x00, 0x00, 0x00, 0x00, // empty bins |
| 1567 |
[ lines removed ] |
| 1568 |
0x00, 0x00, 0x00, 0x00, // empty intervals |
| 1569 |
|
| 1570 |
0x02, 0x00, 0x00, 0x00, // n_bins - ref 72 |
| 1571 |
0x53, 0x12, 0x00, 0x00, // bin |
| 1572 |
0x01, 0x00, 0x00, 0x00, // n_chunk |
| 1573 |
0x1d, 0x40, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_beg |
| 1574 |
0xf5, 0x41, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // chunk_end |
| 1575 |
|
| 1576 |
0x4a, 0x92, 0x00, 0x00, // bin - always 0x924a |
| 1577 |
0x02, 0x00, 0x00, 0x00, // n_chunk - always 2 |
| 1578 |
0x1d, 0x40, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_beg |
| 1579 |
0xf5, 0x41, 0x46, 0x12, 0x00, 0x00, 0x00, 0x00, // unmapped_end |
| 1580 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mapped_count |
| 1581 |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // unmapped_count |
| 1582 |
|
| 1583 |
0x00, 0x00, 0x00, 0x00, // n_intv - ref 72 |
| 1584 |
|
| 1585 |
0x00, 0x00, 0x00, 0x00, // empty bins |
| 1586 |
[ lines removed ] |
| 1587 |
0x00, 0x00, 0x00, 0x00, // empty intervals |
| 1588 |
|
| 1589 |
0xa4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // n_no_coor |
| 1590 |
*/ |
| 1591 |
data: []byte{ |
| 1592 |
0x42, 0x41, 0x49, 0x01, 0x56, 0x00, 0x00, 0x00, |
| 1593 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1594 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1595 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1596 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1597 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1598 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1599 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1600 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1601 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1602 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1603 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1604 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1605 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1606 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1607 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1608 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1609 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1610 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1611 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1612 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1613 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1614 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1615 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1616 |
0x02, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, |
| 1617 |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, |
| 1618 |
0x00, 0x00, 0x00, 0x00, 0xf9, 0x1c, 0x46, 0x12, |
| 1619 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1620 |
0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, |
| 1621 |
0x00, 0x00, 0x00, 0x00, 0x70, 0x20, 0x00, 0x00, |
| 1622 |
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, |
| 1623 |
0x00, 0x00, 0x00, 0x00, 0xf9, 0x1c, 0x46, 0x12, |
| 1624 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1625 |
0x02, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, |
| 1626 |
0x02, 0x00, 0x00, 0x00, 0xf9, 0x1c, 0x46, 0x12, |
| 1627 |
0x00, 0x00, 0x00, 0x00, 0x1d, 0x40, 0x46, 0x12, |
| 1628 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1629 |
0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, |
| 1630 |
0x00, 0x00, 0x00, 0x00, 0x4a, 0x12, 0x00, 0x00, |
| 1631 |
0x01, 0x00, 0x00, 0x00, 0xf9, 0x1c, 0x46, 0x12, |
| 1632 |
0x00, 0x00, 0x00, 0x00, 0x1d, 0x40, 0x46, 0x12, |
| 1633 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1634 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1635 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1636 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1637 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1638 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1639 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1640 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1641 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1642 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1643 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1644 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1645 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1646 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1647 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1648 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1649 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1650 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1651 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1652 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1653 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1654 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1655 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1656 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1657 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1658 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1659 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1660 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1661 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1662 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1663 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1664 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1665 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1666 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1667 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1668 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1669 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1670 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1671 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1672 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1673 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1674 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1675 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1676 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1677 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1678 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1679 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1680 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1681 |
0x02, 0x00, 0x00, 0x00, 0x53, 0x12, 0x00, 0x00, |
| 1682 |
0x01, 0x00, 0x00, 0x00, 0x1d, 0x40, 0x46, 0x12, |
| 1683 |
0x00, 0x00, 0x00, 0x00, 0xf5, 0x41, 0x46, 0x12, |
| 1684 |
0x00, 0x00, 0x00, 0x00, 0x4a, 0x92, 0x00, 0x00, |
| 1685 |
0x02, 0x00, 0x00, 0x00, 0x1d, 0x40, 0x46, 0x12, |
| 1686 |
0x00, 0x00, 0x00, 0x00, 0xf5, 0x41, 0x46, 0x12, |
| 1687 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1688 |
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 1689 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1690 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1691 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1692 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1693 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1694 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1695 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1696 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1697 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1698 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1699 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1700 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1701 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1702 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1703 |
0xa4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1704 |
}, |
| 1705 |
expect: &Index{idx: internal.Index{ |
| 1706 |
Refs: func() []internal.RefIndex { |
| 1707 |
idx := [86]internal.RefIndex{ |
| 1708 |
23: { |
| 1709 |
Bins: []internal.Bin{ |
| 1710 |
{ |
| 1711 |
Bin: 0x2070, |
| 1712 |
Chunks: []bgzf.Chunk{ |
| 1713 |
{ |
| 1714 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x0}, |
| 1715 |
End: bgzf.Offset{File: 0x1246, Block: 0x1cf9}, |
| 1716 |
}, |
| 1717 |
}, |
| 1718 |
}, |
| 1719 |
}, |
| 1720 |
Stats: &internal.ReferenceStats{ |
| 1721 |
Chunk: bgzf.Chunk{ |
| 1722 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x0}, |
| 1723 |
End: bgzf.Offset{File: 0x1246, Block: 0x1cf9}, |
| 1724 |
}, |
| 1725 |
Mapped: 0, Unmapped: 0x1d, |
| 1726 |
}, |
| 1727 |
Intervals: nil, |
| 1728 |
}, |
| 1729 |
24: { |
| 1730 |
Bins: []internal.Bin{ |
| 1731 |
{ |
| 1732 |
Bin: 0x124a, |
| 1733 |
Chunks: []bgzf.Chunk{ |
| 1734 |
{ |
| 1735 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x1cf9}, |
| 1736 |
End: bgzf.Offset{File: 0x1246, Block: 0x401d}, |
| 1737 |
}, |
| 1738 |
}, |
| 1739 |
}, |
| 1740 |
}, |
| 1741 |
Stats: &internal.ReferenceStats{ |
| 1742 |
Chunk: bgzf.Chunk{ |
| 1743 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x1cf9}, |
| 1744 |
End: bgzf.Offset{File: 0x1246, Block: 0x401d}, |
| 1745 |
}, |
| 1746 |
Mapped: 0, Unmapped: 0x25, |
| 1747 |
}, |
| 1748 |
Intervals: nil, |
| 1749 |
}, |
| 1750 |
72: { |
| 1751 |
Bins: []internal.Bin{ |
| 1752 |
{ |
| 1753 |
Bin: 0x1253, |
| 1754 |
Chunks: []bgzf.Chunk{ |
| 1755 |
{ |
| 1756 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x401d}, |
| 1757 |
End: bgzf.Offset{File: 0x1246, Block: 0x41f5}, |
| 1758 |
}, |
| 1759 |
}, |
| 1760 |
}, |
| 1761 |
}, |
| 1762 |
Stats: &internal.ReferenceStats{ |
| 1763 |
Chunk: bgzf.Chunk{ |
| 1764 |
Begin: bgzf.Offset{File: 0x1246, Block: 0x401d}, |
| 1765 |
End: bgzf.Offset{File: 0x1246, Block: 0x41f5}, |
| 1766 |
}, |
| 1767 |
Mapped: 0, Unmapped: 0x2, |
| 1768 |
}, |
| 1769 |
Intervals: nil, |
| 1770 |
}, |
| 1771 |
} |
| 1772 |
return idx[:] |
| 1773 |
}(), |
| 1774 |
Unmapped: uint64ptr(932), |
| 1775 |
IsSorted: true, |
| 1776 |
LastRecord: maxInt, |
| 1777 |
}}, |
| 1778 |
err: nil, |
| 1779 |
}, |
| 1780 |
} |
| 1781 |
|
| 1782 |
func uint64ptr(i uint64) *uint64 { |
| 1783 |
return &i |
| 1784 |
} |
| 1785 |
|
| 1786 |
func (s *S) TestReadBAI(c *check.C) { |
| 1787 |
for _, test := range baiTestData { |
| 1788 |
bai, err := ReadIndex(bytes.NewReader(test.data)) |
| 1789 |
c.Assert(err, check.Equals, test.err) |
| 1790 |
c.Check(bai, check.DeepEquals, test.expect) |
| 1791 |
} |
| 1792 |
} |
| 1793 |
|
| 1794 |
// conceptualBAIdata is gzip compressed BAI for the alignments in the BAM |
| 1795 |
// corresponding to: |
| 1796 |
// |
| 1797 |
// @HD VN:1.0 SO:coordinate |
| 1798 |
// @SQ SN:conceptual LN:134217728 |
| 1799 |
// 60m66m:bin0 0 conceptual 62914561 40 6291456M * 0 0 * * |
| 1800 |
// 70m76m:bin2 0 conceptual 73400321 40 6291456M * 0 0 * * |
| 1801 |
// 73m75m:bin18 0 conceptual 76546049 40 2097152M * 0 0 * * |
| 1802 |
// |
| 1803 |
// This is a coordinate-translated version of the conceptual example in the |
| 1804 |
// SAM spec using binning as actually used by BAM rather than as presented. |
| 1805 |
var conceptualBAIdata = []byte{ |
| 1806 |
0x1f, 0x8b, 0x08, 0x08, 0xe3, 0xf6, 0x2c, 0x54, |
| 1807 |
0x00, 0x03, 0x63, 0x6f, 0x6e, 0x63, 0x65, 0x70, |
| 1808 |
0x74, 0x75, 0x61, 0x6c, 0x2e, 0x62, 0x61, 0x6d, |
| 1809 |
0x2e, 0x62, 0x61, 0x69, 0x00, 0xed, 0xcb, 0x41, |
| 1810 |
0x0d, 0x85, 0x30, 0x10, 0x40, 0xc1, 0x2d, 0xa0, |
| 1811 |
0x00, 0x2d, 0x18, 0x80, 0x1b, 0xf8, 0x20, 0x41, |
| 1812 |
0x0f, 0x8a, 0x10, 0xf3, 0x85, 0xfc, 0xa4, 0xb4, |
| 1813 |
0x07, 0x08, 0x0a, 0x60, 0xe6, 0xb0, 0x2f, 0x6d, |
| 1814 |
0xb7, 0xd3, 0x38, 0xa7, 0x14, 0x11, 0x5d, 0x9c, |
| 1815 |
0x52, 0x9e, 0x6b, 0x9e, 0x43, 0x69, 0x53, 0xee, |
| 1816 |
0xeb, 0x79, 0x2b, 0x5d, 0xf6, 0xf3, 0xad, 0xee, |
| 1817 |
0x47, 0xfc, 0xf2, 0x6c, 0xe3, 0xaa, 0x2f, 0xff, |
| 1818 |
0xb7, 0xdb, 0xde, 0xd1, 0x07, 0x00, 0x00, 0x00, |
| 1819 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1820 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1821 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1822 |
0x00, 0x00, 0xf0, 0x68, 0x55, 0x55, 0x55, 0x55, |
| 1823 |
0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x97, 0x76, |
| 1824 |
0x50, 0x55, 0x55, 0x55, 0xd5, 0x4f, 0xb5, 0xfa, |
| 1825 |
0x03, 0x6e, 0x81, 0xb2, 0xab, 0x88, 0x96, 0x00, |
| 1826 |
0x00, |
| 1827 |
} |
| 1828 |
|
| 1829 |
var conceptualBAMdata = []byte{ |
| 1830 |
// sam.Header block [{File:0, Block:0}, {File:0, Block:87}). |
| 1831 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1832 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x64, 0x00, 0x73, 0x72, |
| 1833 |
0xf4, 0x65, 0xb4, 0x60, 0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, |
| 1834 |
0x0c, 0xf3, 0xb3, 0x32, 0xd4, 0x33, 0xe0, 0x0c, 0xf6, 0xb7, |
| 1835 |
0x4a, 0xce, 0xcf, 0x2f, 0x4a, 0xc9, 0xcc, 0x4b, 0x2c, 0x49, |
| 1836 |
0xe5, 0x72, 0x08, 0x0e, 0xe4, 0x0c, 0xf6, 0x03, 0x8a, 0xe4, |
| 1837 |
0x25, 0xa7, 0x16, 0x94, 0x94, 0x26, 0xe6, 0x70, 0xfa, 0x00, |
| 1838 |
0x95, 0x19, 0x9b, 0x18, 0x19, 0x9a, 0x9b, 0x1b, 0x59, 0x70, |
| 1839 |
0x31, 0x02, 0xf5, 0x72, 0x03, 0x31, 0x42, 0x1e, 0xc8, 0x61, |
| 1840 |
0xe0, 0x00, 0x00, 0x42, 0x51, 0xcc, 0xea, 0x57, 0x00, 0x00, |
| 1841 |
0x00, |
| 1842 |
|
| 1843 |
// Record block [{File:101, Block:0}, {File:101, Block:157}). |
| 1844 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1845 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x62, 0x00, 0x33, 0x60, |
| 1846 |
0x80, 0x81, 0x03, 0xcc, 0x3c, 0x1a, 0x0c, 0x0c, 0x8c, 0x50, |
| 1847 |
0xde, 0x7f, 0x28, 0x00, 0xb1, 0xcd, 0x0c, 0x72, 0xcd, 0xcc, |
| 1848 |
0x72, 0xad, 0x92, 0x32, 0xf3, 0x0c, 0x40, 0x5c, 0x36, 0x03, |
| 1849 |
0xb8, 0x9e, 0x04, 0x16, 0x1e, 0x0d, 0x26, 0xac, 0x7a, 0xcc, |
| 1850 |
0x0d, 0x72, 0xcd, 0x21, 0x7a, 0x8c, 0xc0, 0x7a, 0x0c, 0xe1, |
| 1851 |
0x7a, 0x26, 0xb0, 0xf0, 0x6a, 0x08, 0x61, 0xd7, 0x63, 0x9c, |
| 1852 |
0x6b, 0x6e, 0x0a, 0xd6, 0x63, 0x68, 0x01, 0xe2, 0x33, 0x01, |
| 1853 |
0x00, 0x5a, 0x80, 0xfe, 0xec, 0x9d, 0x00, 0x00, 0x00, |
| 1854 |
|
| 1855 |
// Magic block [{File:200, Block:0}, {File:200, Block:0}). |
| 1856 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, |
| 1857 |
0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, 0x00, |
| 1858 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1859 |
|
| 1860 |
// End {File:228, Block:0} |
| 1861 |
} |
| 1862 |
|
| 1863 |
// conceptualChunks differs from the chunks described in chunkTests |
| 1864 |
// since samtools defines the end offset of the last chunk as the |
| 1865 |
// end of the file. We define it as the end of the chunk itself. |
| 1866 |
var conceptualChunks = []bgzf.Chunk{ |
| 1867 |
{Begin: bgzf.Offset{File: 0, Block: 0}, End: bgzf.Offset{File: 0, Block: 87}}, // header |
| 1868 |
{Begin: bgzf.Offset{File: 101, Block: 0}, End: bgzf.Offset{File: 101, Block: 52}}, // 60m66m:bin0 |
| 1869 |
{Begin: bgzf.Offset{File: 101, Block: 52}, End: bgzf.Offset{File: 101, Block: 104}}, // 70m76m:bin2 |
| 1870 |
{Begin: bgzf.Offset{File: 101, Block: 104}, End: bgzf.Offset{File: 101, Block: 157}}, // 73m75m:bin18 |
| 1871 |
{Begin: bgzf.Offset{File: 101, Block: 153}, End: bgzf.Offset{File: 101, Block: 157}}, // EOF - not checked. |
| 1872 |
} |
| 1873 |
|
| 1874 |
func (s *S) TestConceptualBAM(c *check.C) { |
| 1875 |
br, err := NewReader(bytes.NewReader(conceptualBAMdata), *conc) |
| 1876 |
c.Assert(err, check.Equals, nil) |
| 1877 |
c.Check(br.LastChunk(), check.Equals, conceptualChunks[0]) |
| 1878 |
for _, chunk := range conceptualChunks[1:] { |
| 1879 |
_, err := br.Read() |
| 1880 |
if err != nil { |
| 1881 |
break |
| 1882 |
} |
| 1883 |
c.Check(br.LastChunk(), check.Equals, chunk) |
| 1884 |
} |
| 1885 |
} |
| 1886 |
|
| 1887 |
var chunkTests = []struct { |
| 1888 |
beg, end int |
| 1889 |
expect []bgzf.Chunk |
| 1890 |
err error |
| 1891 |
}{ |
| 1892 |
{ |
| 1893 |
beg: 65000, end: 71000, // Not in covered region. |
| 1894 |
expect: []bgzf.Chunk{ |
| 1895 |
{Begin: bgzf.Offset{File: 101, Block: 0}, End: bgzf.Offset{File: 101, Block: 52}}, |
| 1896 |
}, |
| 1897 |
err: nil, |
| 1898 |
}, |
| 1899 |
{ |
| 1900 |
beg: 77594624, end: 80740352, // 73m77m:bin2+bin18 - This is the equivalent to the given example. |
| 1901 |
expect: []bgzf.Chunk{ |
| 1902 |
{Begin: bgzf.Offset{File: 101, Block: 52}, End: bgzf.Offset{File: 228, Block: 0}}, |
| 1903 |
}, |
| 1904 |
err: nil, |
| 1905 |
}, |
| 1906 |
{ |
| 1907 |
beg: 62914561, end: 68157440, // 60m65m:bin0+bin2 |
| 1908 |
expect: []bgzf.Chunk{ |
| 1909 |
{Begin: bgzf.Offset{File: 101, Block: 0}, End: bgzf.Offset{File: 101, Block: 104}}, |
| 1910 |
}, |
| 1911 |
err: nil, |
| 1912 |
}, |
| 1913 |
{ |
| 1914 |
beg: 72351744, end: 80740352, // 69m77m:bin0+bin2+18 |
| 1915 |
expect: []bgzf.Chunk{ |
| 1916 |
{Begin: bgzf.Offset{File: 101, Block: 0}, End: bgzf.Offset{File: 228, Block: 0}}, |
| 1917 |
}, |
| 1918 |
err: nil, |
| 1919 |
}, |
| 1920 |
{ |
| 1921 |
beg: 61865984, end: 80740352, // 59m77m:bin0+bin2+bin18 |
| 1922 |
expect: []bgzf.Chunk{ |
| 1923 |
{Begin: bgzf.Offset{File: 101, Block: 0}, End: bgzf.Offset{File: 228, Block: 0}}, |
| 1924 |
}, |
| 1925 |
err: nil, |
| 1926 |
}, |
| 1927 |
{ |
| 1928 |
beg: 80740352, end: 81788928, // 77m78m - Not in covered region. |
| 1929 |
expect: nil, |
| 1930 |
err: index.ErrInvalid, |
| 1931 |
}, |
| 1932 |
} |
| 1933 |
|
| 1934 |
func (s *S) TestConceptualBAI(c *check.C) { |
| 1935 |
gz, err := gzip.NewReader(bytes.NewReader(conceptualBAIdata)) |
| 1936 |
c.Assert(err, check.Equals, nil) |
| 1937 |
bai, err := ReadIndex(gz) |
| 1938 |
c.Assert(err, check.Equals, nil) |
| 1939 |
|
| 1940 |
var ref sam.Reference |
| 1941 |
var h sam.Header |
| 1942 |
h.AddReference(&ref) |
| 1943 |
|
| 1944 |
for _, test := range chunkTests { |
| 1945 |
chunks, err := bai.Chunks(&ref, test.beg, test.end) |
| 1946 |
c.Check(err, check.Equals, test.err, |
| 1947 |
check.Commentf("Unexpected error for [%d,%d).", test.beg, test.end), |
| 1948 |
) |
| 1949 |
c.Check(chunks, check.DeepEquals, test.expect, |
| 1950 |
check.Commentf("Unexpected result for [%d,%d).", test.beg, test.end), |
| 1951 |
) |
| 1952 |
} |
| 1953 |
} |
| 1954 |
|
| 1955 |
// @HD VN:1.0 SO:coordinate |
| 1956 |
// @SQ SN:conceptual LN:134217728 |
| 1957 |
// 60m66m:bin0 0 conceptual 62914561 40 6291456M * 0 0 * * |
| 1958 |
// 70m76m:bin2 0 conceptual 73400321 40 6291456M * 0 0 * * |
| 1959 |
// 73m75m:bin18 0 conceptual 76546049 40 2097152M * 0 0 * * |
| 1960 |
var ( |
| 1961 |
conceptual = func() *sam.Reference { |
| 1962 |
ref, err := sam.NewReference("conceptual", "0", "unicorns", 134217728, nil, nil) |
| 1963 |
if err != nil { |
| 1964 |
panic("Failed to initialise conceptual reference") |
| 1965 |
} |
| 1966 |
// Ensure the reference id is valid. |
| 1967 |
sam.NewHeader(nil, []*sam.Reference{ref}) |
| 1968 |
return ref |
| 1969 |
}() |
| 1970 |
bamFile = []struct { |
| 1971 |
rec *sam.Record |
| 1972 |
chunk bgzf.Chunk |
| 1973 |
}{ |
| 1974 |
{ |
| 1975 |
rec: &sam.Record{ |
| 1976 |
Name: "60m66m:bin0", // [62914560,69206016) |
| 1977 |
Ref: conceptual, |
| 1978 |
Pos: 62914560, |
| 1979 |
MapQ: 40, |
| 1980 |
Cigar: sam.Cigar{ |
| 1981 |
sam.NewCigarOp(sam.CigarMatch, 6291456), |
| 1982 |
}, |
| 1983 |
}, |
| 1984 |
chunk: bgzf.Chunk{ |
| 1985 |
Begin: bgzf.Offset{File: 101, Block: 0}, |
| 1986 |
End: bgzf.Offset{File: 101, Block: 52}, |
| 1987 |
}, |
| 1988 |
}, |
| 1989 |
{ |
| 1990 |
rec: &sam.Record{ |
| 1991 |
Name: "70m76m:bin2", // [73400320,79691776) |
| 1992 |
Ref: conceptual, |
| 1993 |
Pos: 73400320, |
| 1994 |
MapQ: 40, |
| 1995 |
Cigar: sam.Cigar{ |
| 1996 |
sam.NewCigarOp(sam.CigarMatch, 6291456), |
| 1997 |
}, |
| 1998 |
}, |
| 1999 |
chunk: bgzf.Chunk{ |
| 2000 |
Begin: bgzf.Offset{File: 101, Block: 52}, |
| 2001 |
End: bgzf.Offset{File: 101, Block: 104}, |
| 2002 |
}, |
| 2003 |
}, |
| 2004 |
{ |
| 2005 |
rec: &sam.Record{ |
| 2006 |
Name: "73m75m:bin18", // [76546048,78643200) |
| 2007 |
Ref: conceptual, |
| 2008 |
Pos: 76546048, |
| 2009 |
MapQ: 40, |
| 2010 |
Cigar: sam.Cigar{ |
| 2011 |
sam.NewCigarOp(sam.CigarMatch, 2097152), |
| 2012 |
}, |
| 2013 |
}, |
| 2014 |
chunk: bgzf.Chunk{ |
| 2015 |
Begin: bgzf.Offset{File: 101, Block: 104}, |
| 2016 |
End: bgzf.Offset{File: 228, Block: 0}, |
| 2017 |
}, |
| 2018 |
}, |
| 2019 |
} |
| 2020 |
) |
| 2021 |
|
| 2022 |
func (s *S) TestAdd(c *check.C) { |
| 2023 |
var bai Index |
| 2024 |
for _, r := range bamFile { |
| 2025 |
c.Assert(bai.Add(r.rec, r.chunk), check.Equals, nil) |
| 2026 |
} |
| 2027 |
gz, err := gzip.NewReader(bytes.NewReader(conceptualBAIdata)) |
| 2028 |
c.Assert(err, check.Equals, nil) |
| 2029 |
expect, err := ReadIndex(gz) |
| 2030 |
c.Check(bai.idx.Refs[0].Bins, check.DeepEquals, expect.idx.Refs[0].Bins) |
| 2031 |
c.Check(bai.idx.Refs[0].Stats, check.DeepEquals, expect.idx.Refs[0].Stats) |
| 2032 |
c.Check(bai.idx.Unmapped, check.DeepEquals, expect.idx.Unmapped) |
| 2033 |
|
| 2034 |
// We check naively for overlap with tiles since we do not merge chunks in Add. |
| 2035 |
for i := range bai.idx.Refs[0].Intervals { |
| 2036 |
got := bai.idx.Refs[0].Intervals[i] |
| 2037 |
tbeg := i * internal.TileWidth |
| 2038 |
tend := tbeg + internal.TileWidth |
| 2039 |
hasOverlap := false |
| 2040 |
for _, r := range bamFile { |
| 2041 |
if tbeg < r.rec.End() && tend > r.rec.Start() { |
| 2042 |
c.Check(got, check.Equals, r.chunk.Begin, |
| 2043 |
check.Commentf("Unexpected tile offset for [%d,%d) got:%+v expect:%+v", tbeg, tend, got, r.chunk.Begin), |
| 2044 |
) |
| 2045 |
hasOverlap = true |
| 2046 |
break |
| 2047 |
} |
| 2048 |
} |
| 2049 |
if !hasOverlap { |
| 2050 |
c.Check(got, check.Equals, bgzf.Offset{}, |
| 2051 |
check.Commentf("Unexpected non-zero offset for [%d,%d) got:%+v", tbeg, tend, got), |
| 2052 |
) |
| 2053 |
} |
| 2054 |
} |
| 2055 |
} |
| 2056 |
|
| 2057 |
var chunkMergeTests = []struct { |
| 2058 |
index func() *Index |
| 2059 |
|
| 2060 |
expectAdjacent *Index |
| 2061 |
|
| 2062 |
expectSquash *Index |
| 2063 |
|
| 2064 |
compStrat index.MergeStrategy |
| 2065 |
expectCompress *Index |
| 2066 |
}{ |
| 2067 |
{ |
| 2068 |
index: func() *Index { |
| 2069 |
return &Index{idx: internal.Index{ |
| 2070 |
Refs: []internal.RefIndex{ |
| 2071 |
{ |
| 2072 |
Bins: []internal.Bin{ |
| 2073 |
{ |
| 2074 |
Bin: 0, |
| 2075 |
Chunks: []bgzf.Chunk{ |
| 2076 |
{ |
| 2077 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2078 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2079 |
}, |
| 2080 |
{ |
| 2081 |
Begin: bgzf.Offset{File: 2, Block: 0}, |
| 2082 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2083 |
}, |
| 2084 |
}, |
| 2085 |
}, |
| 2086 |
{ |
| 2087 |
Bin: 1, |
| 2088 |
Chunks: []bgzf.Chunk{ |
| 2089 |
{ |
| 2090 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2091 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2092 |
}, |
| 2093 |
{ |
| 2094 |
Begin: bgzf.Offset{File: 2, Block: 0}, |
| 2095 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2096 |
}, |
| 2097 |
}, |
| 2098 |
}, |
| 2099 |
}, |
| 2100 |
}, |
| 2101 |
}, |
| 2102 |
}} |
| 2103 |
}, |
| 2104 |
expectAdjacent: &Index{idx: internal.Index{ |
| 2105 |
Refs: []internal.RefIndex{ |
| 2106 |
{ |
| 2107 |
Bins: []internal.Bin{ |
| 2108 |
{ |
| 2109 |
Bin: 0, |
| 2110 |
Chunks: []bgzf.Chunk{ |
| 2111 |
{ |
| 2112 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2113 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2114 |
}, |
| 2115 |
}, |
| 2116 |
}, |
| 2117 |
{ |
| 2118 |
Bin: 1, |
| 2119 |
Chunks: []bgzf.Chunk{ |
| 2120 |
{ |
| 2121 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2122 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2123 |
}, |
| 2124 |
}, |
| 2125 |
}, |
| 2126 |
}, |
| 2127 |
}, |
| 2128 |
}, |
| 2129 |
}}, |
| 2130 |
expectSquash: &Index{idx: internal.Index{ |
| 2131 |
Refs: []internal.RefIndex{ |
| 2132 |
{ |
| 2133 |
Bins: []internal.Bin{ |
| 2134 |
{ |
| 2135 |
Bin: 0, |
| 2136 |
Chunks: []bgzf.Chunk{ |
| 2137 |
{ |
| 2138 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2139 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2140 |
}, |
| 2141 |
}, |
| 2142 |
}, |
| 2143 |
{ |
| 2144 |
Bin: 1, |
| 2145 |
Chunks: []bgzf.Chunk{ |
| 2146 |
{ |
| 2147 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2148 |
End: bgzf.Offset{File: 3, Block: 0}, |
| 2149 |
}, |
| 2150 |
}, |
| 2151 |
}, |
| 2152 |
}, |
| 2153 |
}, |
| 2154 |
}, |
| 2155 |
}}, |
| 2156 |
}, |
| 2157 |
{ |
| 2158 |
index: func() *Index { |
| 2159 |
return &Index{idx: internal.Index{ |
| 2160 |
Refs: []internal.RefIndex{ |
| 2161 |
{ |
| 2162 |
Bins: []internal.Bin{ |
| 2163 |
{ |
| 2164 |
Bin: 0, |
| 2165 |
Chunks: []bgzf.Chunk{ |
| 2166 |
{ |
| 2167 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2168 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2169 |
}, |
| 2170 |
{ |
| 2171 |
Begin: bgzf.Offset{File: 3, Block: 0}, |
| 2172 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2173 |
}, |
| 2174 |
}, |
| 2175 |
}, |
| 2176 |
{ |
| 2177 |
Bin: 1, |
| 2178 |
Chunks: []bgzf.Chunk{ |
| 2179 |
{ |
| 2180 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2181 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2182 |
}, |
| 2183 |
{ |
| 2184 |
Begin: bgzf.Offset{File: 3, Block: 0}, |
| 2185 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2186 |
}, |
| 2187 |
}, |
| 2188 |
}, |
| 2189 |
}, |
| 2190 |
}, |
| 2191 |
}, |
| 2192 |
}} |
| 2193 |
}, |
| 2194 |
expectAdjacent: &Index{idx: internal.Index{ |
| 2195 |
Refs: []internal.RefIndex{ |
| 2196 |
{ |
| 2197 |
Bins: []internal.Bin{ |
| 2198 |
{ |
| 2199 |
Bin: 0, |
| 2200 |
Chunks: []bgzf.Chunk{ |
| 2201 |
{ |
| 2202 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2203 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2204 |
}, |
| 2205 |
{ |
| 2206 |
Begin: bgzf.Offset{File: 3, Block: 0}, |
| 2207 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2208 |
}, |
| 2209 |
}, |
| 2210 |
}, |
| 2211 |
{ |
| 2212 |
Bin: 1, |
| 2213 |
Chunks: []bgzf.Chunk{ |
| 2214 |
{ |
| 2215 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2216 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2217 |
}, |
| 2218 |
{ |
| 2219 |
Begin: bgzf.Offset{File: 3, Block: 0}, |
| 2220 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2221 |
}, |
| 2222 |
}, |
| 2223 |
}, |
| 2224 |
}, |
| 2225 |
}, |
| 2226 |
}, |
| 2227 |
}}, |
| 2228 |
expectSquash: &Index{idx: internal.Index{ |
| 2229 |
Refs: []internal.RefIndex{ |
| 2230 |
{ |
| 2231 |
Bins: []internal.Bin{ |
| 2232 |
{ |
| 2233 |
Bin: 0, |
| 2234 |
Chunks: []bgzf.Chunk{ |
| 2235 |
{ |
| 2236 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2237 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2238 |
}, |
| 2239 |
}, |
| 2240 |
}, |
| 2241 |
{ |
| 2242 |
Bin: 1, |
| 2243 |
Chunks: []bgzf.Chunk{ |
| 2244 |
{ |
| 2245 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2246 |
End: bgzf.Offset{File: 4, Block: 0}, |
| 2247 |
}, |
| 2248 |
}, |
| 2249 |
}, |
| 2250 |
}, |
| 2251 |
}, |
| 2252 |
}, |
| 2253 |
}}, |
| 2254 |
}, |
| 2255 |
{ |
| 2256 |
index: func() *Index { |
| 2257 |
return &Index{idx: internal.Index{ |
| 2258 |
Refs: []internal.RefIndex{ |
| 2259 |
{ |
| 2260 |
Bins: []internal.Bin{ |
| 2261 |
{ |
| 2262 |
Bin: 0, |
| 2263 |
Chunks: []bgzf.Chunk{ |
| 2264 |
{ |
| 2265 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2266 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2267 |
}, |
| 2268 |
{ |
| 2269 |
Begin: bgzf.Offset{File: 0xffff, Block: 0}, |
| 2270 |
End: bgzf.Offset{File: 0x10000, Block: 0}, |
| 2271 |
}, |
| 2272 |
}, |
| 2273 |
}, |
| 2274 |
{ |
| 2275 |
Bin: 1, |
| 2276 |
Chunks: []bgzf.Chunk{ |
| 2277 |
{ |
| 2278 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2279 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2280 |
}, |
| 2281 |
{ |
| 2282 |
Begin: bgzf.Offset{File: 0x4ffff, Block: 0}, |
| 2283 |
End: bgzf.Offset{File: 0x50000, Block: 0}, |
| 2284 |
}, |
| 2285 |
}, |
| 2286 |
}, |
| 2287 |
}, |
| 2288 |
}, |
| 2289 |
}, |
| 2290 |
}} |
| 2291 |
}, |
| 2292 |
compStrat: index.CompressorStrategy(0x20000), |
| 2293 |
expectCompress: &Index{idx: internal.Index{ |
| 2294 |
Refs: []internal.RefIndex{ |
| 2295 |
{ |
| 2296 |
Bins: []internal.Bin{ |
| 2297 |
{ |
| 2298 |
Bin: 0, |
| 2299 |
Chunks: []bgzf.Chunk{ |
| 2300 |
{ |
| 2301 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2302 |
End: bgzf.Offset{File: 0x10000, Block: 0}, |
| 2303 |
}, |
| 2304 |
}, |
| 2305 |
}, |
| 2306 |
{ |
| 2307 |
Bin: 1, |
| 2308 |
Chunks: []bgzf.Chunk{ |
| 2309 |
{ |
| 2310 |
Begin: bgzf.Offset{File: 1, Block: 0}, |
| 2311 |
End: bgzf.Offset{File: 2, Block: 0}, |
| 2312 |
}, |
| 2313 |
{ |
| 2314 |
Begin: bgzf.Offset{File: 0x4ffff, Block: 0}, |
| 2315 |
End: bgzf.Offset{File: 0x50000, Block: 0}, |
| 2316 |
}, |
| 2317 |
}, |
| 2318 |
}, |
| 2319 |
}, |
| 2320 |
}, |
| 2321 |
}, |
| 2322 |
}}, |
| 2323 |
}, |
| 2324 |
} |
| 2325 |
|
| 2326 |
func (s *S) TestMergeChunks(c *check.C) { |
| 2327 |
var bai *Index |
| 2328 |
for _, test := range chunkMergeTests { |
| 2329 |
if test.expectAdjacent != nil { |
| 2330 |
bai = test.index() |
| 2331 |
bai.MergeChunks(index.Adjacent) |
| 2332 |
c.Check(bai, check.DeepEquals, test.expectAdjacent) |
| 2333 |
} |
| 2334 |
|
| 2335 |
if test.expectSquash != nil { |
| 2336 |
bai = test.index() |
| 2337 |
bai.MergeChunks(index.Squash) |
| 2338 |
c.Check(bai, check.DeepEquals, test.expectSquash) |
| 2339 |
} |
| 2340 |
|
| 2341 |
if test.expectCompress != nil { |
| 2342 |
bai = test.index() |
| 2343 |
bai.MergeChunks(test.compStrat) |
| 2344 |
c.Check(bai, check.DeepEquals, test.expectCompress) |
| 2345 |
} |
| 2346 |
} |
| 2347 |
} |
| 2348 |
|
| 2349 |
func (s *S) TestIndexRoundtrip(c *check.C) { |
| 2350 |
for i, test := range baiTestData { |
| 2351 |
expect := test.expect |
| 2352 |
var buf bytes.Buffer |
| 2353 |
c.Assert(WriteIndex(&buf, expect), check.Equals, nil) |
| 2354 |
got, err := ReadIndex(&buf) |
| 2355 |
c.Assert(err, check.Equals, nil, check.Commentf("Test %d", i)) |
| 2356 |
c.Check(got, check.DeepEquals, expect, check.Commentf("Test %d", i)) |
| 2357 |
} |
| 2358 |
} |
| 2359 |
|
| 2360 |
func (s *S) TestBufferSharing(c *check.C) { |
| 2361 |
// @HD VN:1.5 GO:none SO:coordinate |
| 2362 |
// @SQ SN:1 LN:249250621 |
| 2363 |
// A 1187 1 1000025 60 74M = 1000064 113 AGCTGGGGGTCCACTGGGCTCAGGGAAGACCCCCTGCCAGGGAGACCCCAGGCGCCTGAATGGCCACGGGAAGG BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB |
| 2364 |
// A 1107 1 1000064 60 74M = 1000064 -113 AGCTGGGGGTCCACTGGGCTCAGGGAAGACCCCCTGCCAGGGAGACCCCAGGCGCCTGAATGGCCACGGGAAGG DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD |
| 2365 |
data := []byte{ |
| 2366 |
0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, |
| 2367 |
0x64, 0x00, 0x73, 0x72, 0xf4, 0x65, 0x34, 0x67, 0x60, 0x60, 0x70, 0xf0, 0x70, 0xe1, 0x0c, 0xf3, |
| 2368 |
0xb3, 0x32, 0xd4, 0x33, 0xe5, 0x74, 0xf7, 0xb7, 0xca, 0xcb, 0xcf, 0x4b, 0xe5, 0x0c, 0xf6, 0xb7, |
| 2369 |
0x4a, 0xce, 0xcf, 0x2f, 0x4a, 0xc9, 0xcc, 0x4b, 0x2c, 0x49, 0xe5, 0x72, 0x08, 0x0e, 0xe4, 0x0c, |
| 2370 |
0x06, 0x2a, 0xe0, 0xf4, 0xf1, 0xb3, 0x32, 0x32, 0xb1, 0x34, 0x32, 0x35, 0x30, 0x33, 0x32, 0xe4, |
| 2371 |
0x62, 0x04, 0x6a, 0x65, 0x02, 0x62, 0x43, 0x06, 0x5b, 0xe7, 0xdb, 0x7c, 0x00, 0x65, 0x5c, 0xb8, |
| 2372 |
0xd2, 0x4d, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x06, |
| 2373 |
0x00, 0x42, 0x43, 0x02, 0x00, 0x73, 0x00, 0x9b, 0xca, 0x00, 0x01, 0x11, 0x4e, 0xfc, 0x0c, 0x4c, |
| 2374 |
0x36, 0x6d, 0x42, 0x8c, 0x0c, 0x8b, 0x59, 0xbc, 0xa0, 0x62, 0xf5, 0x40, 0xb1, 0x42, 0x20, 0xed, |
| 2375 |
0xc8, 0xb0, 0x80, 0x85, 0x81, 0x41, 0x44, 0xc3, 0xc5, 0xc5, 0x43, 0x49, 0xa8, 0xc5, 0x45, 0x43, |
| 2376 |
0xd1, 0xc5, 0x51, 0x44, 0x48, 0x49, 0xa9, 0x45, 0x49, 0xc4, 0x05, 0x48, 0x2b, 0xba, 0xa8, 0x28, |
| 2377 |
0xb5, 0x08, 0xb6, 0x38, 0x29, 0xaa, 0xb8, 0x08, 0xba, 0x28, 0x52, 0x0d, 0x4c, 0x45, 0x72, 0x04, |
| 2378 |
0xc4, 0x61, 0xc1, 0x28, 0x0e, 0xeb, 0xff, 0xff, 0xff, 0x3f, 0x09, 0x0e, 0x53, 0xa6, 0x1a, 0x00, |
| 2379 |
0x00, 0x16, 0x09, 0x97, 0x4a, 0x32, 0x01, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, |
| 2380 |
0x00, 0x00, 0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, |
| 2381 |
0x00, 0x00, 0x00, 0x00, 0x00, |
| 2382 |
} |
| 2383 |
r, err := NewReader(bytes.NewReader(data), 1) |
| 2384 |
c.Assert(err, check.Equals, nil) |
| 2385 |
defer r.Close() |
| 2386 |
rec, err := r.Read() |
| 2387 |
c.Assert(err, check.Equals, nil) |
| 2388 |
recClone := *rec |
| 2389 |
recClone.Seq.Seq = append(rec.Seq.Seq[:0:0], rec.Seq.Seq...) |
| 2390 |
recClone.Qual = append(rec.Qual[:0:0], rec.Qual...) |
| 2391 |
recClone.AuxFields = append(rec.AuxFields[:0:0], rec.AuxFields...) |
| 2392 |
_, err = r.Read() |
| 2393 |
c.Assert(err, check.Equals, nil) |
| 2394 |
if !reflect.DeepEqual(rec, &recClone) { |
| 2395 |
c.Errorf("unexpected record mutation:\ngot: %v\nwant:%v", |
| 2396 |
rec, &recClone) |
| 2397 |
} |
| 2398 |
} |
| 2399 |
|
| 2400 |
var fuzzCrashers = []string{ |
| 2401 |
// lText |
| 2402 |
"BAM\x01000\x86", |
| 2403 |
"BAM\x01\x00\x00\x00v", |
| 2404 |
"BAM\x01000\xef", |
| 2405 |
|
| 2406 |
// nRef |
| 2407 |
"BAM\x01\x00\x00\x00\x00000\xbd", |
| 2408 |
"BAM\x01\x00\x00\x00\x000000", |
| 2409 |
"BAM\x01\x00\x00\x00\x000000\x00\x00\x00\x000", |
| 2410 |
"BAM\x01\x00\x00\x00\x00000\xbf", |
| 2411 |
|
| 2412 |
// lName |
| 2413 |
"BAM\x01\x00\x00\x00\x000000\x00\x00\x00\x000", |
| 2414 |
"BAM\x01\x00\x00\x00\x00000\xbf", |
| 2415 |
|
| 2416 |
// reader.go 412 |
| 2417 |
"BAM\x01\xbf\xbdC_t\x0efRRUAe\x80t.V", |
| 2418 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00000\xbf" + |
| 2419 |
"e.Ce&Cell", |
| 2420 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00000\xe9", |
| 2421 |
|
| 2422 |
// Zero size buffer. |
| 2423 |
"BAM\x01\x00\x00\x00\x00\x00\x9f7R", |
| 2424 |
// Negative size buffer |
| 2425 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 2426 |
|
| 2427 |
// Short reads. |
| 2428 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x000", |
| 2429 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00\b\x00\x00\x000000" + |
| 2430 |
"0000", |
| 2431 |
|
| 2432 |
// Invalid aux tags. |
| 2433 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x000000" + |
| 2434 |
"000000000000000\xbd0000" + |
| 2435 |
"0000", |
| 2436 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x000000" + |
| 2437 |
"0000\x04000\x01\x0000\x00\x00\x00\x000000" + |
| 2438 |
"000000000000000000\x000" + |
| 2439 |
"0", |
| 2440 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x00 \r\n\xbd" + |
| 2441 |
"\xff\xff\xff\xff\aun\x00\x00\x00\u007f\x00\x00\x00\x00\x00\x00\u007f\x00\x00" + |
| 2442 |
"\x00 \r\n\xbd\xffxpect\\<invalid" + |
| 2443 |
" ", |
| 2444 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x000000" + |
| 2445 |
"0000\x01000\x00\x0000\x00\x00\x00\x000000" + |
| 2446 |
"00000000000000000000" + |
| 2447 |
"0", |
| 2448 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x000000" + |
| 2449 |
"0000\x06000\x01\x0000\x00\x00\x00\x000000" + |
| 2450 |
"00000000000000000000" + |
| 2451 |
"n", |
| 2452 |
"BAM\x01\x00\x00ewline;�\xbf\xb2\x10e" + |
| 2453 |
"�\x16\x00\x00\x00\x00\x00\xbf89rf", |
| 2454 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x000000" + |
| 2455 |
"0000\x01000\x00\x0000\x00\x00\x00\x000000" + |
| 2456 |
"00000000000\\00000000" + |
| 2457 |
"0", |
| 2458 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x000000" + |
| 2459 |
"0000\a000\x00\x0000\x00\x00\x00\x000000" + |
| 2460 |
"00000000000000000\b00" + |
| 2461 |
"0", |
| 2462 |
"BAM\x01\x00\x00ewline;�\xbf\xb2\x10e" + |
| 2463 |
"�\x16\x00\x00\x00\x00\x00\xbf89rf", |
| 2464 |
|
| 2465 |
// lSeq overflow. |
| 2466 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x000\x00\x00\x000000" + |
| 2467 |
"000000000000\xff\xff\xff\u007f0000" + |
| 2468 |
"00000000000000000000" + |
| 2469 |
"00000000", |
| 2470 |
|
| 2471 |
// B-type aux data length overflow. |
| 2472 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x000\x00\x00\x000000" + |
| 2473 |
"0000\x01000\x01\x0000\x00\x00\x00\x000000" + |
| 2474 |
"000000000000000BC000" + |
| 2475 |
"00000000", |
| 2476 |
"BAM\x01\x00\x00\x00\x00\x00\x00\x00\x000\x00\x00\x000000" + |
| 2477 |
"0000\x02000\x01\x0000\x00\x00\x00\x000000" + |
| 2478 |
"0000000000000000BB00" + |
| 2479 |
"00000000000000000000", |
| 2480 |
} |
| 2481 |
|
| 2482 |
func TestFuzzCrashers(t *testing.T) { |
| 2483 |
for i, test := range fuzzCrashers { |
| 2484 |
func() { |
| 2485 |
i := i |
| 2486 |
defer func() { |
| 2487 |
r := recover() |
| 2488 |
if r != nil { |
| 2489 |
t.Errorf("unexpected panic for crasher %d: %v", i, r) |
| 2490 |
} |
| 2491 |
}() |
| 2492 |
var buf bytes.Buffer |
| 2493 |
w := bgzf.NewWriter(&buf, 1) |
| 2494 |
_, err := w.Write([]byte(test)) |
| 2495 |
if err != nil { |
| 2496 |
t.Errorf("unexpected error preparing buffer: %v", err) |
| 2497 |
} |
| 2498 |
err = w.Close() |
| 2499 |
if err != nil { |
| 2500 |
t.Errorf("unexpected error closing buffer: %v", err) |
| 2501 |
} |
| 2502 |
|
| 2503 |
r, err := NewReader(&buf, 1) |
| 2504 |
if err != nil { |
| 2505 |
return |
| 2506 |
} |
| 2507 |
for { |
| 2508 |
_, err := r.Read() |
| 2509 |
if err != nil { |
| 2510 |
break |
| 2511 |
} |
| 2512 |
} |
| 2513 |
}() |
| 2514 |
} |
| 2515 |
} |