[Bioperl-l] Converting newick to nexus
soungalo
soungalo at walla.com
Thu Jun 20 08:30:29 UTC 2013
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) = @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.
More information about the Bioperl-l
mailing list