test/unit/bio/sequence/test_na.rb in bio-1.0.0 vs test/unit/bio/sequence/test_na.rb in bio-1.1.0
- old
+ new
@@ -1,13 +1,13 @@
#
# = test/unit/bio/sequence/test_na.rb - Unit test for Bio::Sequencce::NA
#
# Copyright:: Copyright (C) 2006
# Mitsuteru C. Nakao <n@bioruby.org>
-# Lisence:: Ruby's
+# License:: The Ruby License
#
-# $Id: test_na.rb,v 1.1 2006/02/08 07:08:22 nakao Exp $
+# $Id: test_na.rb,v 1.5 2007/04/05 23:35:44 trevor Exp $
#
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)
@@ -96,10 +96,36 @@
assert_equal(40, @obj.gc_percent)
@obj[0, 1] = 'g'
assert_equal(45, @obj.gc_percent)
end
+ def test_gc_content
+ assert_in_delta(0.4, @obj.gc_content, Float::EPSILON)
+ @obj[0, 1] = 'g'
+ assert_in_delta(0.45, @obj.gc_content, Float::EPSILON)
+ end
+
+ def test_at_content
+ assert_in_delta(0.6, @obj.at_content, Float::EPSILON)
+ @obj[0, 1] = 'g'
+ assert_in_delta(0.55, @obj.at_content, Float::EPSILON)
+ end
+
+ def test_gc_skew
+ assert_in_delta(0.0, @obj.gc_skew, Float::EPSILON)
+ @obj[0, 1] = 'g'
+ assert_in_delta(1.0/9.0, @obj.gc_skew, Float::EPSILON)
+ @obj.gsub!(/a/, 'c')
+ assert_in_delta(-3.0/8.0, @obj.gc_skew, Float::EPSILON)
+ end
+
+ def test_at_skew
+ assert_in_delta(1.0/3.0, @obj.at_skew, Float::EPSILON)
+ @obj[0, 1] = 'g'
+ assert_in_delta(3.0/11.0, @obj.at_skew, Float::EPSILON)
+ end
+
def test_iliegal_bases
@obj[0, 1] = 'n'
@obj[1, 1] = 'y'
assert_equal(['n', 'y'], @obj.illegal_bases)
end
@@ -113,10 +139,10 @@
@obj[1,1] = 'n'
@obj[2,1] = 'r'
@obj[3,1] = 's'
@obj[4,1] = 'y'
@obj[5,1] = 'w'
- assert_equal(/a[atgc][ag][gc][tc][at]gcatgcatgcaaaa/, @obj.to_re)
+ assert_equal(/a[atgcyrwskmbdhvn][agr][gcw][tcy][atw]gcatgcatgcaaaa/, @obj.to_re)
end
def test_names
ary = ["Adenine", "Thymine", "Guanine"]
assert_equal(ary , @obj.splice("1..3").names)