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
|
#
# test/unit/bio/data/test_na.rb - Unit test for Bio::NucleicAcid
#
# Copyright:: Copyright (C) 2005,2006 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/na'
module Bio
class TestNAConstants < Test::Unit::TestCase
def test_NAMES
assert_equal('a', Bio::NucleicAcid::NAMES['a'])
end
def test_NAMES_1_to_name
assert_equal('Adenine', Bio::NucleicAcid::NAMES['A'])
end
def test_WEIGHT
mw = 135.15
assert_equal(mw, Bio::NucleicAcid::WEIGHT['a'])
assert_equal(mw, Bio::NucleicAcid::WEIGHT[:adenine])
end
end
class TestNA < Test::Unit::TestCase
def setup
@obj = Bio::NucleicAcid.new
end
def test_to_re
re = /[tcy][agr][atw][gcs][tgk][acm][tgcyskb][atgrwkd][agcmrsv][atgcyrwskmbdhvn]atgc/
str = 'yrwskmbdvnatgc'
str0 = str.clone
assert_equal(re, @obj.to_re(str))
assert_equal(str0, str)
assert_equal(re, Bio::NucleicAcid.to_re(str))
end
def test_weight
mw = 135.15
assert_equal(mw, @obj.weight('a'))
assert_equal(mw, Bio::NucleicAcid.weight('a'))
end
def test_weight_rna
mw = 135.15
assert_equal(mw, @obj.weight('A', true))
assert_equal(mw, Bio::NucleicAcid.weight('A', true))
end
def test_accessor
assert_equal('Adenine', @obj['A'])
end
def test_names
assert_equal(Bio::NucleicAcid::NAMES, @obj.names)
end
def test_na
assert_equal(Bio::NucleicAcid::NAMES, @obj.na)
end
def test_name
assert_equal('Adenine', @obj.name('A'))
end
end
end
|