[BioRuby-cvs] bioruby/lib/bio tree.rb,1.4,1.5

Naohisa Goto ngoto at dev.open-bio.org
Fri Dec 15 18:43:12 UTC 2006


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

Modified Files:
	tree.rb 
Log Message:
added Bio::Tree#find_node_by_name to get node by name.


Index: tree.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/tree.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tree.rb	15 Dec 2006 18:32:00 -0000	1.4
--- tree.rb	15 Dec 2006 18:43:10 -0000	1.5
***************
*** 372,375 ****
--- 372,388 ----
      end
  
+     # Finds a node in the tree by given name and returns the node.
+     # If the node does not found, returns nil.
+     # If multiple nodes with the same name exist,
+     # the result would be one of those (unspecified).
+     def find_node_by_name(str)
+       self.each_node do |node|
+         if get_node_name(node) == str
+           return node
+         end
+       end
+       nil
+     end
+ 
      # Adds a node to the tree.
      # Returns self.




More information about the bioruby-cvs mailing list