File: test_compat.rb

package info (click to toggle)
ruby-bio 2.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,108 kB
  • sloc: ruby: 68,331; perl: 13; makefile: 11; sh: 1
file content (71 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# test/unit/bio/sequence/test_compat.rb - Unit test for Bio::Sequencce::Compat
#
# Copyright::   Copyright (C) 2006 Mitsuteru C. Nakao <n@bioruby.org>
# License::     The Ruby License
#
#  $Id:$
#

# loading helper routine for testing bioruby
require 'pathname'
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
                            'bioruby_test_helper.rb')).cleanpath.to_s

# libraries needed for the tests
require 'test/unit'
require 'bio/sequence'
require 'bio/sequence/compat'

module Bio; module TestSequenceCompat
  
  class TSequence < String
    include Bio::Sequence::Common
  end


  class TestSequenceCompat < Test::Unit::TestCase

    def setup
      @obj  = TSequence.new('atgcatgcatgcatgcaaaa')
    end

    def test_to_s
      str = 'atgcatgcatgcatgcaaaa'
      assert_equal(str, @obj.to_s)
    end
  end


  class TestSequenceCommonCompat < Test::Unit::TestCase

    # Test Sequence#to_fasta    
    def test_to_fasta
      sequence = TSequence.new("agtc" * 10)
      header = "the header"
      str = ">the header\n" + ("agtc" * 5) + "\n" + ("agtc" * 5) + "\n"
      assert_equal(str, sequence.to_fasta(header, 20))
    end

  end


  require 'bio/sequence/na'

  class TestSequenceNACompat < Test::Unit::TestCase
    def test_na_self_randomize
      composition = Bio::Sequence::NA.new("acgtacgt").composition
      assert(Bio::Sequence::NA.randomize(composition))
    end
  end 

  require 'bio/sequence/aa'  

  class TestSequenceNACompat < Test::Unit::TestCase
    def test_aa_self_randomize
      composition = Bio::Sequence::AA.new("WWDTGAK").composition
      assert(Bio::Sequence::AA.randomize(composition))
    end
  end

end; end #module Bio; module TestSequenceCompat