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