1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
15 type tilelibSuite struct {
20 var _ = check.Suite(&tilelibSuite{})
22 func (s *tilelibSuite) SetUpSuite(c *check.C) {
24 ggagaactgtgctccgccttcaga
25 acacatgctagcgcgtcggggtgg
26 gactctagcagagtggccagccac
27 cctcccgagccgagccacccgtca
28 gttattaataataacttatcatca
30 err := s.taglib.Load(bytes.NewBufferString(fasta))
31 c.Assert(err, check.IsNil)
32 for _, seq := range strings.Split(fasta, "\n") {
33 if len(seq) > 0 && seq[0] != '>' {
34 s.tag = append(s.tag, seq+"\n")
39 func (s *tilelibSuite) TestSkipOOO(c *check.C) {
40 matchAllChromosomes := regexp.MustCompile(".")
42 // tags appear in seq: 4, 0, 2 (but skipOOO is false)
43 tilelib := &tileLibrary{taglib: &s.taglib, skipOOO: false}
44 tseq, _, err := tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
46 "ggggggggggggggggggggggg\n"+
48 "cccccccccccccccccccc\n"+
50 "\n"), matchAllChromosomes, false)
51 c.Assert(err, check.IsNil)
52 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{4, 1}, {0, 1}, {2, 1}}})
54 // tags appear in seq: 0, 1, 2 -> don't skip
55 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
56 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
58 "cccccccccccccccccccc\n"+
60 "ggggggggggggggggggggggg\n"+
62 "\n"), matchAllChromosomes, false)
63 c.Assert(err, check.IsNil)
64 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}})
66 // tags appear in seq: 2, 3, 4 -> don't skip
67 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
68 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
70 "cccccccccccccccccccc\n"+
72 "ggggggggggggggggggggggg\n"+
74 "\n"), matchAllChromosomes, false)
75 c.Assert(err, check.IsNil)
76 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{2, 1}, {3, 1}, {4, 1}}})
78 // tags appear in seq: 4, 0, 2 -> skip 4
79 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
80 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
82 "cccccccccccccccccccc\n"+
84 "ggggggggggggggggggggggg\n"+
86 "\n"), matchAllChromosomes, false)
87 c.Assert(err, check.IsNil)
88 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {2, 1}}})
90 // tags appear in seq: 0, 2, 1 -> skip 2
91 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
92 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
94 "cccccccccccccccccccc\n"+
96 "ggggggggggggggggggggggg\n"+
98 "\n"), matchAllChromosomes, false)
99 c.Assert(err, check.IsNil)
100 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}}})
102 // tags appear in seq: 0, 1, 1, 2 -> skip second tag1
103 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true, useDups: true}
104 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
106 "cccccccccccccccccccc\n"+
108 "ggggggggggggggggggggggg\n"+
110 "ggggggggggggggggggggggg\n"+
112 "\n"), matchAllChromosomes, false)
113 c.Assert(err, check.IsNil)
114 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}})
116 // tags appear in seq: 0, 1, 3, 0, 4 -> skip second tag0
117 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true, useDups: true}
118 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
120 "cccccccccccccccccccc\n"+
122 "ggggggggggggggggggggggg\n"+
124 "ggggggggggggggggggggggg\n"+
126 "ggggggggggggggggggggggg\n"+
128 "\n"), matchAllChromosomes, false)
129 c.Assert(err, check.IsNil)
130 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}, {4, 1}}})
132 // tags appear in seq: 0, 1, 3 -> don't skip
133 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
134 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
136 "cccccccccccccccccccc\n"+
138 "ggggggggggggggggggggggg\n"+
140 "\n"), matchAllChromosomes, false)
141 c.Assert(err, check.IsNil)
142 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}}})