[BioRuby-cvs] bioruby/lib/bio/db newick.rb,1.5,1.6
Naohisa Goto
ngoto at dev.open-bio.org
Fri Dec 15 14:59:28 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio/db
In directory dev.open-bio.org:/tmp/cvs-serv19837/lib/bio/db
Modified Files:
newick.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: newick.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/newick.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** newick.rb 13 Dec 2006 17:29:17 -0000 1.5
--- newick.rb 15 Dec 2006 14:59:25 -0000 1.6
***************
*** 206,209 ****
--- 206,211 ----
when :nhx
output_nhx(*arg, &block)
+ when :phylip_distance_matrix
+ output_phylip_distance_matrix(*arg, &block)
else
raise 'Unknown format'
***************
*** 211,214 ****
--- 213,235 ----
end
+ #---
+ # This method isn't suitable to written in this file?
+ #+++
+
+ # Generates phylip-style distance matrix as a string.
+ # if nodes is not given, all leaves in the tree are used.
+ # If the names of some of the given (or default) nodes
+ # are not defined or are empty, the names are automatically generated.
+ def output_phylip_distance_matrix(nodes = nil, options = {})
+ nodes = self.leaves unless nodes
+ names = nodes.collect do |x|
+ y = get_node_name(x)
+ y = sprintf("%x", x.__id__.abs) if y.empty?
+ y
+ end
+ m = self.distance_matrix(nodes)
+ Bio::Phylip::DistanceMatrix.generate(m, names, options)
+ end
+
end #class Tree
More information about the bioruby-cvs
mailing list