lib/bio/nwk.rb in bio-nwk-0.1.1 vs lib/bio/nwk.rb in bio-nwk-0.1.2
- old
+ new
@@ -15,10 +15,14 @@
rv = descendents(node).select{|n|children(n).empty?}
end
return(rv)
end
+ def all_nodes_of_subtree(node)
+ [leaves(node), tips(node)].flatten
+ end
+
def cleanName!
allTips.each do |tip|
tip.name.gsub!(' ', '_')
end
end
@@ -34,9 +38,18 @@
def twoTaxaNodeName(node)
if node.isTip?(self)
return(node.name)
else
return children(node).map{|child|tips(child).sort_by{|i|i.name}.shift}.sort_by{|i|i.name}.map{|i|i.name}
+ end
+ end
+
+ def twoTaxaNodeNameStr(node, sep='|')
+ a = twoTaxaNodeName(node)
+ if a.is_a?(Array)
+ return(a.join(sep))
+ else
+ return(a)
end
end
def sisters(node)
if node == root