Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 561d6af651e4b42e704f3cdabd8080c7 > files > 106

perl-BioPerl-1.7.5-2.mga7.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;    
}