]> git.donarmstrong.com Git - biopieces.git/blob - code_ruby/test/maasha/test_seq.rb
171e6b1ae9157205527a0613ef68fe65686bf4e7
[biopieces.git] / code_ruby / test / maasha / test_seq.rb
1 #!/usr/bin/env ruby
2
3 require 'maasha/seq'
4 require 'test/unit'
5 require 'pp'
6
7 class TestSeq < Test::Unit::TestCase 
8   def setup
9     @entry = Seq.new
10   end
11
12   #  def test_Seq# autoremoves whitespace, newlines, and carriage returns
13   #    dna = Seq.new
14   #    dna.seq = "A\tT\r\tC\nG  "
15   #    assert_equal(dna.seq, "ATCG")
16   #  end
17   
18   def test_Seq_new_bp_returns_correctly
19     record = {:SEQ_NAME => "test", :SEQ => "ATCG", :SEQ_TYPE => "dna", :SCORES => "hhhh"}
20     seq    = Seq.new_bp(record)
21     assert_equal("test", seq.seq_name)
22     assert_equal("ATCG", seq.seq)
23     assert_equal("dna",  seq.type)
24     assert_equal("hhhh", seq.qual)
25   end
26
27   def test_Seq_is_dna_with_no_sequence_type_returns_false
28     assert(@entry.is_dna? == false)
29   end
30
31   def test_Seq_is_dna_with_dna_sequence_type_returns_true
32     @entry.type = 'dna'
33     assert(@entry.is_dna? == true)
34   end
35
36   def test_Seq_is_rna_with_no_sequence_type_returns_false
37     assert(@entry.is_rna? == false)
38   end
39
40   def test_Seq_is_rna_with_rna_sequence_type_returns_true
41     @entry.type = 'rna'
42     assert(@entry.is_rna? == true)
43   end
44
45   def test_Seq_is_protein_with_no_sequence_type_returns_false
46     assert(@entry.is_protein? == false)
47   end
48
49   def test_Seq_is_protein_with_protein_sequence_type_returns_true
50     @entry.type = 'protein'
51     assert_equal(true, @entry.is_protein?)
52   end
53
54   def test_Seq_type_guess_without_sequence_raises
55     assert_raise(SeqError) { @entry.type_guess }
56   end
57
58   def test_Seq_type_guess_with_protein_returns_protein
59     @entry.seq = 'atcatcrFgatcg'
60     assert_equal('protein', @entry.type_guess)
61   end
62
63   def test_Seq_type_guess_with_rna_returns_rna
64     @entry.seq = 'atcatcrUgatcg'
65     assert_equal('rna', @entry.type_guess)
66   end
67
68   def test_Seq_type_guess_with_dna_returns_dna
69     @entry.seq = 'atcatcgatcg'
70     assert_equal('dna', @entry.type_guess)
71   end
72
73   def test_Seq_type_guess_EM_without_sequence_raises
74     assert_raise(SeqError) { @entry.type_guess! }
75   end
76
77   def test_Seq_type_guess_EM_with_protein_returns_protein
78     @entry.seq = 'atcatcrFgatcg'
79     @entry.type_guess!
80     assert_equal('protein', @entry.type)
81   end
82
83   def test_Seq_type_guess_EM_with_rna_returns_rna
84     @entry.seq = 'atcatcrUgatcg'
85     @entry.type_guess!
86     assert_equal('rna', @entry.type)
87   end
88
89   def test_Seq_type_guess_EM_with_dna_returns_dna
90     @entry.seq = 'atcatcgatcg'
91     @entry.type_guess!
92     assert_equal('dna', @entry.type)
93   end
94
95   def test_Seq_length_is_correct
96     @entry.seq = 'ATCG'
97     assert_equal(4, @entry.length)
98   end
99
100   def test_Seq_indels_is_correct
101     @entry.seq = 'ATCG.-~_'
102     assert_equal(4, @entry.indels)
103   end
104
105   def test_Seq_to_rna_raises_if_no_sequence
106     @entry.type = 'dna'
107     assert_raise(SeqError) { @entry.to_rna }
108   end
109
110   def test_Seq_to_rna_raises_on_bad_type
111     @entry.seq  = 'ATCG'
112     @entry.type = 'rna'
113     assert_raise(SeqError) { @entry.to_rna }
114   end
115
116   def test_Seq_to_rna_transcribes_correctly
117     @entry.seq  = 'ATCGatcg'
118     @entry.type = 'dna'
119     assert_equal("AUCGaucg", @entry.to_rna)
120   end
121
122   def test_Seq_to_rna_changes_entry_type_to_rna
123     @entry.seq  = 'ATCGatcg'
124     @entry.type = 'dna'
125     @entry.to_rna
126     assert_equal("rna", @entry.type)
127   end
128
129   def test_Seq_to_dna_raises_if_no_sequence
130     @entry.type = 'rna'
131     assert_raise(SeqError) { @entry.to_dna }
132   end
133
134   def test_Seq_to_dna_raises_on_bad_type
135     @entry.seq  = 'AUCG'
136     @entry.type = 'dna'
137     assert_raise(SeqError) { @entry.to_dna }
138   end
139
140   def test_Seq_to_dna_transcribes_correctly
141     @entry.seq  = 'AUCGaucg'
142     @entry.type = 'rna'
143     assert_equal("ATCGatcg", @entry.to_dna)
144   end
145
146   def test_Seq_to_dna_changes_entry_type_to_dna
147     @entry.seq  = 'AUCGaucg'
148     @entry.type = 'rna'
149     @entry.to_dna
150     assert_equal("dna", @entry.type)
151   end
152
153   def test_Seq_to_bp_returns_correct_record
154     @entry.seq_name = 'test'
155     @entry.seq      = 'ATCG'
156     assert_equal({:SEQ_NAME=>"test", :SEQ=>"ATCG", :SEQ_LEN=>4}, @entry.to_bp)
157   end
158
159   def test_Seq_to_bp_raises_on_missing_seq_name
160     @entry.seq = 'ATCG'
161     assert_raise(SeqError) { @entry.to_bp }
162   end
163
164   def test_Seq_to_bp_raises_on_missing_sequence
165     @entry.seq_name = 'test'
166     assert_raise(SeqError) { @entry.to_bp }
167   end
168
169   def test_Seq_to_fasta_raises_on_missing_seq_name
170     @entry.seq = 'ATCG'
171     assert_raise(SeqError) { @entry.to_fasta }
172   end
173
174   def test_Seq_to_fasta_raises_on_empty_seq_name
175     @entry.seq_name = ''
176     @entry.seq      = 'ATCG'
177     assert_raise(SeqError) { @entry.to_fasta }
178   end
179
180   def test_Seq_to_fasta_raises_on_missing_seq
181     @entry.seq_name = 'test'
182     assert_raise(SeqError) { @entry.to_fasta }
183   end
184
185   def test_Seq_to_fasta_raises_on_empty_seq
186     @entry.seq_name = 'test'
187     @entry.seq      = ''
188     assert_raise(SeqError) { @entry.to_fasta }
189   end
190
191   def test_Seq_to_fasta_returns_correct_entry
192     @entry.seq_name = 'test'
193     @entry.seq      = 'ATCG'
194     assert_equal(">test\nATCG\n", @entry.to_fasta)
195   end
196
197   def test_Seq_to_fasta_wraps_correctly
198     entry = Seq.new("test", "ATCG")
199     assert_equal(">test\nAT\nCG\n", entry.to_fasta(2))
200   end
201
202   def test_Seq_to_fastq_returns_correct_entry
203     @entry.seq_name = 'test'
204     @entry.seq      = 'ATCG'
205     @entry.qual     = 'hhhh'
206     assert_equal("@test\nATCG\n+\nhhhh\n", @entry.to_fastq)
207   end
208
209   def test_Seq_to_key_with_bad_residue_raises
210     entry = Seq.new("test", "AUCG")
211     assert_raise(SeqError) { entry.to_key }
212   end
213
214   def test_Seq_to_key_returns_correctly
215     entry = Seq.new("test", "ATCG")
216     assert_equal(54, entry.to_key)
217   end
218
219   def test_Seq_reverse_returns_correctly
220     @entry.seq = "ATCG"
221     assert_equal("GCTA", @entry.reverse.seq)
222   end
223
224   def test_Seq_complement_raises_if_no_sequence
225     @entry.type = 'dna'
226     assert_raise(SeqError) { @entry.complement }
227   end
228
229   def test_Seq_complement_raises_on_bad_type
230     @entry.seq  = 'ATCG'
231     @entry.type = 'protein'
232     assert_raise(SeqError) { @entry.complement }
233   end
234
235   def test_Seq_complement_for_DNA_is_correct
236     @entry.seq  = 'ATCGatcg'
237     @entry.type = 'dna'
238     assert_equal("TAGCtagc", @entry.complement)
239   end
240
241   def test_Seq_complement_for_RNA_is_correct
242     @entry.seq  = 'AUCGaucg'
243     @entry.type = 'rna'
244     assert_equal("UAGCuagc", @entry.complement)
245   end
246
247   def test_Seq_reverse_complement_for_DNA_is_correct
248     @entry.seq  = 'ATCGatcg'
249     @entry.type = 'dna'
250     assert_equal("cgatCGAT", @entry.reverse_complement.seq)
251   end
252
253   def test_Seq_reverse_complement_for_RNA_is_correct
254     @entry.seq  = 'AUCGaucg'
255     @entry.type = 'rna'
256     assert_equal("cgauCGAU", @entry.reverse_complement.seq)
257   end
258
259   def test_Seq_hamming_distance_returns_correctly
260     seq1 = Seq.new("test1", "ATCG")
261     seq2 = Seq.new("test2", "atgg")
262     assert_equal(1, seq1.hamming_distance(seq2))
263   end
264
265   def test_Seq_generate_with_length_lt_1_raises
266     assert_raise(SeqError) { @entry.generate(-10, "dna") }
267     assert_raise(SeqError) { @entry.generate(0, "dna") }
268   end
269
270   def test_Seq_generate_with_bad_type_raises
271     assert_raise(SeqError) { @entry.generate(10, "foo") }
272   end
273
274   def test_Seq_generate_with_ok_type_dont_raise
275     %w[dna DNA rna RNA protein Protein].each do |type|
276       assert_nothing_raised { @entry.generate(10, type) }
277     end
278   end
279
280   def test_Seq_subseq_with_start_lt_0_raises
281     @entry.seq = "ATCG"
282     assert_raise(SeqError) { @entry.subseq(-1, 1) }
283   end
284
285   def test_Seq_subseq_with_start_plus_length_gt_seq_raises
286     @entry.seq = "ATCG"
287     assert_raise(SeqError) { @entry.subseq(0, 5) }
288   end
289
290   def test_Seq_subseq_returns_correct_sequence
291     @entry.seq  = "ATCG"
292     assert_equal("AT", @entry.subseq(0, 2).seq)
293     assert_equal("CG", @entry.subseq(2, 2).seq)
294   end
295
296   def test_Seq_subseq_without_len_returns_correct_sequence
297     @entry.seq  = "ATCG"
298     assert_equal("ATCG", @entry.subseq(0).seq)
299     assert_equal("CG",   @entry.subseq(2).seq)
300   end
301
302   def test_Seq_subseq_returns_correct_qual
303     @entry.seq  = "ATCG"
304     @entry.qual = "abcd"
305     assert_equal("ab", @entry.subseq(0, 2).qual)
306     assert_equal("cd", @entry.subseq(2, 2).qual)
307   end
308
309   def test_Seq_subseq_without_len_returns_correct_qual
310     @entry.seq  = "ATCG"
311     @entry.qual = "abcd"
312     assert_equal("abcd", @entry.subseq(0).qual)
313     assert_equal("cd",   @entry.subseq(2).qual)
314   end
315
316   def test_Seq_subseq_bang_with_start_lt_0_raises
317     @entry.seq = "ATCG"
318     assert_raise(SeqError) { @entry.subseq!(-1, 1) }
319   end
320
321   def test_Seq_subseq_bang_with_start_plus_length_gt_seq_raises
322     @entry.seq = "ATCG"
323     assert_raise(SeqError) { @entry.subseq!(0, 5) }
324   end
325
326   def test_Seq_subseq_bang_returns_correct_sequence
327     @entry.seq  = "ATCG"
328     @entry.subseq!(0, 2)
329     assert_equal("AT", @entry.seq)
330     @entry.seq  = "ATCG"
331     @entry.subseq!(2, 2)
332     assert_equal("CG", @entry.seq)
333   end
334
335   def test_Seq_subseq_bang_without_len_returns_correct_sequence
336     @entry.seq  = "ATCG"
337     @entry.subseq!(0)
338     assert_equal("ATCG", @entry.seq)
339     @entry.seq  = "ATCG"
340     @entry.subseq!(2)
341     assert_equal("CG", @entry.seq)
342   end
343
344   def test_Seq_subseq_bang_with_pos_and_len_returns_correct_qual
345     @entry.seq  = "ATCG"
346     @entry.qual = "abcd"
347     @entry.subseq!(0, 2)
348     assert_equal("ab", @entry.qual)
349     @entry.seq  = "ATCG"
350     @entry.qual = "abcd"
351     @entry.subseq!(2, 2)
352     assert_equal("cd", @entry.qual)
353   end
354
355   def test_Seq_subseq_bang_with_pos_returns_correct_qual
356     @entry.seq  = "ATCG"
357     @entry.qual = "abcd"
358     @entry.subseq!(0)
359     assert_equal("abcd", @entry.qual)
360     @entry.seq  = "ATCG"
361     @entry.qual = "abcd"
362     @entry.subseq!(2)
363     assert_equal("cd", @entry.qual)
364   end
365
366   def test_Seq_subseq_rand_returns_correct_sequence
367     @entry.seq  = "ATCG"
368     assert_equal("ATCG", @entry.subseq_rand(4).seq)
369   end
370
371   def test_Seq_indels_remove_without_qual_returns_correctly
372     @entry.seq  = "A-T.CG~CG"
373     @entry.qual = nil
374     assert_equal("ATCGCG", @entry.indels_remove.seq)
375   end
376
377   def test_Seq_indels_remove_with_qual_returns_correctly
378     @entry.seq  = "A-T.CG~CG"
379     @entry.qual = "a@b@cd@fg"
380     assert_equal("ATCGCG", @entry.indels_remove.seq)
381     assert_equal("abcdfg", @entry.indels_remove.qual)
382   end
383
384   def test_Seq_composition_returns_correctly
385     @entry.seq = "AAAATTTCCG"
386     assert_equal(4, @entry.composition["A"])
387     assert_equal(3, @entry.composition["T"])
388     assert_equal(2, @entry.composition["C"])
389     assert_equal(1, @entry.composition["G"])
390     assert_equal(0, @entry.composition["X"])
391   end
392
393   def test_Seq_homopol_max_returns_0_with_empty_sequence
394     @entry.seq = ""
395     assert_equal(0, @entry.homopol_max)
396   end
397
398   def test_Seq_homopol_max_returns_0_with_nil_sequence
399     @entry.seq = nil
400     assert_equal(0, @entry.homopol_max)
401   end
402
403   def test_Seq_homopol_max_returns_0_when_not_found
404     @entry.seq = "AtTcCcGggGnnNnn"
405     assert_equal(0, @entry.homopol_max(6))
406   end
407
408   def test_Seq_homopol_max_returns_correctly
409     @entry.seq = "AtTcCcGggGnnNnn"
410     assert_equal(5, @entry.homopol_max(3))
411   end
412
413   def test_Seq_hard_mask_returns_correctly
414     @entry.seq = "--AAAANn"
415     assert_equal(33.33, @entry.hard_mask)
416   end
417
418   def test_Seq_soft_mask_returns_correctly
419     @entry.seq = "--AAAa"
420     assert_equal(25.00, @entry.soft_mask)
421   end
422
423   def test_Seq_mask_seq_hard_bang_with_nil_seq_raises
424     @entry.seq  = nil
425     @entry.qual = ""
426
427     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
428   end
429
430   def test_Seq_mask_seq_hard_bang_with_nil_qual_raises
431     @entry.seq  = ""
432     @entry.qual = nil
433
434     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
435   end
436
437   def test_Seq_mask_seq_hard_bang_with_bad_cutoff_raises
438     assert_raise(SeqError) { @entry.mask_seq_hard!(-1) }
439     assert_raise(SeqError) { @entry.mask_seq_hard!(41) }
440   end
441
442   def test_Seq_mask_seq_hard_bang_with_OK_cutoff_dont_raise
443     @entry.seq  = "ATCG"
444     @entry.qual = "RSTU"
445
446     assert_nothing_raised { @entry.mask_seq_hard!(0) }
447     assert_nothing_raised { @entry.mask_seq_hard!(40) }
448   end
449
450   def test_Seq_mask_seq_hard_bang_returns_correctly
451     @entry.seq  = "-ATCG"
452     @entry.qual = "RRSTU"
453
454     assert_equal("-NNCG", @entry.mask_seq_hard!(20).seq)
455   end
456
457   def test_Seq_mask_seq_soft_bang_with_nil_seq_raises
458     @entry.seq  = nil
459     @entry.qual = ""
460
461     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
462   end
463
464   def test_Seq_mask_seq_soft_bang_with_nil_qual_raises
465     @entry.seq  = ""
466     @entry.qual = nil
467
468     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
469   end
470
471   def test_Seq_mask_seq_soft_bang_with_bad_cutoff_raises
472     assert_raise(SeqError) { @entry.mask_seq_soft!(-1) }
473     assert_raise(SeqError) { @entry.mask_seq_soft!(41) }
474   end
475
476   def test_Seq_mask_seq_soft_bang_with_OK_cutoff_dont_raise
477     @entry.seq  = "ATCG"
478     @entry.qual = "RSTU"
479
480     assert_nothing_raised { @entry.mask_seq_soft!(0) }
481     assert_nothing_raised { @entry.mask_seq_soft!(40) }
482   end
483
484   def test_Seq_mask_seq_soft_bang_returns_correctly
485     @entry.seq  = "-ATCG"
486     @entry.qual = "RRSTU"
487
488     assert_equal("-atCG", @entry.mask_seq_soft!(20).seq)
489   end
490
491   # qual score detection
492
493   def test_Seq_qual_base33_returns_correctly
494     # self.qual.match(/[!-:]/)
495     @entry.qual = '!"#$%&\'()*+,-./0123456789:'
496     assert_equal(true,  @entry.qual_base33? )
497     @entry.qual = 32.chr
498     assert_equal(false, @entry.qual_base33? )
499     @entry.qual = 59.chr
500     assert_equal(false, @entry.qual_base33? )
501   end
502
503   def test_Seq_qual_base64_returns_correctly
504     # self.qual.match(/[K-h]/)
505     @entry.qual = 'KLMNOPQRSTUVWXYZ[\]^_`abcdefgh'
506     assert_equal(true,  @entry.qual_base64? )
507     @entry.qual = 74.chr
508     assert_equal(false, @entry.qual_base64? )
509     @entry.qual = 105.chr
510     assert_equal(false, @entry.qual_base64? )
511   end
512
513   def test_Seq_qual_valid_with_nil_qual_raises
514     assert_raise(SeqError) { @entry.qual_valid?("illumina1.8") }
515   end
516
517   def test_Seq_qual_valid_with_bad_encoding_raises
518     @entry.qual = "abc"
519     assert_raise(SeqError) { @entry.qual_valid?("foobar") }
520   end
521
522   def test_Seq_qual_valid_returns_correctly
523     tests = [["sanger",      0, 40, 33],
524              ["454",         0, 40, 64],
525              ["solexa",     -5, 40, 64],
526              ["illumina13",  0, 40, 64],
527              ["illumina15",  0, 40, 64],
528              ["illumina18",  0, 41, 33]]
529
530     tests.each do |test|
531       @entry.qual = (test[1] + test[-1]).chr + (test[2] + test[-1]).chr
532       assert_equal(true, @entry.qual_valid?(test[0]))
533       @entry.qual = (test[1] + test[-1] - 1).chr
534       assert_equal(false, @entry.qual_valid?(test[0]))
535       @entry.qual = (test[2] + test[-1] + 1).chr
536       assert_equal(false, @entry.qual_valid?(test[0]))
537     end
538   end
539
540   # convert sanger to ...
541
542   def test_Seq_convert_scores_bang_from_sanger_to_sanger_returns_OK
543     @entry.qual = 'BCDEFGHI'
544     assert_equal('BCDEFGHI', @entry.convert_scores!('sanger', 'sanger').qual)
545   end
546
547   def test_Seq_convert_scores_bang_from_sanger_to_solexa_returns_OK
548     @entry.qual = 'BCDEFGHI'
549     assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'solexa').qual)
550   end
551
552   def test_Seq_convert_scores_bang_from_sanger_to_illumina13_returns_OK
553     @entry.qual = 'BCDEFGHI'
554     assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'illumina13').qual)
555   end
556
557   def test_Seq_convert_scores_bang_from_sanger_to_illumina15_returns_OK
558     @entry.qual = 'BCDEFGHI'
559     assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'illumina15').qual)
560   end
561
562   def test_Seq_convert_scores_bang_from_sanger_to_illumina18_returns_OK
563     @entry.qual = 'BCDEFGHI'
564     assert_equal('BCDEFGHI', @entry.convert_scores!('sanger', 'illumina18').qual)
565   end
566
567   # convert solexa to ...
568
569   def test_Seq_convert_scores_bang_from_solexa_to_sanger_returns_OK
570     @entry.qual = 'BCDEFGHI'
571     assert_equal(%q[#$%&'()*], @entry.convert_scores!('solexa', 'sanger').qual)
572   end
573
574   def test_Seq_convert_scores_bang_from_solexa_to_solexa_returns_OK
575     @entry.qual = 'BCDEFGHI'
576     assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'solexa').qual)
577   end
578
579   def test_Seq_convert_scores_bang_from_solexa_to_illumina13_returns_OK
580     @entry.qual = 'BCDEFGHI'
581     assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'illumina13').qual)
582   end
583
584   def test_Seq_convert_scores_bang_from_solexa_to_illumina15_returns_OK
585     @entry.qual = 'BCDEFGHI'
586     assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'illumina15').qual)
587   end
588
589   def test_Seq_convert_scores_bang_from_solexa_to_illumina18_returns_OK
590     @entry.qual = 'BCDEFGHI'
591     assert_equal(%q[#$%&'()*], @entry.convert_scores!('solexa', 'illumina18').qual)
592   end
593
594   # convert illumina13 to ...
595
596   def test_Seq_convert_scores_bang_from_illumina13_to_sanger_returns_OK
597     @entry.qual = 'BCDEFGHI'
598     assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina13', 'sanger').qual)
599   end
600
601   def test_Seq_convert_scores_bang_from_illumina13_to_solexa_returns_OK
602     @entry.qual = 'BCDEFGHI'
603     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'solexa').qual)
604   end
605
606   def test_Seq_convert_scores_bang_from_illumina13_to_illumina13_returns_OK
607     @entry.qual = 'BCDEFGHI'
608     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'illumina13').qual)
609   end
610
611   def test_Seq_convert_scores_bang_from_illumina13_to_illumina15_returns_OK
612     @entry.qual = 'BCDEFGHI'
613     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'illumina15').qual)
614   end
615
616   def test_Seq_convert_scores_bang_from_illumina13_to_illumina18_returns_OK
617     @entry.qual = 'BCDEFGHI'
618     assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina13', 'illumina18').qual)
619   end
620
621   # convert illumina15 to ...
622
623   def test_Seq_convert_scores_bang_from_illumina15_to_sanger_returns_OK
624     @entry.qual = 'BCDEFGHI'
625     assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina15', 'sanger').qual)
626   end
627
628   def test_Seq_convert_scores_bang_from_illumina15_to_solexa_returns_OK
629     @entry.qual = 'BCDEFGHI'
630     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'solexa').qual)
631   end
632
633   def test_Seq_convert_scores_bang_from_illumina15_to_illumina13_returns_OK
634     @entry.qual = 'BCDEFGHI'
635     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'illumina13').qual)
636   end
637
638   def test_Seq_convert_scores_bang_from_illumina15_to_illumina15_returns_OK
639     @entry.qual = 'BCDEFGHI'
640     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'illumina15').qual)
641   end
642
643   def test_Seq_convert_scores_bang_from_illumina15_to_illumina18_returns_OK
644     @entry.qual = 'BCDEFGHI'
645     assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina15', 'illumina18').qual)
646   end
647
648   # convert illumina18 to ...
649
650   def test_Seq_convert_scores_bang_from_illumina18_to_sanger_returns_OK
651     @entry.qual = 'BCDEFGHI'
652     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina18', 'sanger').qual)
653   end
654
655   def test_Seq_convert_scores_bang_from_illumina18_to_solexa_returns_OK
656     @entry.qual = 'BCDEFGHI'
657     assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'solexa').qual)
658   end
659
660   def test_Seq_convert_scores_bang_from_illumina18_to_illumina13_returns_OK
661     @entry.qual = 'BCDEFGHI'
662     assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'illumina13').qual)
663   end
664
665   def test_Seq_convert_scores_bang_from_illumina18_to_illumina15_returns_OK
666     @entry.qual = 'BCDEFGHI'
667     assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'illumina15').qual)
668   end
669
670   def test_Seq_convert_scores_bang_from_illumina18_to_illumina18_returns_OK
671     @entry.qual = 'BCDEFGHI'
672     assert_equal('BCDEFGHI', @entry.convert_scores!('illumina18', 'illumina18').qual)
673   end
674
675   def test_Seq_scores_mean_without_qual_raises
676     @entry.qual = nil
677     assert_raise(SeqError) { @entry.scores_mean }
678   end
679
680   def test_Seq_scores_mean_returns_correctly
681     @entry.qual = '@@hh'
682     assert_equal(20.0, @entry.scores_mean)
683   end
684 end
685
686 __END__