|
Hi nnahar,
things ought to work correctly like this:
use Bio::Phylo::IO qw(parse unparse);
# some way to generate a forest object:
my $trees = '((A,B),C);((A,C),B);';
my $forest = parse( -format => 'newick', -string => $trees );
# write out to MRP:
print unparse( -format => 'mrp', -phylo => $forest );
...but unfortunately I made a bit of a blunder in the Bio::Phylo::set_name method. The method is now (v.0.15) as follows:
sub set_name {
my ( $self, $name ) = @_;
my $ref = ref $self;
if ( $name && $name !~ m/^['"][^'"]*['"]$/ && $name =~ m/(?:;|,|:|\(|\)|\s)/ ) {
Bio::Phylo::Util::Exceptions::BadString->throw(
error => "\"$name\" is a bad name format for $ref names"
);
}
else {
$name[ $self->get_id ] = $name =~ s/^\s*(.*?)\s*$/$1/;
}
return $self;
}
...but there is something wrong with this line:
$name[ $self->get_id ] = $name =~ s/^\s*(.*?)\s*$/$1/;
...which you can correct by hand by replacing that line inside the else block with the following:
$name =~ s/^\s*(.*?)\s*$/$1/;
$name[ $self->get_id ] = $name;
My apologies for trying to be too clever by half. This should fix it though.
Best wishes,
Rutger
|