X-Git-Url: https://git.arvados.org/lightning.git/blobdiff_plain/ba5dea916505730ed44af0655c820bd3d767be1e..e4839e500e2da73b476f095425c0347ae7c5de97:/tilelib_test.go diff --git a/tilelib_test.go b/tilelib_test.go index 0e7edd6759..5801b9baf3 100644 --- a/tilelib_test.go +++ b/tilelib_test.go @@ -1,7 +1,12 @@ -package main +// Copyright (C) The Lightning Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +package lightning import ( "bytes" + "regexp" "strings" "gopkg.in/check.v1" @@ -32,69 +37,71 @@ gttattaataataacttatcatca } func (s *tilelibSuite) TestSkipOOO(c *check.C) { + matchAllChromosomes := regexp.MustCompile(".") + // tags appear in seq: 4, 0, 2 (but skipOOO is false) tilelib := &tileLibrary{taglib: &s.taglib, skipOOO: false} - tseq, err := tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err := tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[4]+ "ggggggggggggggggggggggg\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[2]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{4, 1}, {0, 1}, {2, 1}}}) // tags appear in seq: 0, 1, 2 -> don't skip tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[1]+ "ggggggggggggggggggggggg\n"+ s.tag[2]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}}) // tags appear in seq: 2, 3, 4 -> don't skip tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[2]+ "cccccccccccccccccccc\n"+ s.tag[3]+ "ggggggggggggggggggggggg\n"+ s.tag[4]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{2, 1}, {3, 1}, {4, 1}}}) // tags appear in seq: 4, 0, 2 -> skip 4 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[4]+ "cccccccccccccccccccc\n"+ s.tag[0]+ "ggggggggggggggggggggggg\n"+ s.tag[2]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {2, 1}}}) // tags appear in seq: 0, 2, 1 -> skip 2 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[2]+ "ggggggggggggggggggggggg\n"+ s.tag[1]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}}}) // tags appear in seq: 0, 1, 1, 2 -> skip second tag1 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[1]+ @@ -102,13 +109,13 @@ func (s *tilelibSuite) TestSkipOOO(c *check.C) { s.tag[1]+ "ggggggggggggggggggggggg\n"+ s.tag[2]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}}) // tags appear in seq: 0, 1, 3, 0, 4 -> skip second tag0 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[1]+ @@ -118,19 +125,19 @@ func (s *tilelibSuite) TestSkipOOO(c *check.C) { s.tag[0]+ "ggggggggggggggggggggggg\n"+ s.tag[4]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}, {4, 1}}}) // tags appear in seq: 0, 1, 3 -> don't skip tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true} - tseq, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ + tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+ s.tag[0]+ "cccccccccccccccccccc\n"+ s.tag[1]+ "ggggggggggggggggggggggg\n"+ s.tag[3]+ - "\n")) + "\n"), matchAllChromosomes, false) c.Assert(err, check.IsNil) c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}}}) }