[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.18, 1.19 analysis_basic.rb, 1.14, 1.15

Trevor Wennblom trevor at dev.open-bio.org
Sun May 13 04:08:04 UTC 2007


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

Modified Files:
	analysis.rb analysis_basic.rb 
Log Message:
Added view_ranges parameter to indicate preservation of cut location data in results.


Index: analysis_basic.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis_basic.rb,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** analysis_basic.rb	23 Apr 2007 17:11:11 -0000	1.14
--- analysis_basic.rb	13 May 2007 04:08:02 -0000	1.15
***************
*** 98,102 ****
    # * +hsh+: +Hash+  Keys are a permutation ID, if any.  Values are SequenceRange objects that have cuts applied.
    # *Returns*:: Bio::RestrictionEnzyme::Analysis::Fragments object populated with Bio::RestrictionEnzyme::Analysis::Fragment objects.
!   def fragments_for_display( hsh )
      ary = Fragments.new
      return ary unless hsh
--- 98,102 ----
    # * +hsh+: +Hash+  Keys are a permutation ID, if any.  Values are SequenceRange objects that have cuts applied.
    # *Returns*:: Bio::RestrictionEnzyme::Analysis::Fragments object populated with Bio::RestrictionEnzyme::Analysis::Fragment objects.
!   def fragments_for_display( hsh, view_ranges=false )
      ary = Fragments.new
      return ary unless hsh
***************
*** 104,111 ****
      hsh.each do |permutation_id, sequence_range|
        sequence_range.fragments.for_display.each do |fragment|
!         ary << Bio::RestrictionEnzyme::Fragment.new(fragment.primary, fragment.complement)
        end
      end
!     ary.uniq!
      ary
    end
--- 104,117 ----
      hsh.each do |permutation_id, sequence_range|
        sequence_range.fragments.for_display.each do |fragment|
!         if view_ranges
!           ary << Bio::RestrictionEnzyme::Fragment.new(fragment.primary, fragment.complement, fragment.p_left, fragment.p_right, fragment.c_left, fragment.c_right)
!         else
!           ary << Bio::RestrictionEnzyme::Fragment.new(fragment.primary, fragment.complement)
!         end
        end
      end
!     
!     ary.uniq! unless view_ranges
!     
      ary
    end

Index: analysis.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** analysis.rb	23 Apr 2007 19:42:55 -0000	1.18
--- analysis.rb	13 May 2007 04:08:02 -0000	1.19
***************
*** 49,56 ****
    # *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
    def cut( sequence, *args )
      res = cut_and_return_by_permutations( sequence, *args )
      return res if res.class == Symbol
      # Format the fragments for the user
!     fragments_for_display( res )
    end
  
--- 49,69 ----
    # *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
    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
  
***************
*** 79,84 ****
          when :max_permutations, 'max_permutations', :maximum_permutations, 'maximum_permutations'
            maximum_permutations = value.to_i unless value == nil
          else
!           raise ArgumentError, "Received key #{key.inspect} in argument - I only know the key ':max_permutations' currently.  Hash passed: #{hsh.inspect}"
          end
        end
--- 92,98 ----
          when :max_permutations, 'max_permutations', :maximum_permutations, 'maximum_permutations'
            maximum_permutations = value.to_i unless value == nil
+         when :view_ranges
          else
!           raise ArgumentError, "Received key #{key.inspect} in argument - I only know the key ':max_permutations' and ':view_ranges' currently.  Hash passed: #{hsh.inspect}"
          end
        end




More information about the bioruby-cvs mailing list