[BioRuby-cvs] bioruby/lib/bio/util/restriction_enzyme analysis.rb, 1.1, 1.2

Trevor Wennblom trevor at pub.open-bio.org
Sat Feb 18 22:00:57 UTC 2006


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

Modified Files:
	analysis.rb 
Log Message:
Removal and replacement of permutation.rb


Index: analysis.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/restriction_enzyme/analysis.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** analysis.rb	1 Feb 2006 07:34:11 -0000	1.1
--- analysis.rb	18 Feb 2006 22:00:55 -0000	1.2
***************
*** 22,26 ****
  require 'bio/util/restriction_enzyme'
  require 'bio/util/restriction_enzyme/analysis/sequence_range.rb'
- require 'bio/util/restriction_enzyme/analysis/permutation.rb'
  
  class Bio::RestrictionEnzyme
--- 22,25 ----
***************
*** 71,75 ****
    end
  
- 
    def cut_without_permutations( sequence, *args )
      sequence = Bio::Sequence::NA.new( sequence )
--- 70,73 ----
***************
*** 93,97 ****
      sequence = Bio::Sequence::NA.new( sequence )
      enzyme_actions = create_enzyme_actions( sequence, *args )
!     permutations = Permutation.new(enzyme_actions.size).map { |p| p.value }
  
      # Indexed by permutation.
--- 91,95 ----
      sequence = Bio::Sequence::NA.new( sequence )
      enzyme_actions = create_enzyme_actions( sequence, *args )
!     permutations = permute(enzyme_actions.size)
  
      # Indexed by permutation.
***************
*** 168,171 ****
--- 166,184 ----
    protected
    #########
+ 
+   def permute(count, permutations = [[0]])
+     return permutations if count <= 1
+     new_arrays = []
+     new_array = []
+ 
+     (permutations[0].size + 1).times do |n|
+       new_array.clear
+       permutations.each { |a| new_array << a.dup }
+       new_array.each { |e| e.insert(n, permutations[0].size) }
+       new_arrays += new_array
+     end
+ 
+     permute(count-1, new_arrays)
+   end
  
    UniqueFragment = Struct.new(:primary, :complement)




More information about the bioruby-cvs mailing list