use strict; use warnings; use Bio::AlignIO; use Bio::Align::ProteinStatistics; use Bio::Tree::DistanceFactory; use Bio::TreeIO; my $alnio = Bio::AlignIO->new(-file => 'outfile.fasta', -format=>'fasta'); my $dfactory = Bio::Tree::DistanceFactory->new(-method => 'NJ'); my $stats = Bio::Align::ProteinStatistics->new; my $treeout = Bio::TreeIO->new(-format => 'newick'); while( my $aln = $alnio->next_aln ) { my $mat = $stats->distance(-method => 'Kimura', -align => $aln); my $tree = $dfactory->make_tree($mat); $treeout->write_tree($tree); }