Subject: | remove_unbranched_internals does not appear to (always) work |
Date: | Sun, 10 Sep 2006 15:22:39 -0400 |
To: | bug-bio-phylo [...] rt.cpan.org |
From: | Allen Smith <easmith [...] beatrice.rutgers.edu> |
$Id: Tree.pm,v 1.23 2006/05/19 02:08:54 rvosa Exp $
The below program yields these results:
(((((Saccharomyces-NUM3,Schizosaccharomyces-NUM3),(((Saccharomyces-NUM4,Schizosaccharomyces-NUM4),(((Drosophila-NUM4,Monosiga_brevicollis-NUM4),Mus-NUM4),Schistosoma-NUM4,Caenorhabditis-NUM4)),(((Funiculina,Eunicella),(Rhabdocalyptus,Beroe),(Monosiga_brevicollis-NUM2,Monosiga_ovata),((Danio,Mus-NUM2),Crassostrea),(Asbestopluma,Chondrosia),(Nematostella,Schistosoma-NUM2),Petrobiona,Petrosia,Caenorhabditis-NUM2,Drosophila-NUM2),((Schizosaccharomyces-NUM2,Pneumocystis),Dictyostelium,Saccharomyces-NUM2)))),(Caenorhabditis-NUM3,Schistosoma-NUM3))),Aplysia);
(((((Saccharomyces-NUM3,Schizosaccharomyces-NUM3),(((Saccharomyces-NUM4,Schizosaccharomyces-NUM4),(((Drosophila-NUM4,Monosiga_brevicollis-NUM4),Mus-NUM4),Schistosoma-NUM4,Caenorhabditis-NUM4)),(((Funiculina,Eunicella),(Rhabdocalyptus,Beroe),(Monosiga_brevicollis-NUM2,Monosiga_ovata),((Danio,Mus-NUM2),Crassostrea),(Asbestopluma,Chondrosia),(Nematostella,Schistosoma-NUM2),Petrobiona,Petrosia,Caenorhabditis-NUM2,Drosophila-NUM2),((Schizosaccharomyces-NUM2,Pneumocystis),Dictyostelium,Saccharomyces-NUM2)))),(Caenorhabditis-NUM3,Schistosoma-NUM3))),Aplysia);
This is despite that there are two parentheses around everything in front of
",Aplysia", of which one should get eliminated. Incidentally, the above is
even worse if one uses the newick parser instead of the fastnewick parser:
(n22,Aplysia);
(n22,Aplysia);
One gets essentially the same result if one tries using the _analyze method
(called in a number of other subroutines, I note) on a tree, read in using
fastnewick, with unbranched internals:
(((((Saccharomyces-NUM3,Schizosaccharomyces-NUM3),(((Saccharomyces-NUM4,Schizosaccharomyces-NUM4),(((Drosophila-NUM4,Monosiga_brevicollis-NUM4),Mus-NUM4),Schistosoma-NUM4,Caenorhabditis-NUM4)),(((Funiculina,Eunicella),(Rhabdocalyptus,Beroe),(Monosiga_brevicollis-NUM2,Monosiga_ovata),((Danio,Mus-NUM2),Crassostrea),(Asbestopluma,Chondrosia),(Nematostella,Schistosoma-NUM2),Petrobiona,Petrosia,Caenorhabditis-NUM2,Drosophila-NUM2),((Schizosaccharomyces-NUM2,Pneumocystis),Dictyostelium,Saccharomyces-NUM2)))),(Caenorhabditis-NUM3,Schistosoma-NUM3))),Aplysia);
(((((Saccharomyces-NUM3,Schizosaccharomyces-NUM3),(((Saccharomyces-NUM4,Schizosaccharomyces-NUM4),(((Drosophila-NUM4,Monosiga_brevicollis-NUM4),Mus-NUM4),Schistosoma-NUM4,Caenorhabditis-NUM4)),(((Funiculina,Eunicella),(Rhabdocalyptus,Beroe),(Monosiga_brevicollis-NUM2,Monosiga_ovata),((Danio,Mus-NUM2),Crassostrea),(Asbestopluma,Chondrosia),(Nematostella,Schistosoma-NUM2),Petrobiona,Petrosia,Caenorhabditis-NUM2,Drosophila-NUM2),((Schizosaccharomyces-NUM2,Pneumocystis),Dictyostelium,Saccharomyces-NUM2)))),(Caenorhabditis-NUM3,Schistosoma-NUM3))),Aplysia);
(,Aplysia);
sub get_tree {
my $forest = Bio::Phylo::IO->parse(-string => $_[0],
-format => "fastnewick");
unless (defined($forest)) {
confess "Unable to parse '" . $_[0] . "' into forest; stopped";
}
my $tree = $forest->first;
unless (defined($tree)) {
confess "Unable to parse forest from '" . $_[0] . "' into tree; stopped";
}
return $tree;
}
sub to_newick {
return Bio::Phylo::IO->unparse( -format => 'newick', -phylo => $_[0] );
}
$tree = get_tree("(Aplysia,(((Schistosoma-NUM3,Caenorhabditis-NUM3),((((Saccharomyces-NUM2,Dictyostelium,(Pneumocystis,Schizosaccharomyces-NUM2)),(Drosophila-NUM2,Caenorhabditis-NUM2,Petrosia,Petrobiona,(Schistosoma-NUM2,Nematostella),(Chondrosia,Asbestopluma),(Crassostrea,(Mus-NUM2,Danio)),(Monosiga_ovata,Monosiga_brevicollis-NUM2),(Beroe,Rhabdocalyptus),(Eunicella,Funiculina))),((Caenorhabditis-NUM4,Schistosoma-NUM4,(Mus-NUM4,(Monosiga_brevicollis-NUM4,Drosophila-NUM4))),(Schizosaccharomyces-NUM4,Saccharomyces-NUM4))),(Schizosaccharomyces-NUM3,Saccharomyces-NUM3)))))");
print STDERR to_newick($tree) . "\n";
$tree->remove_unbranched_internals;
print STDERR to_newick($tree) . "\n";
# for _analyze shown above:
#$tree->_analyze;
#print STDERR to_newick($tree) . "\n";
--
Allen Smith http://cesario.rutgers.edu/easmith/
There is only one sound argument for democracy, and that is the argument
that it is a crime for any man to hold himself out as better than other men,
and, above all, a most heinous offense for him to prove it. - H. L. Mencken