[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.10, 1.11 analysis_basic.rb, 1.3, 1.4

Trevor Wennblom trevor at dev.open-bio.org
Tue Jan 2 07:33:48 UTC 2007


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

Modified Files:
	analysis.rb analysis_basic.rb 
Log Message:


Index: analysis_basic.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis_basic.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** analysis_basic.rb	2 Jan 2007 06:18:38 -0000	1.3
--- analysis_basic.rb	2 Jan 2007 07:33:46 -0000	1.4
***************
*** 122,127 ****
      hsh.each do |permutation_id, sequence_range|
        sequence_range.fragments.for_display.each do |fragment|
!         # NOTE might not need tr here
!         uf_ary << UniqueFragment.new(fragment.primary.tr(' ', ''), fragment.complement.tr(' ', ''))
        end
      end
--- 122,126 ----
      hsh.each do |permutation_id, sequence_range|
        sequence_range.fragments.for_display.each do |fragment|
!         uf_ary << UniqueFragment.new(fragment.primary, fragment.complement)
        end
      end
***************
*** 136,141 ****
    def create_enzyme_actions( sequence, *args )
      require 'set'
!     always_cut = []
!     indicies_of_sometimes_cut = Set.new
      
      args.each do |enzyme|
--- 135,139 ----
    def create_enzyme_actions( sequence, *args )
      require 'set'
!     all_enzyme_actions = []
      
      args.each do |enzyme|
***************
*** 143,147 ****
  
        find_match_locations( sequence, enzyme.primary.to_re ).each do |offset|
!         always_cut << enzyme.create_action_at( offset )
        end
      end
--- 141,145 ----
  
        find_match_locations( sequence, enzyme.primary.to_re ).each do |offset|
!         all_enzyme_actions << enzyme.create_action_at( offset )
        end
      end
***************
*** 149,155 ****
      # VerticalCutRange should really be called VerticalAndHorizontalCutRange
      
!     # * always_cut is now full of EnzymeActions at specific locations across 
      #   the sequence.
!     # * always_cut will now be examined to see if any EnzymeActions may
      #   conflict with one another, and if they do they'll be made note of in
      #   indicies_of_sometimes_cut.  They will then be remove FIXME
--- 147,153 ----
      # VerticalCutRange should really be called VerticalAndHorizontalCutRange
      
!     # * all_enzyme_actions is now full of EnzymeActions at specific locations across 
      #   the sequence.
!     # * all_enzyme_actions will now be examined to see if any EnzymeActions may
      #   conflict with one another, and if they do they'll be made note of in
      #   indicies_of_sometimes_cut.  They will then be remove FIXME
***************
*** 163,208 ****
      #   is competition.
      
! dirty = Set.new
! 
! =begin
!     always_cut.each_with_index do |ea, index|
!       
!     end
! =end
!     # enzyme_actions_that_always_cut may lose members, the members to be lost are recorded in indicies_of_sometimes_cut
! 
!     always_cut.each_with_index do |ea, index1|
!       conflict = false
!       other_cut_ranges = {}
  
!       always_cut.each_with_index do |i_ea, index2|
!         next if index1 == index2
!         other_cut_ranges[index2] = i_ea.cut_ranges 
!       end
        
!       other_cut_ranges.each do |key, cut_ranges|
!         
!         cut_ranges.each do |cut_range|
!           next unless cut_range.class == Bio::RestrictionEnzyme::Range::VerticalCutRange  # we aren't concerned with horizontal cuts
!           previous_cut_left, previous_cut_right = cut_range.min, cut_range.max
  
!           if (ea.right <= previous_cut_left) or
!              (ea.left > previous_cut_right) or
!              (ea.left > previous_cut_left and ea.right <= previous_cut_right) # in-between cuts
!             # no conflict
!           else
!             conflict = true
!           end
!           indicies_of_sometimes_cut += [index1, key] if conflict == true
          end
        end
      end
!     
!     sometimes_cut = always_cut.values_at( *indicies_of_sometimes_cut )
      always_cut.delete_if {|x| sometimes_cut.include? x }
  
- #puts "Sometimes cut: #{sometimes_cut.size}"
- #puts "Always cut: #{always_cut.size}"
- #puts
      [sometimes_cut, always_cut]
    end
--- 161,199 ----
      #   is competition.
      
!     # Take current EnzymeAction's entire bind site and compare it to all other
!     # EzymeAction's cut ranges.  Only look for vertical cuts as boundaries
!     # since trailing horizontal cuts would have no influence on the bind site.
!     #
!     # If example Enzyme A makes this cut pattern (cut range 2..5):
!     #
!     # 0 1 2|3 4 5 6 7
!     #      +-----+
!     # 0 1 2 3 4 5|6 7
!     #
!     # Then the bind site (and EnzymeAction range) for Enzyme B would need it's
!     # right side to be 2 or less, or it's left side to be 6 or greater.
!     
!     competition_indexes = Set.new
  
!     all_enzyme_actions[0..-2].each_with_index do |current_enzyme_action, i|
!       next if competition_indexes.include? i
        
!       all_enzyme_actions[i+1..-1].each_with_index do |comparison_enzyme_action, j|
!         j += (i + 1)
!         next if competition_indexes.include? j
  
!         if (current_enzyme_action.right <= comparison_enzyme_action.cut_ranges.min_vertical) or
!            (current_enzyme_action.left > comparison_enzyme_action.cut_ranges.max_vertical)
!           # no conflict
!         else
!           competition_indexes += [i, j] # merge both indexes into the flat set
          end
        end
      end
!         
!     sometimes_cut = all_enzyme_actions.values_at( *competition_indexes )
!     always_cut = all_enzyme_actions
      always_cut.delete_if {|x| sometimes_cut.include? x }
  
      [sometimes_cut, always_cut]
    end

Index: analysis.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** analysis.rb	2 Jan 2007 06:18:38 -0000	1.10
--- analysis.rb	2 Jan 2007 07:33:46 -0000	1.11
***************
*** 69,73 ****
                                                                              
          initial_cuts.each { |enzyme_action|
!           raise initial_cuts.inspect
             
                              enzyme_action.cut_ranges.each { |cut_range| 
--- 69,73 ----
                                                                              
          initial_cuts.each { |enzyme_action|
!           #raise initial_cuts.inspect
             
                              enzyme_action.cut_ranges.each { |cut_range| 




More information about the bioruby-cvs mailing list