Method: Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation#initialize
- Defined in:
- lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb
#initialize(*a) ⇒ CutLocationsInEnzymeNotation
Constructor for CutLocationsInEnzymeNotation
Arguments
-
a: Locations of cuts represented as a string with cuts or an array of values
Examples:
-
n^ng^arraxt^n
-
2
-
-1, 5
- -1, 5
- Returns
-
nothing
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb', line 58 def initialize(*a) a.flatten! # in case an array was passed as an argument if a.size == 1 and a[0].kind_of? String and a[0] =~ re_cut_symbol # Initialize with a cut symbol pattern such as 'n^ng^arraxt^n' s = a[0] a = [] i = -( s.tr(cut_symbol, '') =~ %r{[^n]} ) # First character that's not 'n' s.each_byte { |c| (a << i; next) if c.chr == cut_symbol; i += 1 } a.collect! { |n| n <= 0 ? n-1 : n } # 0 is not a valid enzyme index, decrement from 0 and all negative else a.collect! { |n| n.to_i } # Cut locations are always integers end validate_cut_locations( a ) super(a) self.sort! @min = self.first @max = self.last self.freeze end |