Class: Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation

Inherits:
CutLocations
  • Object
show all
Defined in:
lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb

Overview

Inherits from DoubleStranded::CutLocations. Contains CutLocationPairInEnzymeNotation objects. Adds helper methods to convert from enzyme index notation to 0-based array index notation.

Instance Method Summary collapse

Methods inherited from CutLocations

#complement, #initialize, #primary

Constructor Details

This class inherits a constructor from Bio::RestrictionEnzyme::DoubleStranded::CutLocations

Instance Method Details

#complement_to_array_indexObject

Returns Array of locations of cuts on the complementary strand in 0-based array index notation.


Arguments

  • none

Returns

Array of locations of cuts on the complementary strand in 0-based array index notation.



32
33
34
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb', line 32

def complement_to_array_index
  helper_for_to_array_index(self.complement)
end

#primary_to_array_indexObject

Returns Array of locations of cuts on the primary strand in 0-based array index notation.


Arguments

  • none

Returns

Array of locations of cuts on the primary strand in 0-based array index notation.



21
22
23
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb', line 21

def primary_to_array_index
  helper_for_to_array_index(self.primary)
end

#to_array_indexObject

Returns the contents of the present CutLocationsInEnzymeNotation object as a CutLocations object with the contents converted from enzyme notation to 0-based array index notation.


Arguments

  • none

Returns

CutLocations



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb', line 44

def to_array_index
  unless self.primary_to_array_index.size == self.complement_to_array_index.size
    err = "Primary and complement strand cut locations are not available in equal numbers.\n"
    err += "primary: #{self.primary_to_array_index.inspect}\n"
    err += "primary.size: #{self.primary_to_array_index.size}\n"
    err += "complement: #{self.complement_to_array_index.inspect}\n"
    err += "complement.size: #{self.complement_to_array_index.size}"
    raise IndexError, err
  end
  a = self.primary_to_array_index.zip(self.complement_to_array_index)
  CutLocations.new( *a.collect {|cl| CutLocationPair.new(cl)} )
end