soungalo | 20 Jun 10:30 2013

Converting newick to nexus

Dear mailing list members,
Could you please help me with this somewhat trivial task ?
I'm trying to convert a multi-tree newick format file to nexus format, using
the TreeIO module. I used the following code:

################
#!/usr/bin/perl -w
use strict;
use Bio::TreeIO;
my $usage = "script.pl INFILE OUTFILE\n";
my $infile = shift or die $usage;
my $outfile = shift or die $usage;

my ($filein,$fileout) =  <at> ARGV;
my ($format,$oformat) = qw(newick nexus);
my $in = Bio::TreeIO->new(-file => $infile, -format => $format);
my $out= Bio::TreeIO->new(-format => $oformat, -file => ">$outfile");

while( my $t = $in->next_tree ) {
	$out->write_tree($t);
}
################

However, results are coming out a bit weird, since the nexus translation,
header etc are repeated for every tree in the file, instead of creating a
single trees block containing all trees.
Could you please explain how to change this code in order to perform the
conversion properly, or suggest a different way of doing this ?
Any help will be appreciated. Thank you! 

--
View this message in context: http://bioperl.996286.n3.nabble.com/Converting-newick-to-nexus-tp17013.html
Sent from the Bioperl-L mailing list archive at Nabble.com.

Gmane