Class: Bio::Map::Mapping

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/bio/map.rb

Overview

Description

Creates a new Bio::Map::Mapping object, which links Bio::Map::ActsAsMap- and Bio::Map::ActsAsMarker-like objects. This class is typically not accessed directly, but through map- or marker-like objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map, marker, location = nil) ⇒ Mapping

Creates a new Bio::Map::Mapping object


Arguments:

  • map: a Bio::Map::SimpleMap object

  • marker: a Bio::Map::Marker object

  • location: a Bio::Locations object



304
305
306
# File 'lib/bio/map.rb', line 304

def initialize (map, marker, location = nil)
  @map, @marker, @location = map, marker, location
end

Instance Attribute Details

#locationObject

Returns the value of attribute location.



307
308
309
# File 'lib/bio/map.rb', line 307

def location
  @location
end

#mapObject

Returns the value of attribute map.



307
308
309
# File 'lib/bio/map.rb', line 307

def map
  @map
end

#markerObject

Returns the value of attribute marker.



307
308
309
# File 'lib/bio/map.rb', line 307

def marker
  @marker
end

Instance Method Details

#<=>(other) ⇒ Object

Compares the location of this mapping to another mapping.


Arguments:

  • other_mapping: Bio::Map::Mapping object

Returns
  • 1 if self < other location

  • -1 if self > other location

  • 0 if both location are the same

  • nil if the argument is not a Bio::Location object



318
319
320
321
322
323
324
325
326
327
# File 'lib/bio/map.rb', line 318

def <=>(other)
  unless other.kind_of?(Bio::Map::Mapping)
    raise "[Error] markers are not comparable"
  end
  unless @map.equal?(other.map)
    raise "[Error] maps have to be the same"
  end

  return self.location[0].<=>(other.location[0])
end