11 type tilelibSuite struct {
16 var _ = check.Suite(&tilelibSuite{})
18 func (s *tilelibSuite) SetUpSuite(c *check.C) {
20 ggagaactgtgctccgccttcaga
21 acacatgctagcgcgtcggggtgg
22 gactctagcagagtggccagccac
23 cctcccgagccgagccacccgtca
24 gttattaataataacttatcatca
26 err := s.taglib.Load(bytes.NewBufferString(fasta))
27 c.Assert(err, check.IsNil)
28 for _, seq := range strings.Split(fasta, "\n") {
29 if len(seq) > 0 && seq[0] != '>' {
30 s.tag = append(s.tag, seq+"\n")
35 func (s *tilelibSuite) TestSkipOOO(c *check.C) {
36 matchAllChromosomes := regexp.MustCompile(".")
38 // tags appear in seq: 4, 0, 2 (but skipOOO is false)
39 tilelib := &tileLibrary{taglib: &s.taglib, skipOOO: false}
40 tseq, _, err := tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
42 "ggggggggggggggggggggggg\n"+
44 "cccccccccccccccccccc\n"+
46 "\n"), matchAllChromosomes)
47 c.Assert(err, check.IsNil)
48 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{4, 1}, {0, 1}, {2, 1}}})
50 // tags appear in seq: 0, 1, 2 -> don't skip
51 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
52 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
54 "cccccccccccccccccccc\n"+
56 "ggggggggggggggggggggggg\n"+
58 "\n"), matchAllChromosomes)
59 c.Assert(err, check.IsNil)
60 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}})
62 // tags appear in seq: 2, 3, 4 -> don't skip
63 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
64 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
66 "cccccccccccccccccccc\n"+
68 "ggggggggggggggggggggggg\n"+
70 "\n"), matchAllChromosomes)
71 c.Assert(err, check.IsNil)
72 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{2, 1}, {3, 1}, {4, 1}}})
74 // tags appear in seq: 4, 0, 2 -> skip 4
75 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
76 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
78 "cccccccccccccccccccc\n"+
80 "ggggggggggggggggggggggg\n"+
82 "\n"), matchAllChromosomes)
83 c.Assert(err, check.IsNil)
84 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {2, 1}}})
86 // tags appear in seq: 0, 2, 1 -> skip 2
87 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
88 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
90 "cccccccccccccccccccc\n"+
92 "ggggggggggggggggggggggg\n"+
94 "\n"), matchAllChromosomes)
95 c.Assert(err, check.IsNil)
96 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}}})
98 // tags appear in seq: 0, 1, 1, 2 -> skip second tag1
99 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
100 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
102 "cccccccccccccccccccc\n"+
104 "ggggggggggggggggggggggg\n"+
106 "ggggggggggggggggggggggg\n"+
108 "\n"), matchAllChromosomes)
109 c.Assert(err, check.IsNil)
110 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {2, 1}}})
112 // tags appear in seq: 0, 1, 3, 0, 4 -> skip second tag0
113 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
114 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
116 "cccccccccccccccccccc\n"+
118 "ggggggggggggggggggggggg\n"+
120 "ggggggggggggggggggggggg\n"+
122 "ggggggggggggggggggggggg\n"+
124 "\n"), matchAllChromosomes)
125 c.Assert(err, check.IsNil)
126 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}, {4, 1}}})
128 // tags appear in seq: 0, 1, 3 -> don't skip
129 tilelib = &tileLibrary{taglib: &s.taglib, skipOOO: true}
130 tseq, _, err = tilelib.TileFasta("test-label", bytes.NewBufferString(">test-seq\n"+
132 "cccccccccccccccccccc\n"+
134 "ggggggggggggggggggggggg\n"+
136 "\n"), matchAllChromosomes)
137 c.Assert(err, check.IsNil)
138 c.Check(tseq, check.DeepEquals, tileSeq{"test-seq": []tileLibRef{{0, 1}, {1, 1}, {3, 1}}})