[Bioperl-l] Need help for implementing a new TreeIO module
Jason Stajich
jason.stajich at duke.edu
Mon Jan 3 11:13:34 EST 2005
Guillaume -
Ironic - I was just starting to download a bunch of jpackage stuff and
seeing your name everywhere.... Trying to get FOP working so can try
and build our docbook HOWTOs on linux.
The thing is you need to build the tree by connecting the nodes, so the
order they are created in is very important. You can't just build the
leaves first and then the (internal) nodes later. You need to build
from the top down - if you read a newick format from left to right,
that is exactly how we are building the tree up using the
EventListener.
In a way the builder basically assumes you have already have the tree
built, just encoded. So you start with a root node, you add children.
For each child you add more children where appropriate until you get to
a leaf node and you are done with that recursion.
-jason
On Jan 3, 2005, at 10:53 AM, Guillaume Rousse wrote:
> I'm trying to implement a Bio::TreeIO module for parsing
> Alogrithm::Cluster::treecluster output, and I need some help about the
> tree event builder module. Reading the code, I understand I can add
> elements of type 'tree', 'branch-length', 'id', 'node', and 'leaf',
> and also add characters. However, I don't really understand how it
> works...
>
> Basically, I know all leaves right from given parameters. Then I parse
> a result table, line by line, each new line being an internal node
> whose length is given. So I guess, the code should be similar to:
>
> $self->_eventHandler->start_document;
> $self->_eventHandler->start_element( {'Name' => 'tree'} );
>
> # leaves
> foreach my $label (@{$self->{_labels}} {
> $self->_eventHandler->start_element( {'Name' => 'leaf'} );
> $self->_eventHandler->characters($label);
> $self->_eventHandler->end_element( {'Name' => 'leaf'} );
> }
>
> # nodes
> foreach my $line (@{$self->{_result}} {
> $self->_eventHandler->start_element( {'Name' => 'node'} );
> # this node result from the merge of two already existing leaves
> or nodes with a known distance
> $self->_eventHandler->end_element( {'Name' => 'node'} );
> }
>
> $self->_eventHandler->end_element( {'Name' => 'tree'} );
> my $tree = $self->_eventHandler->end_document;
>
> Any help appreciated.
> --
> Any circuit design must contain at least one part which is obsolete,
> two parts which are unobtainable and three parts which are still under
> development
> -- Murphy's Laws on Technology n°23
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
>
--
Jason Stajich
jason.stajich at duke.edu
http://www.duke.edu/~jes12/
More information about the Bioperl-l
mailing list