Class Bio::RestrictionEnzyme::SingleStrand
In: lib/bio/util/restriction_enzyme/single_strand.rb
lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb
Parent: Bio::Sequence::NA

A single strand of restriction enzyme sequence pattern with a 5’ to 3’ orientation.

DoubleStranded puts the SingleStrand and SingleStrandComplement together to create the sequence pattern with cuts on both strands.

Methods

Included Modules

CutSymbol StringFormatting

Classes and Modules

Class Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation

Attributes

cut_locations  [R]  The cut locations transformed from enzyme index notation to 0-based array index notation. Contains an Array.
cut_locations_in_enzyme_notation  [R]  The cut locations in enzyme notation. Contains a CutLocationsInEnzymeNotation object set when the SingleStrand object is initialized.
stripped  [R]  Sequence pattern with no cut symbols and no ‘n’ padding.

Public Class methods

Constructor for a Bio::RestrictionEnzyme::StingleStrand object.

A single strand of restriction enzyme sequence pattern with a 5’ to 3’ orientation.


Arguments

Constraints

  • sequence cannot contain immediately adjacent cut symbols (ex. atg^^c).
  • c is in enzyme index notation and therefore cannot contain a 0.
  • If c is omitted, sequence must contain a cut symbol.
  • You cannot provide both a sequence with cut symbols and provide cut locations - ambiguous.

sequence must be a kind of:

c must be a kind of:

Returns:nothing

[Source]

    # File lib/bio/util/restriction_enzyme/single_strand.rb, line 69
69:   def initialize( sequence, *c )
70:     c.flatten! # if an array was supplied as an argument
71:   # NOTE t| 2009-09-19 commented out for library efficiency
72:     # validate_args(sequence, c)
73:     sequence = sequence.downcase
74:     
75:     if sequence =~ re_cut_symbol
76:       @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) )
77:     else
78:       @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c )
79:     end
80: 
81:     @stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) )
82:     super( pattern )
83:     @cut_locations = @cut_locations_in_enzyme_notation.to_array_index
84:     return
85:   end

Public Instance methods

Orientation of the strand, 5’ to 3‘

[Source]

    # File lib/bio/util/restriction_enzyme/single_strand.rb, line 40
40:   def orientation; [5,3]; end

Returns true if this enzyme is palindromic with its reverse complement. Does not report if the cut_locations are palindromic or not.

Examples:

  • This would be palindromic:
      5' - ATGCAT - 3'
           TACGTA
    
  • This would not be palindromic:
      5' - ATGCGTA - 3'
           TACGCAT
    

Arguments

  • none
Returns:true or false

[Source]

     # File lib/bio/util/restriction_enzyme/single_strand.rb, line 103
103:   def palindromic?
104:     @stripped.reverse_complement == @stripped
105:   end

The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.


Arguments

  • none
Returns:The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.

[Source]

     # File lib/bio/util/restriction_enzyme/single_strand.rb, line 131
131:   def pattern
132:     return stripped if @cut_locations_in_enzyme_notation.min == nil
133:     left = (@cut_locations_in_enzyme_notation.min < 0 ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '')
134: 
135:     # Add one more 'n' if a cut is at the last position 
136:     right = ( (@cut_locations_in_enzyme_notation.max >= @stripped.length) ? ('n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1)) : '')
137:     [left, stripped, right].join('')
138:   end

The sequence with ‘n’ padding and cut symbols.


Arguments

  • none
Returns:The sequence with ‘n’ padding and cut symbols.

[Source]

     # File lib/bio/util/restriction_enzyme/single_strand.rb, line 118
118:   def with_cut_symbols
119:     s = pattern
120:     @cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) }
121:     s
122:   end

The sequence with ‘n’ pads, cut symbols, and spacing for alignment.


Arguments

  • none
Returns:The sequence with ‘n’ pads, cut symbols, and spacing for alignment.

[Source]

     # File lib/bio/util/restriction_enzyme/single_strand.rb, line 147
147:   def with_spaces
148:     add_spacing( with_cut_symbols )
149:   end

Protected Instance methods

[Source]

     # File lib/bio/util/restriction_enzyme/single_strand.rb, line 155
155:   def validate_args( input_pattern, input_cut_locations )
156:     unless input_pattern.kind_of?(String)
157:       err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand object\n"
158:       err += "pattern: #{input_pattern}\n"
159:       err += "class: #{input_pattern.class}"
160:       raise ArgumentError, err
161:     end
162: 
163:     if ( input_pattern =~ re_cut_symbol ) and !input_cut_locations.empty?
164:       err = "Cut symbol found in sequence, but cut locations were also supplied.  Ambiguous.\n"
165:       err += "pattern: #{input_pattern}\n"
166:       err += "symbol: #{cut_symbol}\n"
167:       err += "locations: #{input_cut_locations.inspect}"
168:       raise ArgumentError, err
169:     end
170: 
171:     input_pattern.each_byte do |c| 
172:       c = c.chr.downcase
173:       unless Bio::NucleicAcid::NAMES.has_key?(c) or c == 'x' or c == 'X' or c == cut_symbol
174:         err = "Invalid character in pattern.\n"
175:         err += "Not a nucleotide or representation of possible nucleotides.  See Bio::NucleicAcid::NAMES for more information.\n"
176:         err += "char: #{c}\n"
177:         err += "input_pattern: #{input_pattern}"
178:         raise ArgumentError, err
179:       end
180:     end
181:   end

[Validate]