https://github.com/wwood/bbbin
Tip revision: b98a60ba36ad03c4dafc984b9b17ac2a318b5fe0 authored by Ben Woodcroft on 18 March 2024, 05:59:38 UTC
rust: Adjust for strange case.
rust: Adjust for strange case.
Tip revision: b98a60b
uniqify_tree.rb
#!/usr/bin/env ruby
# Make each node in a tree have a unique name - otherwise FigTree at least
# cannot handle it
require 'bio'
require '/home/ben/bin/uniq'
tree = Bio::FlatFile.open(Bio::Newick, ARGF).entries[0].tree
uniq = Uniq.new
tree.each_node do |node|
#I get internal nodes here - not sure how else to skip
next if node.name.nil? or node.name.length == 0
node.name = uniq.make_unique(node.name);
end
puts tree.output(:newick)