[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme/double_stranded aligned_strands.rb, 1.2, 1.3 cut_location_pair.rb, 1.2, 1.3 cut_location_pair_in_enzyme_notation.rb, 1.2, 1.3 cut_locations.rb, 1.2, 1.3 cut_locations_in_enzyme_notation.rb, 1.2, 1.3

Trevor Wennblom trevor at dev.open-bio.org
Mon Jan 1 05:07:06 UTC 2007


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

Modified Files:
	aligned_strands.rb cut_location_pair.rb 
	cut_location_pair_in_enzyme_notation.rb cut_locations.rb 
	cut_locations_in_enzyme_notation.rb 
Log Message:


Index: aligned_strands.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** aligned_strands.rb	31 Dec 2006 21:50:31 -0000	1.2
--- aligned_strands.rb	1 Jan 2007 05:07:04 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/double_stranded/aligned_strands.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/double_stranded/aligned_strands.rb - Align two SingleStrand objects
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 21,25 ****
  
  #
! # bio/util/restrction_enzyme/double_stranded/aligned_strands.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 21,25 ----
  
  #
! # bio/util/restrction_enzyme/double_stranded/aligned_strands.rb - Align two SingleStrand objects
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 27,31 ****
  # License::   Distributes under the same terms as Ruby
  #
! # Align two SingleStrand::Pattern objects and return a Result
  # object with +primary+ and +complement+ accessors.
  #
--- 27,31 ----
  # License::   Distributes under the same terms as Ruby
  #
! # Align two SingleStrand objects and return a Result
  # object with +primary+ and +complement+ accessors.
  #
***************
*** 37,53 ****
    Result = Struct.new(:primary, :complement)
  
!   # Pad and align two String objects.
    #
!   # +a+:: First String
!   # +b+:: Second String
    #
!   # Example invocation:
!   #   AlignedStrands.align('nngattacannnnn', 'nnnnnctaatgtnn')
    #
!   # Example return value:
!   #   #<struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
!   #    primary="nnnnngattacannnnn",
!   #    complement="nnnnnctaatgtnnnnn">
    #
    def self.align(a, b)
      a = a.to_s
--- 37,60 ----
    Result = Struct.new(:primary, :complement)
  
!   # Pad and align two String objects without cut symbols.
    #
!   # This will look for the sub-sequence without left and right 'n' padding
!   # and re-apply 'n' padding to both strings on both sides equal to the 
!   # maximum previous padding on that side.
    #
!   # The sub-sequences stripped of left and right 'n' padding must be of equal
!   # length.
    #
!   # Example:
!   #   AlignedStrands.align('nngattacannnnn', 'nnnnnctaatgtnn') # => 
!   #    <struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
!   #      primary="nnnnngattacannnnn",
!   #      complement="nnnnnctaatgtnnnnn">
    #
+   # ---
+   # *Arguments*
+   # * +a+: Primary strand
+   # * +b+: Complementary strand
+   # *Returns*:: +Result+ object with equal padding on both strings
    def self.align(a, b)
      a = a.to_s
***************
*** 64,79 ****
    # Pad and align two String objects with cut symbols.
    #
!   # +a+:: First String
!   # +b+:: Second String
!   # +a_cuts+:: First strand cut locations in 0-based index notation
!   # +b_cuts+:: Second strand cut locations in 0-based index notation
!   #
!   # Example invocation:
!   #   AlignedStrands.with_cuts('nngattacannnnn', 'nnnnnctaatgtnn', [0, 10, 12], [0, 2, 12])
!   #
!   # Example return value:
!   #   #<struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
!   #    primary="n n n n^n g a t t a c a n n^n n^n",
!   #    complement="n^n n^n n c t a a t g t n^n n n n">
    #
    # Notes:
--- 71,79 ----
    # Pad and align two String objects with cut symbols.
    #
!   # Example:
!   #   AlignedStrands.with_cuts('nngattacannnnn', 'nnnnnctaatgtnn', [0, 10, 12], [0, 2, 12]) # => 
!   #     <struct Bio::RestrictionEnzyme::DoubleStranded::AlignedStrands::Result
!   #       primary="n n n n^n g a t t a c a n n^n n^n",
!   #       complement="n^n n^n n c t a a t g t n^n n n n">
    #
    # Notes:
***************
*** 81,86 ****
    # * This is meant to be able to handle multiple cuts and completely
    #   unrelated cutsites on the two strands, therefore no biological
!   #   shortcuts are made.
    #
    def self.align_with_cuts(a,b,a_cuts,b_cuts)
      a = a.to_s
--- 81,96 ----
    # * This is meant to be able to handle multiple cuts and completely
    #   unrelated cutsites on the two strands, therefore no biological
!   #   algorithm assumptions (shortcuts) are made.
!   #
!   # The sequences stripped of left and right 'n' padding must be of equal
!   # length.
    #
+   # ---
+   # *Arguments*
+   # * +a+: Primary sequence
+   # * +b+: Complementary sequence
+   # * +a_cuts+: Primary strand cut locations in 0-based index notation
+   # * +b_cuts+: Complementary strand cut locations in 0-based index notation
+   # *Returns*:: +Result+ object with equal padding on both strings and spacing between bases
    def self.align_with_cuts(a,b,a_cuts,b_cuts)
      a = a.to_s

Index: cut_locations.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cut_locations.rb	31 Dec 2006 21:50:31 -0000	1.2
--- cut_locations.rb	1 Jan 2007 05:07:04 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations.rb - Contains an Array of CutLocationPair objects
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 19,23 ****
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 19,23 ----
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations.rb - Contains an Array of CutLocationPair objects
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 25,30 ****
--- 25,45 ----
  # License::   Distributes under the same terms as Ruby
  #
+ # Contains an +Array+ of CutLocationPair objects.
+ #
  class CutLocations < Array
  
+   # CutLocations constructor.
+   #
+   # Contains an +Array+ of CutLocationPair objects.
+   #
+   # Example:
+   #   clp1 = CutLocationPair.new(3,2)
+   #   clp2 = CutLocationPair.new(7,9)
+   #   pairs = CutLocations.new(clp1, clp2)
+   #
+   # ---
+   # *Arguments*
+   # * +args+: Any number of +CutLocationPair+ objects
+   # *Returns*:: nothing
    def initialize(*args)
      validate_args(args)
***************
*** 32,39 ****
--- 47,66 ----
    end
  
+   # Returns an +Array+ of locations of cuts on the primary strand
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Array+ of locations of cuts on the primary strand
    def primary
      self.collect {|a| a[0]}
    end
  
+   # Returns an +Array+ of locations of cuts on the complementary strand
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Array+ of locations of cuts on the complementary strand
    def complement
      self.collect {|a| a[1]}

Index: cut_locations_in_enzyme_notation.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cut_locations_in_enzyme_notation.rb	31 Dec 2006 21:50:31 -0000	1.2
--- cut_locations_in_enzyme_notation.rb	1 Jan 2007 05:07:04 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - Inherits from DoubleStrand::CutLocations
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 20,24 ****
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 20,24 ----
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb - Inherits from DoubleStrand::CutLocations
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 26,39 ****
--- 26,64 ----
  # License::   Distributes under the same terms as Ruby
  #
+ # Inherits from DoubleStranded::CutLocations.  Contains CutLocationPairInEnzymeNotation objects.
+ # Adds helper methods to convert from enzyme index notation to 0-based array index notation.
+ #
  class CutLocationsInEnzymeNotation < CutLocations
  
+   # Returns +Array+ of locations of cuts on the primary 
+   # strand in 0-based array index notation.
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Array+ of locations of cuts on the primary strand in 0-based array index notation.
    def primary_to_array_index
      helper_for_to_array_index(self.primary)
    end
  
+   # Returns +Array+ of locations of cuts on the complementary 
+   # strand in 0-based array index notation.
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Array+ of locations of cuts on the complementary strand in 0-based array index notation.
    def complement_to_array_index
      helper_for_to_array_index(self.complement)
    end
  
+   # Returns the contents of the present CutLocationsInEnzymeNotation object as
+   # a CutLocations object with the contents converted from enzyme notation 
+   # to 0-based array index notation.
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +CutLocations+
    def to_array_index
      unless self.primary_to_array_index.size == self.complement_to_array_index.size

Index: cut_location_pair_in_enzyme_notation.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cut_location_pair_in_enzyme_notation.rb	31 Dec 2006 21:50:31 -0000	1.2
--- cut_location_pair_in_enzyme_notation.rb	1 Jan 2007 05:07:04 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - Inherits from DoubleStranded::CutLocationPair
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 20,24 ****
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 20,24 ----
  
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb - Inherits from DoubleStranded::CutLocationPair
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 26,30 ****
  # License::   Distributes under the same terms as Ruby
  #
! # See CutLocationPair
  #
  class CutLocationPairInEnzymeNotation < CutLocationPair
--- 26,31 ----
  # License::   Distributes under the same terms as Ruby
  #
! # Inherits from DoubleStranded::CutLocationPair , stores the cut location pair in
! # enzyme notation instead of 0-based.
  #
  class CutLocationPairInEnzymeNotation < CutLocationPair
***************
*** 35,43 ****
  
    def validate_2( a, b )
!     if a == 0
!       raise ArgumentError, "Enzyme index notation only.  0 values are illegal."
!     end
! 
!     if b == 0
        raise ArgumentError, "Enzyme index notation only.  0 values are illegal."
      end
--- 36,40 ----
  
    def validate_2( a, b )
!     if (a == 0) or (b == 0)
        raise ArgumentError, "Enzyme index notation only.  0 values are illegal."
      end

Index: cut_location_pair.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cut_location_pair.rb	31 Dec 2006 21:50:31 -0000	1.2
--- cut_location_pair.rb	1 Jan 2007 05:07:04 -0000	1.3
***************
*** 1,4 ****
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 1,4 ----
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair.rb - Stores a cut location pair in 0-based index notation
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 20,24 ****
    
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair.rb - 
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
--- 20,24 ----
    
  #
! # bio/util/restrction_enzyme/double_stranded/cut_location_pair.rb - Stores a cut location pair in 0-based index notation
  #
  # Author::    Trevor Wennblom  <mailto:trevor at corevx.com>
***************
*** 26,48 ****
  # License::   Distributes under the same terms as Ruby
  #
! # Stores a cut location pair in 0-based index notation
! # 
! # Input:
! # +pair+:: May be two values represented as an Array, a Range, or a
! #          combination of Integer and nil values.  The first value
! #          represents a cut on the primary strand, the second represents
! #          a cut on the complement strand.
! # 
! # Example:
! #   clp = CutLocationPair.new(3,2)
! #   clp.primary                    # 3
! #   clp.complement                 # 2
! # 
! # Notes:
! # * a value of +nil+ is an explicit representation of 'no cut'
  #
  class CutLocationPair < Array
!   attr_reader :primary, :complement
  
    def initialize( *pair )
      a = b = nil
--- 26,60 ----
  # License::   Distributes under the same terms as Ruby
  #
! # Stores a single cut location pair in 0-based index notation for use with
! # DoubleStranded enzyme sequences.
  #
  class CutLocationPair < Array
!   # Location of the cut on the primary strand.
!   # Corresponds - or 'pairs' - to the complement cut.
!   # A value of +nil+ is an explicit representation of 'no cut'.
!   attr_reader :primary
!   
!   # Location of the cut on the complementary strand.
!   # Corresponds - or 'pairs' - to the primary cut.
!   # A value of +nil+ is an explicit representation of 'no cut'.
!   attr_reader :complement
  
+   # CutLocationPair constructor.
+   #
+   # Stores a single cut location pair in 0-based index notation for use with
+   # DoubleStranded enzyme sequences.
+   # 
+   # Example:
+   #   clp = CutLocationPair.new(3,2)
+   #   clp.primary                    # 3
+   #   clp.complement                 # 2
+   #
+   # ---
+   # *Arguments*
+   # * +pair+: May be two values represented as an Array, a Range, or a
+   #   combination of Integer and nil values.  The first value
+   #   represents a cut on the primary strand, the second represents
+   #   a cut on the complement strand.
+   # *Returns*:: nothing
    def initialize( *pair )
      a = b = nil
***************
*** 64,67 ****
--- 76,80 ----
      @primary = a
      @complement = b
+     return
    end
  
***************
*** 85,93 ****
  
    def validate_2( a, b )
!     if a != nil and a.negative?
!       raise ArgumentError, "0-based index notation only.  Negative values are illegal."
!     end
! 
!     if b != nil and b.negative?
        raise ArgumentError, "0-based index notation only.  Negative values are illegal."
      end
--- 98,102 ----
  
    def validate_2( a, b )
!     if (a != nil and a.negative?) or (b != nil and b.negative?)
        raise ArgumentError, "0-based index notation only.  Negative values are illegal."
      end




More information about the bioruby-cvs mailing list