| Class | Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation |
| In: |
lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb
|
| Parent: | CutLocations |
Inherits from DoubleStranded::CutLocations. Contains CutLocationPairInEnzymeNotation objects. Adds helper methods to convert from enzyme index notation to 0-based array index notation.
Returns Array of locations of cuts on the complementary strand in 0-based array index notation.
Arguments
| 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, line 40
40: def complement_to_array_index
41: helper_for_to_array_index(self.complement)
42: end
Returns Array of locations of cuts on the primary strand in 0-based array index notation.
Arguments
| 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, line 29
29: def primary_to_array_index
30: helper_for_to_array_index(self.primary)
31: end
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
| Returns: | CutLocations |
# File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb, line 52
52: def to_array_index
53: unless self.primary_to_array_index.size == self.complement_to_array_index.size
54: err = "Primary and complement strand cut locations are not available in equal numbers.\n"
55: err += "primary: #{self.primary_to_array_index.inspect}\n"
56: err += "primary.size: #{self.primary_to_array_index.size}\n"
57: err += "complement: #{self.complement_to_array_index.inspect}\n"
58: err += "complement.size: #{self.complement_to_array_index.size}"
59: raise IndexError, err
60: end
61: a = self.primary_to_array_index.zip(self.complement_to_array_index)
62: CutLocations.new( *a.collect {|cl| CutLocationPair.new(cl)} )
63: end
# File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb, line 69
69: def helper_for_to_array_index(a)
70: minimum = (self.primary + self.complement).flatten
71: minimum.delete(nil)
72: minimum = minimum.sort.first
73:
74: return [] if minimum == nil # no elements
75:
76: if minimum < 0
77: calc = lambda do |n|
78: unless n == nil
79: n -= 1 unless n < 0
80: n += minimum.abs
81: end
82: n
83: end
84: else
85: calc = lambda do |n|
86: n -= 1 unless n == nil
87: n
88: end
89: end
90:
91: a.collect(&calc)
92: end
# File lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb, line 94
94: def validate_args(args)
95: args.each do |a|
96: unless a.class == Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
97: err = "Not a CutLocationPairInEnzymeNotation\n"
98: err += "class: #{a.class}\n"
99: err += "inspect: #{a.inspect}"
100: raise TypeError, err
101: end
102: end
103: end