[BioRuby-cvs] bioruby/lib/bio/appl/phylip distance_matrix.rb, 1.1, 1.2

Naohisa Goto ngoto at dev.open-bio.org
Fri Dec 15 14:59:28 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/appl/phylip
In directory dev.open-bio.org:/tmp/cvs-serv19837/lib/bio/appl/phylip

Modified Files:
	distance_matrix.rb 
Log Message:
Bio::Tree#output_phylip_distance_matrix(...) and
Bio::Tree#output(:phylip_distance_matrix, ...) are added
to output phylip-style distance matrix as a string.


Index: distance_matrix.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/phylip/distance_matrix.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** distance_matrix.rb	15 Dec 2006 14:36:14 -0000	1.1
--- distance_matrix.rb	15 Dec 2006 14:59:26 -0000	1.2
***************
*** 67,79 ****
  
        # Generates a new phylip distance matrix formatted text as a string.
!       def self.generate(matrix, otu_names = nil)
          if matrix.row_size != matrix.column_size then
            raise "must be a square matrix"
          end
          otus = matrix.row_size
!         data = (0...otus).collect do |i|
            name = ((otu_names and otu_names[i]) or "OTU#{i.to_s}")
            x = (0...otus).collect { |j|  sprintf("%9.6f", matrix[i, j]) }
!           x.unshift(sprintf("%-10s", name)[0, 10])
  
            str = x[0, 7].join(' ') + "\n"
--- 67,82 ----
  
        # Generates a new phylip distance matrix formatted text as a string.
!       def self.generate(matrix, otu_names = nil, options = {})
          if matrix.row_size != matrix.column_size then
            raise "must be a square matrix"
          end
          otus = matrix.row_size
!         names = (0...otus).collect do |i|
            name = ((otu_names and otu_names[i]) or "OTU#{i.to_s}")
+           name
+         end
+         data = (0...otus).collect do |i|
            x = (0...otus).collect { |j|  sprintf("%9.6f", matrix[i, j]) }
!           x.unshift(sprintf("%-10s", names[i])[0, 10])
  
            str = x[0, 7].join(' ') + "\n"




More information about the bioruby-cvs mailing list