[Bioperl-l] Drawing ASCII trees (was Bio::TreeIO::tabtree Question)

Jason Stajich jason at cgt.duhs.duke.edu
Sun Sep 21 10:32:36 EDT 2003


As I responded to Simon off-list tabtree was just a play format output I
had started but never finished.  This would be a fun project for the
compsci types out there.

A bunch of solutions exist for this problem it just requires applying it
to the Bio::Tree::Node API.  I checked in some changes on the main trunk
which at least connect things with some lines, but it still isn't as nice
as I would like to see.

If someone is keen to work on this - you basically just need to take bits
and pieces of some solutions to the perl quiz of the week #5 and apply it
to _write_tree_Helper:


[the original question]
http://perl.plover.com/qotw/misc/e005/question

[some solutions <*.pl>]
http://perl.plover.com/qotw/misc/e005/

Ideally we could support vertical and horizontal layout w/ and w/o the
boxes as many of the example solutions have done.  You would just need to
add another option when initializing TreeIO::tabtree to tell it what type
of layout you want.

If your day involves drawing a lot of trees and want some easy ways to
generate overview ASCII pictures of them this would be a good project
for you...

-jason
On Thu, 18 Sep 2003, Simon Chan wrote:

> Greetings,
>
> I've got a question regarding Bio::TreeIO::tabtree
>
> I want to draw phylogenetic trees in via ASCII and was quite happy to find
> tabtree.  I inputed a newick file that contained the tree:
>
> (B,(A,C,E),D);
>
> In my output file, I got this:
>
>         B
>         D
>
>                 A
>                 C
>                 E
>
>
> I was expecting that there would be branches (ie: " ---" ) linking the
> letters together.
> What's wrong?
>
>
> Many thanks for your time!  Any suggestions/comments would be greatly
> appreciated.
>
>
> My code is below:
> #!/usr/bin/perl -w
>
> use Bio::TreeIO;
>
> my $treeFile = "newickTreeFile.txt";
> my $in = new Bio::TreeIO(-file => "$treeFile", -format => 'newick');
> my $out = new Bio::TreeIO(-file => '>output', -format => 'tabtree');
> while( my $tree = $in->next_tree ) {      $out->write_tree($tree);  }
>
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list