> I planning to use Archaeopteryx to display phylogenetic trees in the next
> TreeFam release.
Cool! As it happens I'm now sitting next to Christian Zmasek (in
Moscow, of all places). I assume he's aware of your plans? Small world
:-)
> I hope it is ok, to ask you two more questions. I am totally stuck and have
> no clue how to solve it. Your help is much appreciated!
Absolutely, very welcome.
> Using my $taxa = $forest->make_taxa you create a taxon block. This allows
> you to iterate over
> all terminal taxa using $taxa->visit.
>
> Question: How can you do the same with internal nodes?
There's a number of different ways. An easy way is with $tree->visit.
Both trees and taxa inherit from Bio::Phylo::Listable, so both can be
used in the same way. Also, nodes have a method $node->is_internal
(and $node->is_terminal, $node->is_root) so you should be able to hack
something together with that :-)
A downside of doing it that way is that it treats the tree simply as a
flat list of nodes, so if you want to do something topologically
clever (like compute paths) you might be interested in:
$tree->visit_depth_first, which takes named arguments whose values are
subroutine references, i.e.:
$tree->visit_depth_first(
'-pre' => sub { print "executed in pre-order traversal, i.e. parent
before child" },
'-post' => sub { print "executed in post-order traversal, i.e. child
before parent" },
);
> 2. I would like to display domain architecture information.
> The corresponding xml looks like this and works in Archaeopteryx.
> <sequence>
> <domain_architecture length="1249">
> <domain from="1" to="245" confidence="7.0E-26">COX1</domain>
> <domain from="1168" to="1204" confidence="0.3">piwi</domain>
> </domain_architecture>
> </sequence>
This can be done, easily but in a very ugly way :-)
I never got around to doing the domain architecture annotations
properly, but you can do something like this, i.e. by inserting XML
strings:
my $tree = $forest->first;
$tree->visit(sub{
my $node = shift;
my $arch = _create_dummy_architecture();
$node->add_meta(
$fac->create_meta(
'-namespaces' => { 'pxml' => _NS_PHYLOXML_ },
'-triple' => { 'pxml:sequence' => $arch },
)
);
});
sub _create_dummy_architecture {
return
'<domain_architecture length="1249">
<domain from="1" to="245" confidence="7.0E-26">COX1</domain>
<domain from="1168" to="1204" confidence="0.3">piwi</domain>
</domain_architecture>';
}
The result looks like this, which I think is roughly what you are after:
<?xml version="1.0" encoding="UTF-8"?>
<phyloxml xmlns="
http://www.phyloxml.org"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.phyloxml.org
http://www.phyloxml.org/1.10/phyloxml.xsd">
<phylogeny rooted="true">
<clade>
<sequence>
<domain_architecture length="1249">
<domain confidence="7.0E-26" from="1" to="245">COX1</domain>
<domain confidence="0.3" from="1168" to="1204">piwi</domain>
</domain_architecture>
</sequence>
<clade>
<sequence>
<domain_architecture length="1249">
<domain confidence="7.0E-26" from="1" to="245">COX1</domain>
<domain confidence="0.3" from="1168" to="1204">piwi</domain>
</domain_architecture>
</sequence>
<clade>
<name>Homo_sapiens</name>
<sequence>
<domain_architecture length="1249">
<domain confidence="7.0E-26" from="1" to="245">COX1</domain>
<domain confidence="0.3" from="1168" to="1204">piwi</domain>
</domain_architecture>
</sequence>
<taxonomy>
<code>HS</code>
</taxonomy>
</clade>
<clade>
<name>Pan_troglodytes</name>
<sequence>
<domain_architecture length="1249">
<domain confidence="7.0E-26" from="1" to="245">COX1</domain>
<domain confidence="0.3" from="1168" to="1204">piwi</domain>
</domain_architecture>
</sequence>
<taxonomy>
<code>PT</code>
</taxonomy>
</clade>
</clade>
<clade>
<name>Gorilla_gorilla</name>
<sequence>
<domain_architecture length="1249">
<domain confidence="7.0E-26" from="1" to="245">COX1</domain>
<domain confidence="0.3" from="1168" to="1204">piwi</domain>
</domain_architecture>
</sequence>
<taxonomy>
<code>GG</code>
</taxonomy>
</clade>
</clade>
</phylogeny>
</phyloxml>
Best wishes,
Rutger