[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/analysis calculated_cuts.rb, 1.3, 1.4 cut_range.rb, 1.2, 1.3 cut_ranges.rb, 1.3, 1.4 horizontal_cut_range.rb, 1.2, 1.3 sequence_range.rb, 1.4, 1.5 vertical_cut_range.rb, 1.2, 1.3

Trevor Wennblom trevor at dev.open-bio.org
Mon Jan 1 23:47:30 UTC 2007


Update of /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis
In directory dev.open-bio.org:/tmp/cvs-serv2413/restriction_enzyme/analysis

Modified Files:
	calculated_cuts.rb cut_range.rb cut_ranges.rb 
	horizontal_cut_range.rb sequence_range.rb 
	vertical_cut_range.rb 
Log Message:


Index: vertical_cut_range.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/vertical_cut_range.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vertical_cut_range.rb	31 Dec 2006 21:50:31 -0000	1.2
--- vertical_cut_range.rb	1 Jan 2007 23:47:28 -0000	1.3
***************
*** 31,34 ****
--- 31,56 ----
    attr_reader :range
  
+   # VerticalCutRange provides an extremely raw, yet precise, method of
+   # defining the location of cuts on primary and complementary sequences.
+   #
+   # Many VerticalCutRange objects are used with HorizontalCutRange objects
+   # to be contained in CutRanges to define the cut pattern that a
+   # specific enzyme may make.
+   #
+   # VerticalCutRange takes up to four possible cuts, two on the primary
+   # strand and two on the complementary strand.  In typical usage
+   # you will want to make a single cut on the primary strand and a single
+   # cut on the complementary strand.
+   #
+   # However, you can construct it with whatever cuts you desire to accomadate
+   # the most eccentric of imaginary restriction enzymes.
+   #
+   # ---
+   # *Arguments*
+   # * +p_cut_left+: (_optional_) Left-most cut on the primary strand.  +nil+ to skip
+   # * +p_cut_right+: (_optional_) Right-most cut on the primary strand.  +nil+ to skip
+   # * +c_cut_left+: (_optional_) Left-most cut on the complementary strand.  +nil+ to skip
+   # * +c_cut_right+: (_optional_) Right-most cut on the complementary strand.  +nil+ to skip
+   # *Returns*:: nothing
    def initialize( p_cut_left=nil, p_cut_right=nil, c_cut_left=nil, c_cut_right=nil )
      @p_cut_left = p_cut_left
***************
*** 45,50 ****
--- 67,80 ----
      @range = nil
      @range = (@min.. at max) unless @min == nil or @max == nil
+     return
    end
  
+   # Check if a location falls within the minimum or maximum values of this
+   # range.
+   #
+   # ---
+   # *Arguments*
+   # * +i+: Location to check if it is included in the range
+   # *Returns*:: +true+ _or_ +false+
    def include?(i)
      return false if @range == nil

Index: horizontal_cut_range.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/horizontal_cut_range.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** horizontal_cut_range.rb	31 Dec 2006 21:50:31 -0000	1.2
--- horizontal_cut_range.rb	1 Jan 2007 23:47:28 -0000	1.3
***************
*** 36,41 ****
      # The 'range' here is actually off by one on the left
      # side in relation to a normal CutRange, so using the normal
!     # variables from CutRange would result in unpredictable
!     # behavior.
  
      @p_cut_left = nil
--- 36,52 ----
      # The 'range' here is actually off by one on the left
      # side in relation to a normal CutRange, so using the normal
!     # variables from CutRange would result in bad behavior.
!     #
!     # See below - the first horizontal cut is the primary cut plus one.
!     #
!     #    1 2 3 4 5 6 7
!     #    G A|T T A C A
!     #       +-----+
!     #    C T A A T|G T
!     #    1 2 3 4 5 6 7
!     # 
!     # Primary cut = 2
!     # Complement cut = 5
!     # Horizontal cuts = 3, 4, 5
  
      @p_cut_left = nil
***************
*** 50,53 ****
--- 61,71 ----
    end
  
+   # Check if a location falls within the minimum or maximum values of this
+   # range.
+   #
+   # ---
+   # *Arguments*
+   # * +i+: Location to check if it is included in the range
+   # *Returns*:: +true+ _or_ +false+
    def include?(i)
      @range.include?(i)

Index: calculated_cuts.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/calculated_cuts.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** calculated_cuts.rb	1 Jan 2007 05:07:04 -0000	1.3
--- calculated_cuts.rb	1 Jan 2007 23:47:28 -0000	1.4
***************
*** 27,30 ****
--- 27,34 ----
  # License::   Distributes under the same terms as Ruby
  # 
+ # cc = CalculatedCuts.new(@size)
+ # cc.add_cuts_from_cut_ranges(@cut_ranges)
+ # cc.remove_incomplete_cuts
+ #
  #    1 2 3 4 5 6 7
  #    G A|T T A C A
***************
*** 41,55 ****
    include StringFormatting
  
!   # Vertical cuts on the primary strand
    attr_reader :vc_primary
    
!   # Vertical cuts on the complement strand
    attr_reader :vc_complement
  
!   # Horizontal cuts
    attr_reader :hc_between_strands
  
    # Set to +true+ if the fragment CalculatedCuts is working on is circular
    attr_accessor :circular
  
    def initialize(size=nil, circular=false)
--- 45,69 ----
    include StringFormatting
  
!   # +Array+ of vertical cuts on the primary strand in 0-based index notation
    attr_reader :vc_primary
    
!   # +Array+ of vertical cuts on the complementary strand in 0-based index notation
    attr_reader :vc_complement
  
!   # +Array+ of horizontal cuts between strands in 0-based index notation
    attr_reader :hc_between_strands
  
    # Set to +true+ if the fragment CalculatedCuts is working on is circular
    attr_accessor :circular
+   
+   # An +Array+ with the primary strand with vertical cuts, the horizontal cuts, and the complementary strand with vertical cuts.
+   attr_reader :strands_for_display
+   
+   # If +false+ the strands_for_display method needs to be called to update the contents
+   # of @strands_for_display.  Becomes out of date whenever add_cuts_from_cut_ranges is called.
+   attr_reader :strands_for_display_current
+ 
+   # Size of the sequence being digested.
+   attr_reader :size
  
    def initialize(size=nil, circular=false)
***************
*** 61,64 ****
--- 75,82 ----
    end
  
+   # ---
+   # *Arguments*
+   # * +cut_ranges+: An +Array+ of HorizontalCutRange or VerticalCutRange objects
+   # *Returns*:: nothing
    def add_cuts_from_cut_ranges(cut_ranges)
      @strands_for_display_current = false
***************
*** 68,71 ****
--- 86,91 ----
        @vc_complement += [cut_range.c_cut_left, cut_range.c_cut_right]
  
+       # Add horizontal cut ranges.  This may happen from cuts made inbetween a
+       # VerticalCutRange or may be specifically defined by a HorizontalCutRange.
        if cut_range.class == VerticalCutRange
          ( cut_range.min + 1 ).upto( cut_range.max ){|i| @hc_between_strands << i} if cut_range.min < cut_range.max
***************
*** 75,80 ****
--- 95,129 ----
      end
      clean_all
+     #return
    end
  
+   # There may be incomplete cuts made, this method removes the cuts that don't
+   # create sub-sequences for easier processing.
+   #
+   # For example, stray horizontal cuts that do not end with a left 
+   # and right separation:
+   #
+   #   G A T T A C A
+   #      +--  ---
+   #   C T|A A T G T
+   #
+   # Or stray vertical cuts:
+   #
+   #   G A T T A C A
+   #      +--   +
+   #   C T|A A T|G T
+   #
+   # However note that for non-circular sequences this would be a successful 
+   # cut which would result in a floating 'GT' sub-sequence:
+   #
+   #   G A T T A C A
+   #            +---
+   #   C T A A T|G T
+   #
+   # Blunt cuts are also complete cuts.
+   # ---
+   # *Arguments*
+   # * +size+: (_optional_) Size of the sequence being digested.  Defined here or during initalization of CalculatedCuts.
+   # *Returns*:: nothing
    def remove_incomplete_cuts(size=nil)
      @strands_for_display_current = false
***************
*** 90,94 ****
      if @circular
      # NOTE
!     # if it's circular we should start at the beginning of a cut for orientation
      # scan for it, hack off the first set of hcuts and move them to the back
      else
--- 139,143 ----
      if @circular
      # NOTE
!     # if it's circular we should start at the beginning of a cut for orientation,
      # scan for it, hack off the first set of hcuts and move them to the back
      else
***************
*** 133,136 ****
--- 182,196 ----
    end
  
+   # Sets @strands_for_display_current to +true+ and populates @strands_for_display.
+   #
+   # ---
+   # *Arguments*
+   # * +str1+: (_optional_) For displaying a primary strand.  If +nil+ a numbered sequence will be used in place.
+   # * +str2+: (_optional_) For displaying a complementary strand.  If +nil+ a numbered sequence will be used in place.
+   # * +vcp+: (_optional_) An array of vertical cut locations on the primary strand.  If +nil+ the contents of @vc_primary is used.
+   # * +vcc+: (_optional_) An array of vertical cut locations on the complementary strand.  If +nil+ the contents of @vc_complementary is used.
+   # * +hc+: (_optional_) An array of horizontal cut locations between strands.  If +nil+ the contents of @hc_between_strands is used.
+   # *Returns*:: +Array+ An array with the primary strand with vertical cuts, the horizontal cuts, and the complementary strand with vertical cuts.
+   #
    def strands_for_display(str1 = nil, str2 = nil, vcp=nil, vcc=nil, hc=nil)
      return @strands_for_display if @strands_for_display_current
***************
*** 178,181 ****
--- 238,243 ----
    #########
  
+   # remove nil values, remove duplicate values, and 
+   # sort @vc_primary, @vc_complement, and @hc_between_strands
    def clean_all
      [@vc_primary, @vc_complement, @hc_between_strands].collect { |a| a.delete(nil); a.uniq!; a.sort! }

Index: cut_range.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/cut_range.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cut_range.rb	31 Dec 2006 21:50:31 -0000	1.2
--- cut_range.rb	1 Jan 2007 23:47:28 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/analysis/cut_range.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/analysis/cut_range.rb - Abstract base class for HorizontalCutRange and VerticalCutRange
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 20,24 ****
  
  #
! # bio/util/restrction_enzyme/analysis/cut_range.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 20,24 ----
  
  #
! # bio/util/restrction_enzyme/analysis/cut_range.rb - Abstract base class for HorizontalCutRange and VerticalCutRange
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 26,29 ****
--- 26,31 ----
  # License::   Distributes under the same terms as Ruby
  #
+ # Abstract base class for HorizontalCutRange and VerticalCutRange
+ #
  class CutRange
  end # CutRange

Index: cut_ranges.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/cut_ranges.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** cut_ranges.rb	1 Jan 2007 02:16:05 -0000	1.3
--- cut_ranges.rb	1 Jan 2007 23:47:28 -0000	1.4
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/analysis/cut_ranges.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/analysis/cut_ranges.rb - Container for many CutRange objects or CutRange child objects.
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 12,24 ****
  $:.unshift(libpath) unless $:.include?(libpath)
  
- #require 'bio'
- 
  module Bio; end
  class Bio::RestrictionEnzyme
  class Analysis
! #class Analysis
! 
  #
! # bio/util/restrction_enzyme/analysis/cut_ranges.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 12,21 ----
  $:.unshift(libpath) unless $:.include?(libpath)
  
  module Bio; end
  class Bio::RestrictionEnzyme
  class Analysis
!   
  #
! # bio/util/restrction_enzyme/analysis/cut_ranges.rb - Container for many CutRange objects or CutRange child objects.
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 26,29 ****
--- 23,28 ----
  # License::   Distributes under the same terms as Ruby
  #
+ # Container for many CutRange objects or CutRange child objects.  Inherits from array.
+ #
  class CutRanges < Array
    def min; self.collect{|a| a.min}.flatten.sort.first; end

Index: sequence_range.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis/sequence_range.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sequence_range.rb	1 Jan 2007 02:31:22 -0000	1.4
--- sequence_range.rb	1 Jan 2007 23:47:28 -0000	1.5
***************
*** 87,98 ****
      # scan for it, hack off the first set of hcuts and move them to the back
      else
- #      last_index = @size - 1
        p_cut.unshift(-1) unless p_cut.include?(-1)
- #      p_cut.push(last_index) unless p_cut.include?(last_index)
        c_cut.unshift(-1) unless c_cut.include?(-1)
- #      c_cut.push(last_index) unless c_cut.include?(last_index)
      end
  
- 
      if @circular
        largest_bin = 0
--- 87,94 ----
***************
*** 114,118 ****
  
      -1.upto(@size-1) do |idx|
- 
        # if bins are out of sync but the strands are attached
        if p_bin != c_bin and h.include?(idx) == false
--- 110,113 ----
***************
*** 134,138 ****
          x.call(c_bin)
        end
- 
      end
  
--- 129,132 ----
***************
*** 141,148 ****
      bins.delete(-1) unless @circular
  
- #    require 'pp'
- #    pp bins
- 
- #NOTE
      str1 = nil
      str2 = nil
--- 135,138 ----
***************
*** 159,166 ****
      end
  
- #pp fragments.for_display
- #    pp fragments
- #    exit
- 
      @__fragments = fragments
      return fragments
--- 149,152 ----




More information about the bioruby-cvs mailing list