Class: Bio::RestrictionEnzyme::Analysis
- Defined in:
- lib/bio/util/restriction_enzyme/analysis.rb,
lib/bio/util/restriction_enzyme/analysis_basic.rb
Class Method Summary collapse
-
.cut(sequence, *args) ⇒ Object
See cut instance method.
-
.cut_without_permutations(sequence, *args) ⇒ Object
See cut_without_permutations instance method.
Instance Method Summary collapse
-
#cut(sequence, *args) ⇒ Object
See main documentation for Bio::RestrictionEnzyme.
-
#cut_without_permutations(sequence, *args) ⇒ Object
See main documentation for Bio::RestrictionEnzyme.
Class Method Details
.cut(sequence, *args) ⇒ Object
See cut instance method
23 24 25 |
# File 'lib/bio/util/restriction_enzyme/analysis.rb', line 23 def self.cut( sequence, *args ) self.new.cut( sequence, *args ) end |
.cut_without_permutations(sequence, *args) ⇒ Object
See cut_without_permutations instance method
21 22 23 |
# File 'lib/bio/util/restriction_enzyme/analysis_basic.rb', line 21 def self.cut_without_permutations( sequence, *args ) self.new.cut_without_permutations( sequence, *args ) end |
Instance Method Details
#cut(sequence, *args) ⇒ Object
See main documentation for Bio::RestrictionEnzyme
cut
takes into account permutations of cut variations based on competitiveness of enzymes for an enzyme cutsite or enzyme bindsite on a sequence.
Example:
FIXME add output
Bio::RestrictionEnzyme::Analysis.cut('gaattc', 'EcoRI')
_same as:_
Bio::RestrictionEnzyme::Analysis.cut('gaattc', 'g^aattc')
Arguments
-
sequence
:String
kind of object that will be used as a nucleic acid sequence. -
args
: Series of enzyme names, enzymes sequences with cut marks, or RestrictionEnzyme objects.
- Returns
-
Bio::RestrictionEnzyme::Fragments object populated with Bio::RestrictionEnzyme::Fragment objects. (Note: unrelated to Bio::RestrictionEnzyme::Range::SequenceRange::Fragments) or a
Symbol
containing an error code
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bio/util/restriction_enzyme/analysis.rb', line 48 def cut( sequence, *args ) view_ranges = false args.select { |i| i.class == Hash }.each do |hsh| hsh.each do |key, value| if key == :view_ranges unless ( value.kind_of?(TrueClass) or value.kind_of?(FalseClass) ) raise ArgumentError, "view_ranges must be set to true or false, currently #{value.inspect}." end view_ranges = value end end end res = cut_and_return_by_permutations( sequence, *args ) return res if res.class == Symbol # Format the fragments for the user fragments_for_display( res, view_ranges ) end |
#cut_without_permutations(sequence, *args) ⇒ Object
See main documentation for Bio::RestrictionEnzyme
Bio::RestrictionEnzyme.cut is preferred over this!
USE AT YOUR OWN RISK
This is a simpler version of method cut
. cut
takes into account permutations of cut variations based on competitiveness of enzymes for an enzyme cutsite or enzyme bindsite on a sequence. This does not take into account those possibilities and is therefore faster, but less likely to be accurate.
This code is mainly included as an academic example without having to wade through the extra layer of complexity added by the permutations.
Example:
FIXME add output
Bio::RestrictionEnzyme::Analysis.cut_without_permutations('gaattc', 'EcoRI')
_same as:_
Bio::RestrictionEnzyme::Analysis.cut_without_permutations('gaattc', 'g^aattc')
Arguments
-
sequence
:String
kind of object that will be used as a nucleic acid sequence. -
args
: Series of enzyme names, enzymes sequences with cut marks, or RestrictionEnzyme objects.
- Returns
-
Bio::RestrictionEnzyme::Fragments object populated with Bio::RestrictionEnzyme::Fragment objects. (Note: unrelated to Bio::RestrictionEnzyme::Range::SequenceRange::Fragments)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bio/util/restriction_enzyme/analysis_basic.rb', line 55 def cut_without_permutations( sequence, *args ) return fragments_for_display( {} ) if !sequence.kind_of?(String) or sequence.empty? sequence = Bio::Sequence::NA.new( sequence ) # create_enzyme_actions returns two seperate array elements, they're not # needed separated here so we put them into one array enzyme_actions = create_enzyme_actions( sequence, *args ).flatten return fragments_for_display( {} ) if enzyme_actions.empty? # Primary and complement strands are both measured from '0' to 'sequence.size-1' here sequence_range = Bio::RestrictionEnzyme::Range::SequenceRange.new( 0, 0, sequence.size-1, sequence.size-1 ) # Add the cuts to the sequence_range from each enzyme_action enzyme_actions.each do |enzyme_action| enzyme_action.cut_ranges.each do |cut_range| sequence_range.add_cut_range(cut_range) end end # Fill in the source sequence for sequence_range so it knows what bases # to use sequence_range.fragments.primary = sequence sequence_range.fragments.complement = sequence.forward_complement # Format the fragments for the user fragments_for_display( {0 => sequence_range} ) end |