Thread

Posted on Thu Dec 14 23:44:30 2006 by nnahar
Example for module Bio::Phylo::Unparsers::Mrp
Hello everyone, I was wondering if someone could point me to an example as to how to use the Bio::Phylo::Unparsers::Mrp module. I have a set of phylogenetic trees and I want to generate an MRP matrix from them. Please let me know. Thank you for your help. Regards, nnahar
Direct Responses: 3796 | Write a response
Posted on Fri Dec 15 00:59:20 2006 by rvosa in response to 3790
Re: Example for module Bio::Phylo::Unparsers::Mrp
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
Write a response