[ensembl-dev] NHX & phyloXML

Matthieu Muffato muffato at ebi.ac.uk
Fri May 17 14:17:48 BST 2013


On 17/05/13 12:36, Moretti Sébastien wrote:
> Hi
>
> I wonder if you have a module, or a script, in the Ensembl API to
> convert from NHX trees to phyloXML trees.
>
> For what I found, it looks you generate NHX and phyloXML from the
> database, and you don't convert from one format to the other directly.
>
> Am I right?
> Regards
>

Hi Sébastien,

We have a NHX parser and a PhyloXML writer. I believe it is possible to 
connect them, though I haven't tried. Here are the two bits you can use:

To get the tree structure from the NHX:
my $tree = 
Bio::EnsEMBL::Compara::Graph::NewickParser::parse_newick_into_tree($str);

To write it in PhyloXML format to the file handle $fh:
my $w = Bio::EnsEMBL::Compara::Graph::PhyloXMLWriter->new(-SOURCE => 
'compara', -NO_SEQUENCES => 1, -HANDLE => $fh, -NO_RELEASE_TREES => 1);
$w->write_trees($tree);
$w->finish();


Hope this helps,
Matthieu


-- 
Matthieu Muffato, Ph.D.
Ensembl Developer - Comparative Genomics
European Bioinformatics Institute (EMBL-EBI)
Wellcome Trust Genome Campus, Hinxton
Cambridge, CB10 1SD, United Kingdom




More information about the Dev mailing list