| 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.
| 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.
|
Constructor for a Bio::RestrictionEnzyme::StingleStrand object.
A single strand of restriction enzyme sequence pattern with a 5’ to 3’ orientation.
Arguments
Constraints
sequence must be a kind of:
c must be a kind of:
| Returns: | nothing |
# 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: validate_args(sequence, c)
72: sequence.downcase!
73:
74: if sequence =~ re_cut_symbol
75: @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) )
76: else
77: @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c )
78: end
79:
80: @stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) )
81: super( pattern )
82: @cut_locations = @cut_locations_in_enzyme_notation.to_array_index
83: return
84: end
Orientation of the strand, 5’ to 3‘
# 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:
5' - ATGCAT - 3'
TACGTA
5' - ATGCGTA - 3'
TACGCAT
Arguments
| Returns: | true or false |
# File lib/bio/util/restriction_enzyme/single_strand.rb, line 102
102: def palindromic?
103: @stripped.reverse_complement == @stripped
104: end
The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.
Arguments
| Returns: | The sequence with ‘n’ padding on the left and right for cuts larger than the sequence. |
# File lib/bio/util/restriction_enzyme/single_strand.rb, line 130
130: def pattern
131: return stripped if @cut_locations_in_enzyme_notation.min == nil
132: left = (@cut_locations_in_enzyme_notation.min < 0 ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '')
133:
134: # Add one more 'n' if a cut is at the last position
135: right = ( (@cut_locations_in_enzyme_notation.max >= @stripped.length) ? ('n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1)) : '')
136: [left, stripped, right].join('')
137: end
The sequence with ‘n’ padding and cut symbols.
Arguments
| Returns: | The sequence with ‘n’ padding and cut symbols. |
# File lib/bio/util/restriction_enzyme/single_strand.rb, line 117
117: def with_cut_symbols
118: s = pattern
119: @cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) }
120: s
121: end
The sequence with ‘n’ pads, cut symbols, and spacing for alignment.
Arguments
| Returns: | The sequence with ‘n’ pads, cut symbols, and spacing for alignment. |
# File lib/bio/util/restriction_enzyme/single_strand.rb, line 146
146: def with_spaces
147: add_spacing( with_cut_symbols )
148: end
# File lib/bio/util/restriction_enzyme/single_strand.rb, line 154
154: def validate_args( input_pattern, input_cut_locations )
155: unless input_pattern.kind_of?(String)
156: err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand object\n"
157: err += "pattern: #{input_pattern}\n"
158: err += "class: #{input_pattern.class}"
159: raise ArgumentError, err
160: end
161:
162: if ( input_pattern =~ re_cut_symbol ) and !input_cut_locations.empty?
163: err = "Cut symbol found in sequence, but cut locations were also supplied. Ambiguous.\n"
164: err += "pattern: #{input_pattern}\n"
165: err += "symbol: #{cut_symbol}\n"
166: err += "locations: #{input_cut_locations.inspect}"
167: raise ArgumentError, err
168: end
169:
170: input_pattern.each_byte do |c|
171: c = c.chr.downcase
172: unless Bio::NucleicAcid::NAMES.has_key?(c) or c == 'x' or c == 'X' or c == cut_symbol
173: err = "Invalid character in pattern.\n"
174: err += "Not a nucleotide or representation of possible nucleotides. See Bio::NucleicAcid::NAMES for more information.\n"
175: err += "char: #{c}\n"
176: err += "input_pattern: #{input_pattern}"
177: raise ArgumentError, err
178: end
179: end
180: end