[BioRuby] BioRuby: newick parser

Rutger Vos rutgeraldo at gmail.com
Mon Mar 12 23:56:16 UTC 2012


I would be flattered if you would find something of interest or
inspiration about the API of  Bio::Phylo::Forest::Tree
(http://search.cpan.org/~rvosa/Bio-Phylo-0.46/lib/Bio/Phylo/Forest/Tree.pm)
and the node objects
(http://search.cpan.org/~rvosa/Bio-Phylo-0.46/lib/Bio/Phylo/Forest/Node.pm)

On Mon, Mar 12, 2012 at 9:11 PM, Pjotr Prins <pjotr.public14 at thebird.nl> wrote:
> Bio::Tree::distance(node1,node2)'s calculating the path distance is
> pretty cool :)
>
> http://bioruby.open-bio.org/rdoc/Bio/Pathway.html#method-i-breadth_first_search
>
>  seq7.parent.should == root
>  seq4 = tree.find("seq4")
>  seq4.distance(seq7).should == 19.387756600000003
>
> Pj.
>
> On Mon, Mar 12, 2012 at 06:05:26PM +0100, Pjotr Prins wrote:
>> 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.
>> >
>>
> _______________________________________________
> BioRuby Project - http://www.bioruby.org/
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby



-- 
Dr. Rutger A. Vos
Bioinformaticist
NCB Naturalis
Visiting address: Office A109, Einsteinweg 2, 2333 CC, Leiden, the Netherlands
Mailing address: Postbus 9517, 2300 RA, Leiden, the Netherlands
http://rutgervos.blogspot.com




More information about the BioRuby mailing list