]> git.donarmstrong.com Git - biopieces.git/blob - code_ruby/test/maasha/test_seq.rb
added new Biopiece merge_pair_seq
[biopieces.git] / code_ruby / test / maasha / test_seq.rb
1 #!/usr/bin/env ruby
2 $:.unshift File.join(File.dirname(__FILE__), '..', '..')
3
4 # Copyright (C) 2011 Martin A. Hansen.
5
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 # http://www.gnu.org/copyleft/gpl.html
21
22 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
23
24 # This software is part of the Biopieces framework (www.biopieces.org).
25
26 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
27
28 require 'maasha/seq'
29 require 'test/unit'
30 require 'test/helper'
31
32 class TestSeq < Test::Unit::TestCase 
33   def setup
34     @entry = Seq.new
35   end
36
37   test "Seq.new_bp returns correctly" do
38     record = {:SEQ_NAME => "test", :SEQ => "ATCG", :SEQ_TYPE => :dna, :SCORES => "hhhh"}
39     seq    = Seq.new_bp(record)
40     assert_equal("test", seq.seq_name)
41     assert_equal("ATCG", seq.seq)
42     assert_equal(:dna,  seq.type)
43     assert_equal("hhhh", seq.qual)
44   end
45
46   test "#is_dna? with no sequence type returns false" do
47     assert(@entry.is_dna? == false)
48   end
49
50   test "#is_dna? with dna sequence type returns true" do
51     @entry.type = :dna
52     assert(@entry.is_dna? == true)
53   end
54
55   test "#is_rna? with no sequence type returns false" do
56     assert(@entry.is_rna? == false)
57   end
58
59   test "#is_rna? with rna sequence type returns true" do
60     @entry.type = :rna
61     assert(@entry.is_rna? == true)
62   end
63
64   test "#is_protein? with no sequence type returns false" do
65     assert(@entry.is_protein? == false)
66   end
67
68   test "#is_protein? with protein sequence type returns true" do
69     @entry.type = :protein
70     assert_equal(true, @entry.is_protein?)
71   end
72
73   test "#type_guess without sequence raises" do
74     assert_raise(SeqError) { @entry.type_guess }
75   end
76
77   test "#type_guess with protein returns protein" do
78     @entry.seq = 'atcatcrFgatcg'
79     assert_equal(:protein, @entry.type_guess)
80   end
81
82   test "#type_guess with rna returns rna" do
83     @entry.seq = 'atcatcrUgatcg'
84     assert_equal(:rna, @entry.type_guess)
85   end
86
87   test "#type_guess with dna returns dna" do
88     @entry.seq = 'atcatcgatcg'
89     assert_equal(:dna, @entry.type_guess)
90   end
91
92   test "#type_guess! without sequence raises" do
93     assert_raise(SeqError) { @entry.type_guess! }
94   end
95
96   test "#type_guess! with protein returns protein" do
97     @entry.seq = 'atcatcrFgatcg'
98     @entry.type_guess!
99     assert_equal(:protein, @entry.type)
100   end
101
102   test "#type_guess! with rna returns rna" do
103     @entry.seq = 'atcatcrUgatcg'
104     @entry.type_guess!
105     assert_equal(:rna, @entry.type)
106   end
107
108   test "#type_guess! with dna returns dna" do
109     @entry.seq = 'atcatcgatcg'
110     @entry.type_guess!
111     assert_equal(:dna, @entry.type)
112   end
113
114   test "#length returns corretly" do
115     @entry.seq = 'ATCG'
116     assert_equal(4, @entry.length)
117   end
118
119   test "#indels returns correctly" do
120     @entry.seq = 'ATCG.-~_'
121     assert_equal(4, @entry.indels)
122   end
123
124   test "#to_rna with no sequence raises" do
125     @entry.type = :dna
126     assert_raise(SeqError) { @entry.to_rna }
127   end
128
129   test "#to_rna with bad type raises" do
130     @entry.seq  = 'ATCG'
131     @entry.type = :rna
132     assert_raise(SeqError) { @entry.to_rna }
133   end
134
135   test "#to_rna transcribes correctly" do
136     @entry.seq  = 'ATCGatcg'
137     @entry.type = :dna
138     assert_equal("AUCGaucg", @entry.to_rna)
139   end
140
141   test "#to_rna changes entry type to rna" do
142     @entry.seq  = 'ATCGatcg'
143     @entry.type = :dna
144     @entry.to_rna
145     assert_equal(:rna, @entry.type)
146   end
147
148   test "#to_dna with no sequence raises" do
149     @entry.type = :rna
150     assert_raise(SeqError) { @entry.to_dna }
151   end
152
153   test "#to_dna with bad type raises" do
154     @entry.seq  = 'AUCG'
155     @entry.type = :dna
156     assert_raise(SeqError) { @entry.to_dna }
157   end
158
159   test "#to_dna transcribes correctly" do
160     @entry.seq  = 'AUCGaucg'
161     @entry.type = :rna
162     assert_equal("ATCGatcg", @entry.to_dna)
163   end
164
165   test "#to_dna changes entry type to dna" do
166     @entry.seq  = 'AUCGaucg'
167     @entry.type = :rna
168     @entry.to_dna
169     assert_equal(:dna, @entry.type)
170   end
171
172   test "#to_bp returns correct record" do
173     @entry.seq_name = 'test'
174     @entry.seq      = 'ATCG'
175     assert_equal({:SEQ_NAME=>"test", :SEQ=>"ATCG", :SEQ_LEN=>4}, @entry.to_bp)
176   end
177
178   test "#to_bp with missing seq_name raises" do
179     @entry.seq = 'ATCG'
180     assert_raise(SeqError) { @entry.to_bp }
181   end
182
183   test "#to_bp with missing sequence raises" do
184     @entry.seq_name = 'test'
185     assert_raise(SeqError) { @entry.to_bp }
186   end
187
188   test "#to_fasta with missing seq_name raises" do
189     @entry.seq = 'ATCG'
190     assert_raise(SeqError) { @entry.to_fasta }
191   end
192
193   test "#to_fasta with empty seq_name raises" do
194     @entry.seq_name = ''
195     @entry.seq      = 'ATCG'
196     assert_raise(SeqError) { @entry.to_fasta }
197   end
198
199   test "#to_fasta with missing seq raises" do
200     @entry.seq_name = 'test'
201     assert_raise(SeqError) { @entry.to_fasta }
202   end
203
204   test "#to_fasta with empty seq raises" do
205     @entry.seq_name = 'test'
206     @entry.seq      = ''
207     assert_raise(SeqError) { @entry.to_fasta }
208   end
209
210   test "#to_fasta returns correct entry" do
211     @entry.seq_name = 'test'
212     @entry.seq      = 'ATCG'
213     assert_equal(">test\nATCG\n", @entry.to_fasta)
214   end
215
216   test "#to_fasta wraps correctly" do
217     entry = Seq.new("test", "ATCG")
218     assert_equal(">test\nAT\nCG\n", entry.to_fasta(2))
219   end
220
221   test "#to_fastq returns correct entry" do
222     @entry.seq_name = 'test'
223     @entry.seq      = 'ATCG'
224     @entry.qual     = 'hhhh'
225     assert_equal("@test\nATCG\n+\nhhhh\n", @entry.to_fastq)
226   end
227
228   test "#to_key with bad residue raises" do
229     entry = Seq.new("test", "AUCG")
230     assert_raise(SeqError) { entry.to_key }
231   end
232
233   test "#to_key returns correctly" do
234     entry = Seq.new("test", "ATCG")
235     assert_equal(54, entry.to_key)
236   end
237
238   test "#reverse returns correctly" do
239     @entry.seq = "ATCG"
240     new_entry  = @entry.reverse
241     assert_equal("GCTA", new_entry.seq)
242     assert_equal("ATCG", @entry.seq)
243   end
244
245   test "#reverse! returns correctly" do
246     @entry.seq = "ATCG"
247     @entry.reverse!
248     assert_equal("GCTA", @entry.seq)
249   end
250
251   test "#complement with no sequence raises" do
252     @entry.type = :dna
253     assert_raise(SeqError) { @entry.complement }
254   end
255
256   test "#complement with bad type raises" do
257     @entry.seq  = 'ATCG'
258     @entry.type = :protein
259     assert_raise(SeqError) { @entry.complement }
260   end
261
262   test "#complement for DNA is correct" do
263     @entry.seq  = 'ATCGatcg'
264     @entry.type = :dna
265     comp        = @entry.complement
266     assert_equal("TAGCtagc", comp.seq)
267     assert_equal("ATCGatcg", @entry.seq)
268   end
269
270   test "#complement for RNA is correct" do
271     @entry.seq  = 'AUCGaucg'
272     @entry.type = :rna
273     comp        = @entry.complement
274     assert_equal("UAGCuagc", comp.seq)
275     assert_equal("AUCGaucg", @entry.seq)
276   end
277
278   test "#complement! with no sequence raises" do
279     @entry.type = :dna
280     assert_raise(SeqError) { @entry.complement! }
281   end
282
283   test "#complement! with bad type raises" do
284     @entry.seq  = 'ATCG'
285     @entry.type = :protein
286     assert_raise(SeqError) { @entry.complement! }
287   end
288
289   test "#complement! for DNA is correct" do
290     @entry.seq  = 'ATCGatcg'
291     @entry.type = :dna
292     assert_equal("TAGCtagc", @entry.complement!.seq)
293   end
294
295   test "#complement! for RNA is correct" do
296     @entry.seq  = 'AUCGaucg'
297     @entry.type = :rna
298     assert_equal("UAGCuagc", @entry.complement!.seq)
299   end
300
301
302   test "#hamming distance returns correctly" do
303     seq1 = Seq.new("test1", "ATCG")
304     seq2 = Seq.new("test2", "atgg")
305     assert_equal(1, seq1.hamming_distance(seq2))
306   end
307
308   test "#generate with length < 1 raises" do
309     assert_raise(SeqError) { @entry.generate(-10, :dna) }
310     assert_raise(SeqError) { @entry.generate(0, :dna) }
311   end
312
313   test "#generate with bad type raises" do
314     assert_raise(SeqError) { @entry.generate(10, "foo") }
315   end
316
317   test "#generate with ok type dont raise" do
318     %w[dna rna protein].each do |type|
319       assert_nothing_raised { @entry.generate(10, type.to_sym) }
320     end
321   end
322
323   test "#shuffle returns correctly" do
324     orig       = "actgactgactgatcgatcgatcgatcgtactg" 
325     @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
326     entry_shuf = @entry.shuffle
327     assert_equal(orig, @entry.seq)
328     assert_not_equal(@entry.seq, entry_shuf.seq)
329   end
330
331   test "#shuffle! returns correctly" do
332     @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
333     assert_not_equal(@entry.seq, @entry.shuffle!.seq)
334   end
335
336   test "#<< with different types raises" do
337     @entry.seq = "atcg"
338     assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna) }
339   end
340
341   test "#<< with missing qual in one entry raises" do
342     @entry.seq  = "atcg"
343     @entry.type = :dna
344     assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna, "IIII") }
345     @entry.qual = "IIII"
346     assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna) }
347   end
348
349   test "#<< with nil qual in both entries dont raise" do
350     @entry.seq = "atcg"
351     assert_nothing_raised { @entry << Seq.new("test", "atcg") }
352   end
353
354   test "#<< with qual in both entries dont raise" do
355     @entry.seq  = "atcg"
356     @entry.type = :dna
357     @entry.qual = "IIII"
358     assert_nothing_raised { @entry << Seq.new("test", "atcg", :dna, "IIII") }
359   end
360
361   test "#<< without qual returns correctly" do
362     @entry.seq  = "atcg"
363     @entry <<  Seq.new("test", "ATCG")
364     assert_equal("atcgATCG", @entry.seq)
365   end
366
367   test "#<< with qual returns correctly" do
368     @entry.seq  = "atcg"
369     @entry.type = :dna
370     @entry.qual = "HHHH"
371     @entry <<  Seq.new("test", "ATCG", :dna, "IIII")
372     assert_equal("atcgATCG", @entry.seq)
373     assert_equal("HHHHIIII", @entry.qual)
374   end
375
376   test "#[] returns correctly" do
377     @entry.seq  = "atcg"
378     @entry.type = :dna
379     @entry.qual = "FGHI"
380
381     fail
382   end
383
384   test "[]= returns correctly" do
385     fail
386   end
387
388   test "#subseq with start < 0 raises" do
389     @entry.seq = "ATCG"
390     assert_raise(SeqError) { @entry.subseq(-1, 1) }
391   end
392
393   test "#subseq with start plus length gt seq raises" do
394     @entry.seq = "ATCG"
395     assert_raise(SeqError) { @entry.subseq(0, 5) }
396   end
397
398   test "#subseq returns correct sequence" do
399     @entry.seq  = "ATCG"
400     assert_equal("AT", @entry.subseq(0, 2).seq)
401     assert_equal("CG", @entry.subseq(2, 2).seq)
402   end
403
404   test "#subseq without length returns correct sequence" do
405     @entry.seq  = "ATCG"
406     assert_equal("ATCG", @entry.subseq(0).seq)
407     assert_equal("CG",   @entry.subseq(2).seq)
408   end
409
410   test "#subseq returns correct qual" do
411     @entry.seq  = "ATCG"
412     @entry.qual = "abcd"
413     assert_equal("ab", @entry.subseq(0, 2).qual)
414     assert_equal("cd", @entry.subseq(2, 2).qual)
415   end
416
417   test "#subseq without length returns correct qual" do
418     @entry.seq  = "ATCG"
419     @entry.qual = "abcd"
420     assert_equal("abcd", @entry.subseq(0).qual)
421     assert_equal("cd",   @entry.subseq(2).qual)
422   end
423
424   test "#subseq! with start < 0 raises" do
425     @entry.seq = "ATCG"
426     assert_raise(SeqError) { @entry.subseq!(-1, 1) }
427   end
428
429   test "#subseq! with start plus length > seq.length raises" do
430     @entry.seq = "ATCG"
431     assert_raise(SeqError) { @entry.subseq!(0, 5) }
432   end
433
434   test "#subseq! returns correct sequence" do
435     @entry.seq  = "ATCG"
436     @entry.subseq!(0, 2)
437     assert_equal("AT", @entry.seq)
438     @entry.seq  = "ATCG"
439     @entry.subseq!(2, 2)
440     assert_equal("CG", @entry.seq)
441   end
442
443   test "#subseq! without length returns correct sequence" do
444     @entry.seq  = "ATCG"
445     @entry.subseq!(0)
446     assert_equal("ATCG", @entry.seq)
447     @entry.seq  = "ATCG"
448     @entry.subseq!(2)
449     assert_equal("CG", @entry.seq)
450   end
451
452   test "#subseq! with pos and length returns correct qual" do
453     @entry.seq  = "ATCG"
454     @entry.qual = "abcd"
455     @entry.subseq!(0, 2)
456     assert_equal("ab", @entry.qual)
457     @entry.seq  = "ATCG"
458     @entry.qual = "abcd"
459     @entry.subseq!(2, 2)
460     assert_equal("cd", @entry.qual)
461   end
462
463   test "#subseq! with pos returns correct qual" do
464     @entry.seq  = "ATCG"
465     @entry.qual = "abcd"
466     @entry.subseq!(0)
467     assert_equal("abcd", @entry.qual)
468     @entry.seq  = "ATCG"
469     @entry.qual = "abcd"
470     @entry.subseq!(2)
471     assert_equal("cd", @entry.qual)
472   end
473
474   test "#subseq_rand returns correct sequence" do
475     @entry.seq  = "ATCG"
476     assert_equal("ATCG", @entry.subseq_rand(4).seq)
477   end
478
479   test "#indels_remove without qual returns correctly" do
480     @entry.seq  = "A-T.CG~CG"
481     @entry.qual = nil
482     assert_equal("ATCGCG", @entry.indels_remove.seq)
483   end
484
485   test "#indels_remove with qual returns correctly" do
486     @entry.seq  = "A-T.CG~CG"
487     @entry.qual = "a@b@cd@fg"
488     assert_equal("ATCGCG", @entry.indels_remove.seq)
489     assert_equal("abcdfg", @entry.indels_remove.qual)
490   end
491
492   test "#composition returns correctly" do
493     @entry.seq = "AAAATTTCCG"
494     assert_equal(4, @entry.composition["A"])
495     assert_equal(3, @entry.composition["T"])
496     assert_equal(2, @entry.composition["C"])
497     assert_equal(1, @entry.composition["G"])
498     assert_equal(0, @entry.composition["X"])
499   end
500
501   test "#homopol_max returns 0 with empty sequence" do
502     @entry.seq = ""
503     assert_equal(0, @entry.homopol_max)
504   end
505
506   test "#homopol_max returns 0 with nil sequence" do
507     @entry.seq = nil
508     assert_equal(0, @entry.homopol_max)
509   end
510
511   test "#homopol_max returns 0 when not found" do
512     @entry.seq = "AtTcCcGggGnnNnn"
513     assert_equal(0, @entry.homopol_max(6))
514   end
515
516   test "#homopol_max returns correctly" do
517     @entry.seq = "AtTcCcGggGnnNnn"
518     assert_equal(5, @entry.homopol_max(3))
519   end
520
521   test "#hard_mask returns correctly" do
522     @entry.seq = "--AAAANn"
523     assert_equal(33.33, @entry.hard_mask)
524   end
525
526   test "#soft_mask returns correctly" do
527     @entry.seq = "--AAAa"
528     assert_equal(25.00, @entry.soft_mask)
529   end
530
531   test "#mask_seq_hard! with nil seq raises" do
532     @entry.seq  = nil
533     @entry.qual = ""
534
535     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
536   end
537
538   test "#mask_seq_hard! with nil qual raises" do
539     @entry.seq  = ""
540     @entry.qual = nil
541
542     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
543   end
544
545   test "#mask_seq_hard! with bad cutoff raises" do
546     assert_raise(SeqError) { @entry.mask_seq_hard!(-1) }
547     assert_raise(SeqError) { @entry.mask_seq_hard!(41) }
548   end
549
550   test "#mask_seq_hard! with OK cutoff dont raise" do
551     @entry.seq  = "ATCG"
552     @entry.qual = "RSTU"
553
554     assert_nothing_raised { @entry.mask_seq_hard!(0) }
555     assert_nothing_raised { @entry.mask_seq_hard!(40) }
556   end
557
558   test "#mask_seq_hard! returns correctly" do
559     @entry.seq  = "-ATCG"
560     @entry.qual = "33456"
561
562     assert_equal("-NNCG", @entry.mask_seq_hard!(20).seq)
563   end
564
565   test "#mask_seq_soft! with nil seq raises" do
566     @entry.seq  = nil
567     @entry.qual = ""
568
569     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
570   end
571
572   test "#mask_seq_soft! with nil qual raises" do
573     @entry.seq  = ""
574     @entry.qual = nil
575
576     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
577   end
578
579   test "#mask_seq_soft! with bad cutoff raises" do
580     assert_raise(SeqError) { @entry.mask_seq_soft!(-1) }
581     assert_raise(SeqError) { @entry.mask_seq_soft!(41) }
582   end
583
584   test "#mask_seq_soft! with OK cutoff dont raise" do
585     @entry.seq  = "ATCG"
586     @entry.qual = "RSTU"
587
588     assert_nothing_raised { @entry.mask_seq_soft!(0) }
589     assert_nothing_raised { @entry.mask_seq_soft!(40) }
590   end
591
592   test "#mask_seq_soft! returns correctly" do
593     @entry.seq  = "-ATCG"
594     @entry.qual = "33456"
595
596     assert_equal("-atCG", @entry.mask_seq_soft!(20).seq)
597   end
598
599   # qual score detection
600
601   test "#qual_base33? returns correctly" do
602     # self.qual.match(/[!-:]/)
603     @entry.qual = '!"#$%&\'()*+,-./0123456789:'
604     assert_equal(true,  @entry.qual_base33? )
605     @entry.qual = 32.chr
606     assert_equal(false, @entry.qual_base33? )
607     @entry.qual = 59.chr
608     assert_equal(false, @entry.qual_base33? )
609   end
610
611   test "#qual_base64? returns correctly" do
612     # self.qual.match(/[K-h]/)
613     @entry.qual = 'KLMNOPQRSTUVWXYZ[\]^_`abcdefgh'
614     assert_equal(true,  @entry.qual_base64? )
615     @entry.qual = 74.chr
616     assert_equal(false, @entry.qual_base64? )
617     @entry.qual = 105.chr
618     assert_equal(false, @entry.qual_base64? )
619   end
620
621   test "#qual_valid? with nil qual raises" do
622     assert_raise(SeqError) { @entry.qual_valid?(:base_33) }
623     assert_raise(SeqError) { @entry.qual_valid?(:base_64) }
624   end
625
626   test "#qual_valid? with bad encoding raises" do
627     @entry.qual = "abc"
628     assert_raise(SeqError) { @entry.qual_valid?("foobar") }
629   end
630
631   test "#qual_valid? with OK range returns correctly" do
632     @entry.qual = ((Seq::SCORE_MIN + 33).chr .. (Seq::SCORE_MAX + 33).chr).to_a.join
633     assert_equal(true,  @entry.qual_valid?(:base_33))
634     @entry.qual = ((Seq::SCORE_MIN + 64).chr .. (Seq::SCORE_MAX + 64).chr).to_a.join
635     assert_equal(true,  @entry.qual_valid?(:base_64))
636   end
637
638   test "#qual_valid? with bad range returns correctly" do
639     @entry.qual = ((Seq::SCORE_MIN + 33 - 1).chr .. (Seq::SCORE_MAX + 33).chr).to_a.join
640     assert_equal(false,  @entry.qual_valid?(:base_33))
641     @entry.qual = ((Seq::SCORE_MIN + 33).chr .. (Seq::SCORE_MAX + 33 + 1).chr).to_a.join
642     assert_equal(false,  @entry.qual_valid?(:base_33))
643
644     @entry.qual = ((Seq::SCORE_MIN + 64 - 1).chr .. (Seq::SCORE_MAX + 64).chr).to_a.join
645     assert_equal(false,  @entry.qual_valid?(:base_64))
646     @entry.qual = ((Seq::SCORE_MIN + 64).chr .. (Seq::SCORE_MAX + 64 + 1).chr).to_a.join
647     assert_equal(false,  @entry.qual_valid?(:base_64))
648   end
649
650   # convert sanger to ...
651
652   test "#qual_convert! from base33 to base33 returns OK" do
653     @entry.qual = 'BCDEFGHI'
654     assert_equal('BCDEFGHI', @entry.qual_convert!(:base_33, :base_33).qual)
655   end
656
657   test "#qual_convert! from base33 to base64 returns OK" do
658     @entry.qual = 'BCDEFGHI'
659     assert_equal('abcdefgh', @entry.qual_convert!(:base_33, :base_64).qual)
660   end
661
662   test "#qual_convert! from base64 to base64 returns OK" do
663     @entry.qual = 'BCDEFGHI'
664     assert_equal('BCDEFGHI', @entry.qual_convert!(:base_64, :base_64).qual)
665   end
666
667   test "#qual_convert! from base64 to base33 returns OK" do
668     @entry.qual = 'abcdefgh'
669     assert_equal('BCDEFGHI', @entry.qual_convert!(:base_64, :base_33).qual)
670   end
671
672   test "#qual_coerce! returns correctly" do
673     @entry.qual = ('!' .. '~').to_a.join
674     assert_equal("!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII", @entry.qual_coerce!(:base_33).qual)
675     @entry.qual = ('!' .. '~').to_a.join
676     assert_equal("!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZh\\h^_`abcdefghhhhhhhhhhhhhhhhhhhhhhh", @entry.qual_coerce!(:base_64).qual)
677   end
678
679   test "#scores_mean without qual raises" do
680     @entry.qual = nil
681     assert_raise(SeqError) { @entry.scores_mean }
682   end
683
684   test "#scores_mean returns correctly" do
685     @entry.qual = '!!II'
686     assert_equal(20.0, @entry.scores_mean)
687   end
688 end