class Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation

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

Public Instance Methods

complement_to_array_index() click to toggle source

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.

   # File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
39 def complement_to_array_index
40   helper_for_to_array_index(self.complement)
41 end
primary_to_array_index() click to toggle source

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.

   # File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
28 def primary_to_array_index
29   helper_for_to_array_index(self.primary)
30 end
to_array_index() click to toggle source

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

   # File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
51 def to_array_index
52   unless self.primary_to_array_index.size == self.complement_to_array_index.size
53     err = "Primary and complement strand cut locations are not available in equal numbers.\n"
54     err += "primary: #{self.primary_to_array_index.inspect}\n"
55     err += "primary.size: #{self.primary_to_array_index.size}\n"
56     err += "complement: #{self.complement_to_array_index.inspect}\n"
57     err += "complement.size: #{self.complement_to_array_index.size}"
58     raise IndexError, err
59   end
60   a = self.primary_to_array_index.zip(self.complement_to_array_index)
61   CutLocations.new( *a.collect {|cl| CutLocationPair.new(cl)} )
62 end

Protected Instance Methods

helper_for_to_array_index(a) click to toggle source
   # File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
68 def helper_for_to_array_index(a)
69   minimum = (self.primary + self.complement).flatten
70   minimum.delete(nil)
71   minimum = minimum.sort.first
72 
73   return [] if minimum == nil  # no elements
74 
75   if minimum < 0
76     calc = lambda do |n|
77       unless n == nil
78         n -= 1 unless n < 0
79         n += minimum.abs
80       end
81       n
82     end
83   else
84     calc = lambda do |n| 
85       n -= 1 unless n == nil
86       n
87     end
88   end
89 
90   a.collect(&calc)
91 end
validate_args(args) click to toggle source
    # File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
 93 def validate_args(args)
 94   args.each do |a|
 95     unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
 96       err = "Not a CutLocationPairInEnzymeNotation\n"
 97       err += "class: #{a.class}\n"
 98       err += "inspect: #{a.inspect}"
 99       raise TypeError, err
100     end
101   end
102 end