# converts Nexus tree output file produced by BioPerl (with ids on trees) into TreeView-readable nexus file use strict; open (INTREE, "$ARGV[0]") || die $!; open (OUTTREE, ">$ARGV[1]") || die $!; while () { print OUTTREE $_; last if /Translate/ } my %no; while () { print OUTTREE $_; last if /;/; my ($no, $id) = /(\d+)\s+('\S+')/; $no{$id} = $no; print "_$no\_\t_$id\_\n"; } while () { last if /End/; s/\(//; # remove one pair of parentheses s/('\S+?')/$no{$1}/g; s/\[\d+?\]//g; s/\);/;/; # remove one pair of parentheses print OUTTREE $_ } print OUTTREE "End;\n";