[BioRuby-cvs] bioruby/test/unit/bio test_map.rb,1.1,1.2

Jan Aerts aerts at dev.open-bio.org
Wed Jun 7 12:56:31 UTC 2006


Update of /home/repository/bioruby/bioruby/test/unit/bio
In directory dev.open-bio.org:/tmp/cvs-serv3723

Modified Files:
	test_map.rb 
Log Message:
Following changes in map.rb


Index: test_map.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_map.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_map.rb	4 May 2006 16:19:52 -0000	1.1
--- test_map.rb	7 Jun 2006 12:56:29 -0000	1.2
***************
*** 5,8 ****
--- 5,10 ----
  #               Jan Aerts <jan.aerts at bbsrc.ac.uk>
  # License::     Ruby's
+ #
+ # $Id$
  
  require 'pathname'
***************
*** 14,102 ****
  
  module Bio
! 	class TestMapSimple < Test::Unit::TestCase
! 		def setup
! 			@marker1 = Bio::Map::Marker.new('marker1')
! 			@marker2 = Bio::Map::Marker.new('marker2')
! 			@map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 'some_unit')
! 		end
  
! 		def test_attributes
! 			assert_equal("marker1", @marker1.name)
! 			assert_equal("marker2", @marker2.name)
! 			assert_equal([], @marker1.mappings)
! 			assert_equal([], @marker2.mappings)
! 			assert_equal("map1", @map1.name)
! 			assert_equal("some_unit", @map1.units)
! 			assert_equal("some_type", @map1.type)
! 			assert_equal([], @map1.mappings)
! 		end
! 	end
  
! 	class TestMapping < Test::Unit::TestCase
! 		def setup
! 			@marker1 = Bio::Map::Marker.new('marker1')
! 			@marker2 = Bio::Map::Marker.new('marker2')
! 			@map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 'some_unit')
! 		end
  
! 		def test_add_mapping_to_marker
! 			@map1.add_mapping_to_marker(@marker2, '5')
! 			assert_equal(1, @map1.mappings.length)
! 			assert_equal(1, @marker2.mappings.length)
! 			assert_equal(0, @marker1.mappings.length)
! 			assert_kind_of(Bio::Location, @map1.mappings[0].location)
! 			assert_kind_of(Bio::Location, @marker2.mappings[0].location)
! 		end
  
!     def test_add_mapping_to_map
! 			@marker1.add_mapping_to_map(@map1, '5')
! 			assert_equal(1, @map1.mappings.length)
! 			assert_equal(1, @marker1.mappings.length)
! 			assert_kind_of(Bio::Location, @map1.mappings[0].location)
! 			assert_kind_of(Bio::Location, @marker1.mappings[0].location)
      end
! 	end
  	
! 	class CloneActsLikeMap
! 		include Bio::Map::ActsLikeMap
! 	end
  	
! 	class TestActsLikeMap < Test::Unit::TestCase
! 		def test_mixin
!       clone = CloneActsLikeMap.new
! 			assert_instance_of(CloneActsLikeMap, clone)
! 			assert_respond_to(clone, 'contains_marker?')
! 			assert_respond_to(clone, 'add_mapping_to_marker')
! 		end
! 	end
! 
! 	class CloneActsLikeMarker
! 		include Bio::Map::ActsLikeMarker
! 	end
  
! 	class TestActsLikeMarker < Test::Unit::TestCase
! 		def test_mixin
! 			clone = CloneActsLikeMarker.new
! 			assert_instance_of(CloneActsLikeMarker, clone)
! 			assert_respond_to(clone, 'mapped_to?')
! 			assert_respond_to(clone, 'add_mapping_to_map')
! 		end
! 	end
  
! 	class CloneActsLikeMapAndMarker
! 		include Bio::Map::ActsLikeMap
! 		include Bio::Map::ActsLikeMarker
! 	end
  
! 	class TestActsLikeMapAndMarker < Test::Unit::TestCase
! 		def test_mixin
! 			clone = CloneActsLikeMapAndMarker.new
! 			assert_instance_of(CloneActsLikeMapAndMarker, clone)
! 			assert_respond_to(clone, 'contains_marker?')
! 			assert_respond_to(clone, 'add_mapping_to_marker')
! 			assert_respond_to(clone, 'mapped_to?')
! 			assert_respond_to(clone, 'add_mapping_to_map')
! 		end
! 	end
  
  end
--- 16,184 ----
  
  module Bio
!   class TestMapSimple < Test::Unit::TestCase
!     def setup
!       @marker1 = Bio::Map::Marker.new('marker1')
!       @marker2 = Bio::Map::Marker.new('marker2')
!       @map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 500, 'some_unit')
!     end
  
!     def test_attributes
!       assert_equal("marker1", @marker1.name)
!       assert_equal("marker2", @marker2.name)
!       assert_equal([], @marker1.mappings_as_marker)
!       assert_equal([], @marker2.mappings_as_marker)
!       assert_equal("map1", @map1.name)
!       assert_equal("some_unit", @map1.units)
!       assert_equal("some_type", @map1.type)
!       assert_equal([], @map1.mappings_as_map)
!     end
!   end
  
!   class TestMapping < Test::Unit::TestCase
!     def setup
!       @marker1 = Bio::Map::Marker.new('marker1')
!       @marker2 = Bio::Map::Marker.new('marker2')
!       @marker3 = Bio::Map::Marker.new('marker3')
!       @map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 'some_unit')
!     end
  
!     def test_add_mapping_as_map
!       @map1.add_mapping_as_map(@marker2, '5')
!       assert_equal(1, @map1.mappings_as_map.length)
!       assert_equal(1, @marker2.mappings_as_marker.length)
!       assert_equal(0, @marker1.mappings_as_marker.length)
!       assert_kind_of(Bio::Locations, @map1.mappings_as_map[0].location)
!       assert_kind_of(Bio::Locations, @marker2.mappings_as_marker[0].location)
!     end
  
!     def test_add_mapping_as_marker
!       @marker1.add_mapping_as_marker(@map1, '5')
!       assert_equal(1, @map1.mappings_as_map.length, 'Mapping as map')
!       assert_equal(1, @marker1.mappings_as_marker.length, 'Mapping as marker')
!       assert_kind_of(Bio::Locations, @map1.mappings_as_map[0].location)
!       assert_kind_of(Bio::Locations, @marker1.mappings_as_marker[0].location)
      end
!     
!     def test_mapped_to?
!       @marker1.add_mapping_as_marker(@map1, '5')
!       assert_equal(true, @marker1.mapped_to?(@map1))
!       assert_equal(false, @marker3.mapped_to?(@map1))
!     end
!     
!     def test_contains_marker?
!       @marker1.add_mapping_as_marker(@map1, '5')
!       assert_equal(true, @map1.contains_marker?(@marker1))
!       assert_equal(false, @map1.contains_marker?(@marker3))
!     end
!     
!     def test_mappings_as_map_each
!       @map1.add_mapping_as_map(@marker1, '5')
!       @marker2.add_mapping_as_marker(@map1, '7')
!       mappings = 0
!       @map1.mappings_as_map.each do |mapping|
!         mappings += 1
!       end
!       assert_equal(2, mappings)
!     end
! 
!     def test_mappings_as_marker_each
!       @map1.add_mapping_as_map(@marker1, '5')
!       @marker1.add_mapping_as_marker(@map1, '7')
!       mappings = 0
!       @marker1.mappings_as_marker.each do |mapping|
!         mappings += 1
!       end
!       assert_equal(2, mappings)
!       
!     end
!     
!     def test_multiple_mappings_between_same_marker_and_map
!       @map1.add_mapping_as_map(@marker1, '5')
!       @map1.add_mapping_as_map(@marker1, '37')
!       @marker1.add_mapping_as_marker(@map1, '53')
!       assert_equal(3, @marker1.mappings_as_marker.length)
! 
!       @marker1.add_mapping_as_marker(@map1, '53')  # This mapping should _not_ be added, because it's already defined.
!       assert_equal(3, @marker1.mappings_as_marker.length)
!     end
!     
!     def test_positions_on
!       @map1.add_mapping_as_map(@marker1, '5')
!       assert_equal(1, @marker1.mappings_as_marker.length)
!       assert_equal('5', @marker1.positions_on(@map1).collect{|p| p.first.from.to_s}.join(',')) # FIXME: Test is not correct (uses Location.first)
!       @map1.add_mapping_as_map(@marker1, '37')
!       assert_equal('5,37', @marker1.positions_on(@map1).collect{|p| p.first.from.to_s}.sort{|a,b| a.to_i <=> b.to_i}.join(',')) # FIXME: Test is not correct (uses Location.first)
!     end
!   end
  	
!   class CloneActsLikeMap
!     include Bio::Map::ActsLikeMap
!     def initialize
!       @mappings_as_map = Array.new
!     end
!     attr_accessor :mappings_as_map
!   end
  	
!   class TestActsLikeMap < Test::Unit::TestCase
!     def setup
!       @clone = CloneActsLikeMap.new
!     end
!     def test_mixin
!       assert_instance_of(CloneActsLikeMap, @clone)
!       assert_respond_to(@clone, 'contains_marker?')
!       assert_respond_to(@clone, 'add_mapping_as_map')
!       assert_equal(0, @clone.mappings_as_map.length)
!     end
!   end
  
!   class CloneActsLikeMarker
!     include Bio::Map::ActsLikeMarker
!     def initialize
!       @mappings_as_marker = Array.new
!     end
!     attr_accessor :mappings_as_marker
!   end
  
!   class TestActsLikeMarker < Test::Unit::TestCase
!     def setup
!       @clone = CloneActsLikeMarker.new
!     end
!     
!     def test_mixin
!       assert_instance_of(CloneActsLikeMarker, @clone)
!       assert_respond_to(@clone, 'mapped_to?')
!       assert_respond_to(@clone, 'add_mapping_as_marker')
!     end
!   end
  
!   class CloneActsLikeMapAndMarker
!     include Bio::Map::ActsLikeMap
!     include Bio::Map::ActsLikeMarker
!     def initialize
!       @mappings_as_map = Array.new
!       @mappings_as_marker = Array.new
!     end
!     attr_accessor :mappings_as_map, :mappings_as_marker
!   end
  
+   class TestActsLikeMapAndMarker < Test::Unit::TestCase
+     def setup
+       @clone_a = CloneActsLikeMapAndMarker.new
+       @clone_b = CloneActsLikeMapAndMarker.new
+       @clone_a.add_mapping_as_map(@clone_b, nil)
+     end
+     
+     def test_mixin
+       assert_instance_of(CloneActsLikeMapAndMarker, @clone_a)
+       assert_respond_to(@clone_a, 'contains_marker?')
+       assert_respond_to(@clone_a, 'add_mapping_as_map')
+       assert_respond_to(@clone_a, 'mapped_to?')
+       assert_respond_to(@clone_a, 'add_mapping_as_marker')
+       
+       assert_equal(1, @clone_a.mappings_as_map.length)
+       assert_equal(0, @clone_a.mappings_as_marker.length)
+       assert_equal(0, @clone_b.mappings_as_map.length)
+       assert_equal(1, @clone_b.mappings_as_marker.length)
+     end
+   end
  end




More information about the bioruby-cvs mailing list