[BioRuby-cvs] bioruby/test/unit/bio/util/restriction_enzyme/double_stranded test_aligned_strands.rb, NONE, 1.1 test_cut_location_pair.rb, NONE, 1.1 test_cut_location_pair_in_enzyme_notation.rb, NONE, 1.1 test_cut_locations.rb, NONE, 1.1 test_cut_locations_in_enzyme_notation.rb, NONE, 1.1

Trevor Wennblom trevor at pub.open-bio.org
Wed Feb 1 07:31:24 UTC 2006


Update of /home/repository/bioruby/bioruby/test/unit/bio/util/restriction_enzyme/double_stranded
In directory pub.open-bio.org:/tmp/cvs-serv28943/double_stranded

Added Files:
	test_aligned_strands.rb test_cut_location_pair.rb 
	test_cut_location_pair_in_enzyme_notation.rb 
	test_cut_locations.rb test_cut_locations_in_enzyme_notation.rb 
Log Message:
Bio::RestrictionEnzyme tests


--- NEW FILE: test_cut_locations_in_enzyme_notation.rb ---
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation'

module Bio

class TestDoubleStrandedCutLocationsInEnzymeNotation < Test::Unit::TestCase

  def setup
    @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
    @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation

    @obj_1 = @t.new([3,5])
    @obj_2 = @t.new(3, 5)
    @obj_3 = @t.new((3..5))
    @obj_4 = @t.new(-3..5)
    @obj_5 = @t.new(3)
    @obj_6 = @t.new(nil,3)
    @obj_7 = @t.new(3,nil)
    @obj_8 = @t.new(-8, -7)

    @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7, @obj_8)
    @loc_2 = @tt.new(@t.new(-2,-2), @t.new(1,1))
    @loc_3 = @tt.new(@t.new(1,2))
  end

  def test_contents
    assert_equal([3,5], @locations[0])
    assert_equal([3,nil], @locations[-2])
  end

  def test_primary
    assert_equal([3, 3, 3, -3, 3, nil, 3, -8], @locations.primary)
  end

  def test_complement
    assert_equal([5, 5, 5, 5, nil, 3, nil, -7], @locations.complement)
  end

  def test_primary_to_array_index
    assert_equal([10, 10, 10, 5, 10, nil, 10, 0], @locations.primary_to_array_index)
    assert_equal([0,2], @loc_2.primary_to_array_index)
    assert_equal([0], @loc_3.primary_to_array_index)
  end

  def test_primary_to_array_index_class
    assert_equal(Array, @locations.primary_to_array_index.class)
    assert_equal(Array, @loc_2.primary_to_array_index.class)
  end

  def test_complement_to_array_index
    assert_equal([12, 12, 12, 12, nil, 10, nil, 1], @locations.complement_to_array_index)
    assert_equal([0,2], @loc_2.complement_to_array_index)
    assert_equal([1], @loc_3.complement_to_array_index)
  end

  def test_complement_to_array_index_class
    assert_equal(Array, @locations.complement_to_array_index.class)
    assert_equal(Array, @loc_2.complement_to_array_index.class)
  end

  def test_to_array_index
    assert_equal(
      [
        [10, 12],
        [10, 12],
        [10, 12],
        [5, 12],
        [10, nil],
        [nil, 10],
        [10, nil],
        [0, 1]
      ], @locations.to_array_index)

    assert_equal(
      [
        [0, 0],
        [2, 2],
      ], @loc_2.to_array_index)

    assert_equal([[0,1]], @loc_3.to_array_index)
  end

  def test_to_array_index_class
    assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @locations.to_array_index.class)
    assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @loc_2.to_array_index.class)
  end

end

end

--- NEW FILE: test_aligned_strands.rb ---
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio/util/restriction_enzyme/double_stranded/aligned_strands'
require 'bio/util/restriction_enzyme/double_stranded'

module Bio

class TestDoubleStrandedAlignedStrands < Test::Unit::TestCase

  def setup
    @t = Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands
    @s = Bio::Sequence::NA

    @ds = Bio::RestrictionEnzyme::DoubleStranded

    @s_1 = @s.new('gattaca')
    @s_2 = @s_1.forward_complement

    @s_3 = @s.new('tttttttnnn')
    @s_4 = @s.new('nnnaaaaaaa')

    @ds_1 = @ds.new('nnnn^ngattacann^nn^n')

    @obj_1 = @t.align(@s_1, @s_2)
    @obj_2 = @t.align(@s_1, @s_3)
    @obj_3 = @t.align(@s_1, @s_4)
    @obj_4 = @t.align(@s_3, @s_4)

    @obj_5 = @t.align(@ds_1.primary, @ds_1.complement)

    @obj_8 = @t.align_with_cuts(@ds_1.primary, @ds_1.complement, @ds_1.primary.cut_locations, @ds_1.complement.cut_locations)

    @obj_6 = @t.align_with_cuts(@s_1, @s_2, [1,2], [3,4])
    @obj_7 = @t.align_with_cuts(@s_3, @s_4, [1,2], [3,4])

  end

  def test_ds
    assert_equal('nngattacannnnn', @ds_1.primary)
    assert_equal('nnnnnctaatgtnn', @ds_1.complement)
    assert_equal(    'n^ngattacann^nn^n', @ds_1.primary.with_cut_symbols)
    assert_equal('n^nn^nnctaatgtn^n'    , @ds_1.complement.with_cut_symbols)

    assert_equal([0, 10, 12], @ds_1.primary.cut_locations)
    assert_equal([0, 2, 12], @ds_1.complement.cut_locations)
  end

  def test_align
    assert_equal('gattaca', @obj_1.primary)
    assert_equal('ctaatgt', @obj_1.complement)

    assert_equal('gattacannn', @obj_2.primary)
    assert_equal('tttttttnnn', @obj_2.complement)

    assert_equal('nnngattaca', @obj_3.primary)
    assert_equal('nnnaaaaaaa', @obj_3.complement)

    assert_equal('nnntttttttnnn', @obj_4.primary)
    assert_equal('nnnaaaaaaannn', @obj_4.complement)

    assert_equal('nnnnngattacannnnn', @obj_5.primary)
    assert_equal('nnnnnctaatgtnnnnn', @obj_5.complement)
  end

  def test_align_with_cuts
    assert_equal('g a^t^t a c a', @obj_6.primary)
    assert_equal('c t a a^t^g t', @obj_6.complement)

    # Looks incorrect at first, but this is deliberate.
    # The correct cuts need to be supplied by the user.
    assert_equal('n n n t t^t^t t t t n n n', @obj_7.primary)
    assert_equal('n n n a^a^a a a a a n n n', @obj_7.complement)

    assert_equal('n n n n^n g a t t a c a n n^n n^n', @obj_8.primary)
    assert_equal('n^n n^n n c t a a t g t n^n n n n', @obj_8.complement)
  end

  def test_argument_error
    assert_raise(ArgumentError) { @t.new('arg', 'agg') }
    assert_raise(ArgumentError) { @t.new(@s.new('arg'), 'agg') }
    assert_raise(ArgumentError) { @t.new('arg', @s.new('agg')) }
    assert_raise(ArgumentError) { @t.new(@s.new('argg'), @s.new('agg')) }
  end

end

end

--- NEW FILE: test_cut_locations.rb ---
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio/util/restriction_enzyme/double_stranded/cut_locations'

module Bio

class TestDoubleStrandedCutLocations < Test::Unit::TestCase

  def setup
    @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair
    @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocations


    @obj_1 = @t.new([3,5])
    @obj_2 = @t.new(3, 5)
    @obj_3 = @t.new((3..5))
    @obj_4 = @t.new(3..5)
    @obj_5 = @t.new(3)
    @obj_6 = @t.new(nil,3)
    @obj_7 = @t.new(3,nil)

    @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7)
  end

  def test_contents
    assert_equal([3,5], @locations[0])
    assert_equal([3,nil], @locations[-1])
  end

  def test_primary
    assert_equal([3, 3, 3, 3, 3, nil, 3], @locations.primary)
  end

  def test_complement
    assert_equal([5, 5, 5, 5, nil, 3, nil], @locations.complement)
  end

end

end

--- NEW FILE: test_cut_location_pair_in_enzyme_notation.rb ---
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation'

module Bio

class TestDoubleStrandedCutLocationPairInEnzymeNotation < Test::Unit::TestCase

  def setup
    @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation

    @obj_1 = @t.new([3,5])
    @obj_2 = @t.new(3, 5)
    @obj_3 = @t.new((3..5))
    @obj_4 = @t.new(-3..5)
    @obj_5 = @t.new(3)
    @obj_6 = @t.new(nil,3)
    @obj_7 = @t.new(3,nil)
  end

  def test_contents
    assert_equal([3,5], @obj_1)
    assert_equal([3,5], @obj_2)
    assert_equal([3,5], @obj_3)
    assert_equal([-3,5], @obj_4)
    assert_equal([3,nil], @obj_5)
    assert_equal([nil,3], @obj_6)
    assert_equal([3,nil], @obj_7)
  end

  def test_primary
    assert_equal(3, @obj_1.primary)
    assert_equal(3, @obj_2.primary)
    assert_equal(3, @obj_3.primary)
    assert_equal(-3, @obj_4.primary)
    assert_equal(3, @obj_5.primary)
    assert_equal(nil, @obj_6.primary)
    assert_equal(3, @obj_7.primary)
  end

  def test_complement
    assert_equal(5, @obj_1.complement)
    assert_equal(5, @obj_2.complement)
    assert_equal(5, @obj_3.complement)
    assert_equal(5, @obj_4.complement)
    assert_equal(nil, @obj_5.complement)
    assert_equal(3, @obj_6.complement)
    assert_equal(nil, @obj_7.complement)
  end

  def test_argument_error
    assert_raise(ArgumentError) { @t.new([3,5,6]) }
    assert_raise(ArgumentError) { @t.new(0,1) }
    assert_raise(ArgumentError) { @t.new(0,0) }
    assert_raise(ArgumentError) { @t.new('3',5) }
  end

end

end

--- NEW FILE: test_cut_location_pair.rb ---
require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 6, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair'

module Bio

class TestDoubleStrandedCutLocationPair < Test::Unit::TestCase

  def setup
    @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair

    @obj_1 = @t.new([3,5])
    @obj_2 = @t.new(3, 5)
    @obj_3 = @t.new((3..5))
    @obj_4 = @t.new(0..5)
    @obj_5 = @t.new(3)
    @obj_6 = @t.new(nil,3)
    @obj_7 = @t.new(3,nil)
  end

  def test_contents
    assert_equal([3,5], @obj_1)
    assert_equal([3,5], @obj_2)
    assert_equal([3,5], @obj_3)
    assert_equal([0,5], @obj_4)
    assert_equal([3,nil], @obj_5)
    assert_equal([nil,3], @obj_6)
    assert_equal([3,nil], @obj_7)
  end

  def test_primary
    assert_equal(3, @obj_1.primary)
    assert_equal(3, @obj_2.primary)
    assert_equal(3, @obj_3.primary)
    assert_equal(0, @obj_4.primary)
    assert_equal(3, @obj_5.primary)
    assert_equal(nil, @obj_6.primary)
    assert_equal(3, @obj_7.primary)
  end

  def test_complement
    assert_equal(5, @obj_1.complement)
    assert_equal(5, @obj_2.complement)
    assert_equal(5, @obj_3.complement)
    assert_equal(5, @obj_4.complement)
    assert_equal(nil, @obj_5.complement)
    assert_equal(3, @obj_6.complement)
    assert_equal(nil, @obj_7.complement)
  end


  def test_argument_error
    assert_raise(ArgumentError) { @t.new([3,5,6]) }
    assert_raise(ArgumentError) { @t.new(3,-1) }
    assert_raise(ArgumentError) { @t.new(-3,1) }
    assert_raise(ArgumentError) { @t.new(nil,nil) }
    assert_raise(ArgumentError) { @t.new('3',5) }
  end

end

end




More information about the bioruby-cvs mailing list