[Bioperl-l] Need help for implementing a new TreeIO module

Guillaume Rousse rousse at ccr.jussieu.fr
Mon Jan 3 10:53:38 EST 2005


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


More information about the Bioperl-l mailing list