[Bioperl-l] problem parsing a newick format

Mark A. Jensen maj at fortinbras.us
Thu Feb 12 07:39:36 EST 2009

Do the trees in your test file end with a semicolon? When I do

use Bio::TreeIO;
$inp = Bio::TreeIO->new(-fh=>\*DATA, -format=>'newick);

$tre is empty, but when

use Bio::TreeIO;
$inp = Bio::TreeIO->new(-fh=>\*DATA, -format=>'newick);

$tre contains the tree.

If this is the problem, it sounds like a bug to me-
  ----- Original Message ----- 
  From: Chrysanthi A.
  To: Mark A. Jensen
  Cc: BioPerl List
  Sent: Thursday, February 12, 2009 5:42 AM
  Subject: Re: [Bioperl-l] problem parsing a newick format

  I tried also that, but it does not work.. It does not give me any error message.. It 
seems that the code is correct, but It does not print anything..Why???



  2009/2/12 Mark A. Jensen <maj at fortinbras.us>

    C- I think you maybe want

    my $input = new Bio::TreeIO(-file =>"nexusCytochrome7R.newick",
                              -format => "newick");

    and not

      my $input = new Bio::TreeIO(-fh =>"nexusCytochrome7R.newick",
                                -format => "newick");



    ----- Original Message ----- From: "Chrysanthi A." <chrysain at gmail.com>
    To: "BioPerl List" <bioperl-l at lists.open-bio.org>
    Sent: Wednesday, February 11, 2009 9:13 PM
    Subject: [Bioperl-l] problem parsing a newick format

      Is the code below correct?? Why it does not print anything???
      use strict;

      use Bio::TreeIO;

      my $input = new Bio::TreeIO(-fh =>"nexusCytochrome7R.newick",
                                -format => "newick");

      while(my $tree = $input->next_tree){
        for my $node(grep{!$_->is_Leaf}$tree->get_nodes){
      next if !$node->ancestor;
      print "Node:", $node->id, "length:", $node->branch_length, " ";
      for my $child($node->get_Descendents){
        print "child:", $child->id, "", $child->branch_length, " ";
        print "\n";

      Any ideas? I want to read a tree and mainly get the duplication events.
      Could someone help me?

      Thanks a lot,

      Bioperl-l mailing list
      Bioperl-l at lists.open-bio.org

More information about the Bioperl-l mailing list