[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme single_strand.rb, 1.2, 1.3 string_formatting.rb, 1.2, 1.3

Trevor Wennblom trevor at dev.open-bio.org
Mon Jan 1 03:36:39 UTC 2007


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

Modified Files:
	single_strand.rb string_formatting.rb 
Log Message:


Index: string_formatting.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/string_formatting.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** string_formatting.rb	31 Dec 2006 21:50:31 -0000	1.2
--- string_formatting.rb	1 Jan 2007 03:36:37 -0000	1.3
***************
*** 33,41 ****
    # Example:
    #   pattern = 'n^ng^arraxt^n'
!   #   add_spacing( pattern )
    #
!   # Returns:
!   #   "n^n g^a r r a x t^n"
    #
    def add_spacing( seq, cs = cut_symbol )
      str = ''
--- 33,49 ----
    # Example:
    #   pattern = 'n^ng^arraxt^n'
!   #   add_spacing( pattern )      # => "n^n g^a r r a x t^n"
    #
!   # ---
!   # *Arguments*
!   # * +seq+: sequence with cut symbols
!   # * +cs+: (_optional_) Cut symbol along the string.  The reason this is
!   #   definable outside of CutSymbol is that this is a utility function used
!   #   to form vertical and horizontal cuts such as:
    #
+   #     a|t g c
+   #      +---+
+   #     t a c|g
+   # *Returns*:: +String+ sequence with single character distance between bases
    def add_spacing( seq, cs = cut_symbol )
      str = ''
***************
*** 58,61 ****
--- 66,74 ----
    # Remove extraneous nucleic acid wildcards ('n' padding) from the
    # left and right sides
+   #
+   # ---
+   # *Arguments*
+   # * +s+: sequence with extraneous 'n' padding
+   # *Returns*:: +String+ sequence without 'n' padding on the sides
    def strip_padding( s )
      if s[0].chr == 'n'
***************
*** 72,75 ****
--- 85,93 ----
    # Remove extraneous nucleic acid wildcards ('n' padding) from the
    # left and right sides and remove cut symbols
+   #
+   # ---
+   # *Arguments*
+   # * +s+: sequence with extraneous 'n' padding and cut symbols
+   # *Returns*:: +String+ sequence without 'n' padding on the sides or cut symbols
    def strip_cuts_and_padding( s )
      strip_padding( s.tr(cut_symbol, '') )
***************
*** 77,80 ****
--- 95,103 ----
  
    # Return the 'n' padding on the left side of the strand
+   #
+   # ---
+   # *Arguments*
+   # * +s+: sequence with extraneous 'n' padding on the left side of the strand
+   # *Returns*:: +String+ the 'n' padding from the left side
    def left_padding( s )
      s =~ %r{^n+}
***************
*** 84,87 ****
--- 107,115 ----
  
    # Return the 'n' padding on the right side of the strand
+   #
+   # ---
+   # *Arguments*
+   # * +s+: sequence with extraneous 'n' padding on the right side of the strand
+   # *Returns*:: +String+ the 'n' padding from the right side
    def right_padding( s )
      s =~ %r{n+$}

Index: single_strand.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/single_strand.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** single_strand.rb	31 Dec 2006 21:50:31 -0000	1.2
--- single_strand.rb	1 Jan 2007 03:36:37 -0000	1.3
***************
*** 17,20 ****
--- 17,21 ----
  require 'bio/sequence'
  
+ module Bio; end
  class Bio::RestrictionEnzyme
  
***************
*** 37,45 ****
  
    # The cut locations in enzyme notation. Contains a 
!   # CutLocationsInEnzymeNotation object.
    attr_reader :cut_locations_in_enzyme_notation
  
    # The cut locations transformed from enzyme index notation to 0-based 
!   # array index notation.  Contains an Array
    attr_reader :cut_locations
  
--- 38,47 ----
  
    # The cut locations in enzyme notation. Contains a 
!   # CutLocationsInEnzymeNotation object set when the SingleStrand
!   # object is initialized.
    attr_reader :cut_locations_in_enzyme_notation
  
    # The cut locations transformed from enzyme index notation to 0-based 
!   # array index notation.  Contains an Array.
    attr_reader :cut_locations
  
***************
*** 47,58 ****
    def orientation; [5,3]; end
  
!   # +sequence+:: The enzyme sequence.
!   # +c+:: Cut locations in enzyme notation.  See CutLocationsInEnzymeNotation.
    #
!   # * +sequence+ is required, +c+ is optional
!   # * You cannot provide a sequence with cut symbols and provide cut locations.
!   # * If +c+ is omitted, +input_pattern+ must contain a cut symbol.
!   # * +sequence+ cannot contain adjacent cut symbols.
    # * +c+ is in enzyme index notation and therefore cannot contain a 0.
    #
    # +sequence+ must be a kind of:
--- 49,67 ----
    def orientation; [5,3]; end
  
!   # 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:
***************
*** 62,69 ****
    #
    # +c+ must be a kind of:
    # * Integer, one or more
    # * Array
-   # * CutLocationsInEnzymeNotation
    #
    def initialize( sequence, *c )
      c.flatten! # if an array was supplied as an argument
--- 71,79 ----
    #
    # +c+ must be a kind of:
+   # * Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
    # * Integer, one or more
    # * Array
    #
+   # *Returns*:: nothing
    def initialize( sequence, *c )
      c.flatten! # if an array was supplied as an argument
***************
*** 80,83 ****
--- 90,94 ----
      super( pattern )
      @cut_locations = @cut_locations_in_enzyme_notation.to_array_index
+     return
    end
  
***************
*** 94,107 ****
    #          TACGCAT
    #
    def palindromic?
      @stripped.reverse_complement == @stripped
    end
  
!   # Pattern with no cut symbols and no 'n' padding.
!   # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).stripped  # "garraxt"</code>
    attr_reader :stripped
  
    # The sequence with 'n' padding and cut symbols.
    # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols  # => "n^ng^arraxt^n"</code>
    def with_cut_symbols
      s = pattern
--- 105,127 ----
    #          TACGCAT
    #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +true+ _or_ +false+
    def palindromic?
      @stripped.reverse_complement == @stripped
    end
  
!   # Sequence pattern with no cut symbols and no 'n' padding.
!   # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).stripped  # => "garraxt"</code>
    attr_reader :stripped
  
    # The sequence with 'n' padding and cut symbols.
    # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_cut_symbols  # => "n^ng^arraxt^n"</code>
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: The sequence with 'n' padding and cut symbols.
    def with_cut_symbols
      s = pattern
***************
*** 112,115 ****
--- 132,140 ----
    # The sequence with 'n' padding on the left and right for cuts larger than the sequence.
    # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).pattern  # => "nngarraxtn"</code>
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: The sequence with 'n' padding on the left and right for cuts larger than the sequence.
    def pattern
      return stripped if @cut_locations_in_enzyme_notation.min == nil
***************
*** 117,121 ****
  
      # 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].to_s
    end
--- 142,146 ----
  
      # 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].to_s
    end
***************
*** 123,139 ****
    # The sequence with 'n' pads, cut symbols, and spacing for alignment.
    # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n"</code>
    def with_spaces
      add_spacing( with_cut_symbols )
    end
  
- # FIXME recheck this
-   # NOTE: BEING WORKED ON, BUG EXISTS IN Bio::NucleicAcid
- =begin  
-   to_re - important
-   example z = [agc]
-   z must match [agcz]
-   not just [agc]
- =end
- 
    #########
    protected
--- 148,160 ----
    # The sequence with 'n' pads, cut symbols, and spacing for alignment.
    # * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n"</code>
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: The sequence with 'n' pads, cut symbols, and spacing for alignment.
    def with_spaces
      add_spacing( with_cut_symbols )
    end
  
    #########
    protected
***************
*** 142,146 ****
    def validate_args( input_pattern, input_cut_locations )
      unless input_pattern.kind_of?(String)
!       err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand::Sequence object\n"
        err += "pattern: #{input_pattern}\n"
        err += "class: #{input_pattern.class}"
--- 163,167 ----
    def validate_args( input_pattern, input_cut_locations )
      unless input_pattern.kind_of?(String)
!       err = "input_pattern is not a String, Bio::Sequence::NA, or Bio::RestrictionEnzyme::SingleStrand object\n"
        err += "pattern: #{input_pattern}\n"
        err += "class: #{input_pattern.class}"



More information about the bioruby-cvs mailing list