Method: Bio::Tree#collect_node!
- Defined in:
- lib/bio/tree.rb
#collect_node! ⇒ Object
Replaces each node by each block’s return value. Returns self.
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/bio/tree.rb', line 487 def collect_node! #:yields: node tr = {} self.each_node do |node| tr[node] = yield node end # replaces nodes in @pathway.relations @pathway.relations.each do |rel| rel.node.collect! { |node| tr[node] } end # re-generates @pathway from relations @pathway.to_list # adds orphan nodes tr.each_value do |newnode| @pathway.graph[newnode] ||= {} end self end |