The Bio::Map::ActsLikeMarker module contains methods that are typical for marker-like things:
map it to one or more maps
check if it's mapped to a given map and can be mixed into other classes (e.g. Bio::Map::Marker)
Classes that include this mixin should provide an array property called mappings_as_marker.
For example:
class MyMarkerThing include Bio::Map::ActsLikeMarker def initialize (name) @name = name @mappings_as_marker = Array.new end attr_accessor :name, :mappings_as_marker end
Adds a Bio::Map::Mappings object to its array of mappings.
# suppose we have a Bio::Map::Marker object called marker_a marker_a.add_mapping_as_marker(Bio::Map::SimpleMap.new('my_map'), '5')
Arguments:
map (required): Bio::Map::SimpleMap object
location: location of mapping. Should be a string, not a number.
Returns |
itself |
# File lib/bio/map.rb, line 203 def add_mapping_as_marker(map, location = nil) unless map.class.include?(Bio::Map::ActsLikeMap) raise "[Error] map is not object that implements Bio::Map::ActsLikeMap" end my_mapping = (location.nil?) ? Bio::Map::Mappings.new(map, self, nil) : Bio::Map::Mapping.new(map, self, Bio::Locations.new(location)) if ! self.mapped_to?(map) self.mappings_as_marker.push(my_mapping) map.mappings_as_map.push(my_mapping) else already_mapped = false self.positions_on(map).each do |loc| if loc.equals?(Bio::Locations.new(location)) already_mapped = true end end if ! already_mapped self.mappings_as_marker.push(my_mapping) map.mappings_as_map.push(my_mapping) end end end
Check whether this marker is mapped to a given Bio::Map::SimpleMap.
Arguments:
map: a Bio::Map::SimpleMap object
Returns |
true or false |
# File lib/bio/map.rb, line 230 def mapped_to?(map) unless map.class.include?(Bio::Map::ActsLikeMap) raise "[Error] map is not object that implements Bio::Map::ActsLikeMap" end mapped = false self.mappings_as_marker.each do |mapping| if mapping.map == map mapped = true return mapped end end return mapped end
Return all mappings of this marker on a given map.
Arguments:
map: an object that mixes in Bio::Map::ActsLikeMap
Returns |
array of Bio::Map::Mapping objects |
# File lib/bio/map.rb, line 271 def mappings_on(map) unless map.class.include?(Bio::Map::ActsLikeMap) raise "[Error] map is not object that implements Bio::Map::ActsLikeMap" end m = Array.new self.mappings_as_marker.each do |mapping| if mapping.map == map m.push(mapping) end end return m end
Return all positions of this marker on a given map.
Arguments:
map: an object that mixes in Bio::Map::ActsLikeMap
Returns |
array of Bio::Location objects |
# File lib/bio/map.rb, line 251 def positions_on(map) unless map.class.include?(Bio::Map::ActsLikeMap) raise "[Error] map is not object that implements Bio::Map::ActsLikeMap" end positions = Array.new self.mappings_as_marker.each do |mapping| if mapping.map == map positions.push(mapping.location) end end return positions end
Generated with the Darkfish Rdoc Generator 2.