[BioRuby] BioRuby: newick parser

Pjotr Prins pjotr.public14 at thebird.nl
Mon Mar 12 17:05:26 UTC 2012


OK, this works:

  @aln.link_tree(@tree)  # @tree contains a parsed Newick tree
  root = @aln.root # get the root of the tree
  root.leaf?.should == false
  children = root.children
  children.map { |n| n.name }.sort.should == ["","seq7"]
  seq7 = children.last
  seq7.name.should == 'seq7'
  seq7.leaf?.should == true
  seq7.parent.should == root

the added functionality for BioRuby's Bio::Tree::Node can be seen here

  https://github.com/pjotrp/bioruby-alignment/blob/development/lib/bio-alignment/tree.rb

basically I inject the @tree info into every existing Node object.
>From then on, I can use it to make the interface nicer. A monkey
patch, indeed.

Good enough for now.

Pj.

On Mon, Mar 12, 2012 at 05:24:38PM +0100, Pjotr Prins wrote:
> On Mon, Mar 12, 2012 at 03:18:48PM +0900, Naohisa GOTO wrote:
> > When writing HOWTO based on BioPerl HOWTO:Trees,
> > (http://bioruby.open-bio.org/wiki/HOWTO:Trees but still incomplete)
> > I'm thinking to add/modify some API about speficying nodes/edges.
> 
> After some trying I agree. The Bio::Tree::Node object should know
> 'more' about its state. I would like to do something like:
> 
>   root.leaf?.should == false
>   node = root.childeren.first
>   node.leaf?.should == false
>   node2 == node.childeren.first
>   node.leaf?.should == true
>   node2.edge(node).distance.should == 1.34
> 
> now I need to do something like 
> 
>   tree = @tree
>   node = tree.get_node_by_name('node')
>   tree.get_edge(node, tree.parent(node)).distance.should == 1.34
> 
> which uses the tree state to get a node edge, and does not feel that
> intuitive.
> 
> I'll try to extend Bio::Tree for bio-alignment, see what works.
> 
> Pj.
> 



More information about the BioRuby mailing list