maint: 644 permissions for almost all files
[bioperl-live.git] / examples / tree / paup2phylip.pl
blob7b41979389627f3b14504f79397db42ca1ffb433
1 #!/usr/bin/perl
2 # Author: Jason Stajich <jason.stajich@duke.edu>
3 # Convert a PAUP tree block to Phylip format
5 use strict;
7 my @data;
8 while(<>) {
9 last if( /Translate/ );
11 while(<>) {
12 last if (/;/);
13 my ($num, $taxon) = (/\s+(\d+)\s([A-Za-z\.\_]+),/);
14 $data[$num] = substr($taxon,0,10);
16 while(<>) {
17 next unless (s/^\s*tree (\S+) = \[\S+\] //i);
18 my $tree = $_;
19 for( my $i=scalar @data; $i > 0; $i-- ) {
20 my $taxon = $data[$i];
21 $tree =~ s/$i/$taxon/;
23 print $tree;