File: test_aa.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 (92 lines) | stat: -rw-r--r-- 1,902 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#
# test/unit/bio/data/test_aa.rb - Unit test for Bio::AminoAcid
#
# Copyright::  Copyright (C) 2005 Mitsuteru 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/data/aa'

module Bio
  class TestAAConstants < Test::Unit::TestCase
    def test_bio_aminoacid
      assert_equal('Ala', Bio::AminoAcid['A'])
    end
  end


  class TestAA < Test::Unit::TestCase
    def setup
      @obj = Bio::AminoAcid.new
    end

    def test_13
      assert_equal("Ala", @obj['A'])
    end

    def test_1n
      assert_equal('alanine', @obj.name('A'))
    end

    def test_to_1_name
      assert_equal('A', @obj.to_1('alanine'))
    end

    def test_to_1_3
      assert_equal('A', @obj.to_1('Ala'))
    end

    def test_to_1_1
      assert_equal('A', @obj.to_1('A'))
    end

    def test_to_3_name
      assert_equal('Ala', @obj.to_3('alanine'))
    end

    def test_to_3_3
      assert_equal('Ala', @obj.to_3('Ala'))
    end

    def test_to_3_1
      assert_equal('Ala', @obj.to_3('A'))
    end

    def test_one2three
      assert_equal('Ala', @obj.one2three('A'))
    end

    def test_three2one
      assert_equal('A', @obj.three2one('Ala'))
    end

    def test_one2name
      assert_equal('alanine', @obj.one2name('A'))
    end

    def test_name2one
      assert_equal('A', @obj.name2one('alanine'))
    end
    
    def test_three2name
      assert_equal('alanine', @obj.three2name('Ala'))
    end

    def test_name2three
      assert_equal('Ala', @obj.name2three('alanine'))
    end
    
    def test_to_re
      assert_equal(/[DNB][EQZ]ACDEFGHIKLMNPQRSTVWYU/, @obj.to_re('BZACDEFGHIKLMNPQRSTVWYU'))
    end
  end
end