Class: Bio::RestrictionEnzyme::SingleStrand
- Inherits:
-
Sequence::NA
- Object
- String
- Sequence::NA
- Bio::RestrictionEnzyme::SingleStrand
- Includes:
- CutSymbol, StringFormatting
- Defined in:
- lib/bio/util/restriction_enzyme/single_strand.rb,
lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb
Overview
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.
Direct Known Subclasses
Defined Under Namespace
Classes: CutLocationsInEnzymeNotation
Instance Attribute Summary collapse
-
#cut_locations ⇒ Object
readonly
The cut locations transformed from enzyme index notation to 0-based array index notation.
-
#cut_locations_in_enzyme_notation ⇒ Object
readonly
The cut locations in enzyme notation.
-
#stripped ⇒ Object
readonly
Sequence pattern with no cut symbols and no ‘n’ padding.
Instance Method Summary collapse
-
#initialize(sequence, *c) ⇒ SingleStrand
constructor
Constructor for a Bio::RestrictionEnzyme::StingleStrand object.
-
#orientation ⇒ Object
Orientation of the strand, 5’ to 3’.
-
#palindromic? ⇒ Boolean
Returns true if this enzyme is palindromic with its reverse complement.
-
#pattern ⇒ Object
The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.
-
#with_cut_symbols ⇒ Object
The sequence with ‘n’ padding and cut symbols.
-
#with_spaces ⇒ Object
The sequence with ‘n’ pads, cut symbols, and spacing for alignment.
Methods included from StringFormatting
#add_spacing, #left_padding, #right_padding, #strip_cuts_and_padding, #strip_padding
Methods included from CutSymbol
#cut_symbol, #escaped_cut_symbol, #re_cut_symbol, #re_cut_symbol_adjacent, #set_cut_symbol
Methods inherited from Sequence::NA
#at_content, #at_skew, #codon_usage, #cut_with_enzyme, #dna, #dna!, #forward_complement, #forward_complement!, #gc_content, #gc_percent, #gc_skew, #illegal_bases, #molecular_weight, #names, #pikachu, randomize, #reverse_complement, #reverse_complement!, #rna, #rna!, #splicing, #to_midi, #to_re, #translate
Methods included from Sequence::Common
#+, #<<, #composition, #concat, #normalize!, #randomize, #seq, #splice, #subseq, #to_fasta, #to_s, #total, #window_search
Methods inherited from String
#fill, #fold, #skip, #step, #to_aaseq, #to_naseq
Constructor Details
#initialize(sequence, *c) ⇒ SingleStrand
Constructor for a Bio::RestrictionEnzyme::StingleStrand object.
A single strand of restriction enzyme sequence pattern with a 5’ to 3’ orientation.
Arguments
-
sequence
: (required) The enzyme sequence. -
c
: (optional) Cut locations in enzyme notation.See Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
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:
-
String
-
Bio::Sequence::NA
-
Bio::RestrictionEnzyme::SingleStrand
c
must be a kind of:
-
Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
-
Integer, one or more
-
Array
- Returns
-
nothing
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 69 def initialize( sequence, *c ) c.flatten! # if an array was supplied as an argument # NOTE t| 2009-09-19 commented out for library efficiency # validate_args(sequence, c) sequence = sequence.downcase if sequence =~ re_cut_symbol @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( strip_padding(sequence) ) else @cut_locations_in_enzyme_notation = CutLocationsInEnzymeNotation.new( c ) end @stripped = Bio::Sequence::NA.new( strip_cuts_and_padding( sequence ) ) super( pattern ) @cut_locations = @cut_locations_in_enzyme_notation.to_array_index return end |
Instance Attribute Details
#cut_locations ⇒ Object (readonly)
The cut locations transformed from enzyme index notation to 0-based array index notation. Contains an Array.
37 38 39 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 37 def cut_locations @cut_locations end |
#cut_locations_in_enzyme_notation ⇒ Object (readonly)
The cut locations in enzyme notation. Contains a CutLocationsInEnzymeNotation object set when the SingleStrand object is initialized.
33 34 35 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 33 def cut_locations_in_enzyme_notation @cut_locations_in_enzyme_notation end |
#stripped ⇒ Object (readonly)
Sequence pattern with no cut symbols and no ‘n’ padding.
-
SingleStrand.new('garraxt', [-2, 1, 7]).stripped # => "garraxt"
109 110 111 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 109 def stripped @stripped end |
Instance Method Details
#orientation ⇒ Object
Orientation of the strand, 5’ to 3’
40 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 40 def orientation; [5,3]; end |
#palindromic? ⇒ Boolean
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
orfalse
103 104 105 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 103 def palindromic? @stripped.reverse_complement == @stripped end |
#pattern ⇒ Object
The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.
-
SingleStrand.new('garraxt', [-2, 1, 7]).pattern # => "nngarraxtn"
Arguments
-
none
- Returns
-
The sequence with ‘n’ padding on the left and right for cuts larger than the sequence.
131 132 133 134 135 136 137 138 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 131 def pattern return stripped if @cut_locations_in_enzyme_notation.min == nil left = (@cut_locations_in_enzyme_notation.min < 0 ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '') # Add one more 'n' if a cut is at the last position right = ( (@cut_locations_in_enzyme_notation.max >= @stripped.length) ? ('n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1)) : '') [left, stripped, right].join('') end |
#with_cut_symbols ⇒ Object
The sequence with ‘n’ padding and cut symbols.
-
SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols # => "n^ng^arraxt^n"
Arguments
-
none
- Returns
-
The sequence with ‘n’ padding and cut symbols.
118 119 120 121 122 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 118 def with_cut_symbols s = pattern @cut_locations_in_enzyme_notation.to_array_index.sort.reverse.each { |c| s.insert(c+1, cut_symbol) } s end |
#with_spaces ⇒ Object
The sequence with ‘n’ pads, cut symbols, and spacing for alignment.
-
SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n"
Arguments
-
none
- Returns
-
The sequence with ‘n’ pads, cut symbols, and spacing for alignment.
147 148 149 |
# File 'lib/bio/util/restriction_enzyme/single_strand.rb', line 147 def with_spaces add_spacing( with_cut_symbols ) end |