Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ade69b80cdaceefefbad10408e76f731 > files > 1092

perl-BioPerl-1.6.901-5.mga4.noarch.rpm

#!/usr/bin/perl
# Author: Jason Stajich <jason.stajich@duke.edu>
# Convert a PAUP tree block to Phylip format

use strict;

my @data;
while(<>) {     
    last if( /Translate/ );
}
while(<>) { 
    last if (/;/);
    my ($num, $taxon) = (/\s+(\d+)\s([A-Za-z\.\_]+),/);
    $data[$num] = substr($taxon,0,10);
}
while(<>) {    
    next unless (s/^\s*tree (\S+) = \[\S+\] //i);
    my $tree = $_;    
    for( my $i=scalar @data; $i > 0; $i-- ) {
	my $taxon = $data[$i];
	$tree =~ s/$i/$taxon/;
    }    
    print $tree;    
}