[BioRuby] newick tree

Ben Woodcroft donttrustben at gmail.com
Thu Jan 22 02:39:50 UTC 2009


I had the same problem - managed to solve it, but it wasn't the best. It
used something like this:

count = 0
tree.each_node do |node|
  #I get internal nodes here - not sure how else to skip
  next if node.name.nil? or node.name.length == 0

  count += 1
end
count

2009/1/22 Tomoaki NISHIYAMA <tomoakin at kenroku.kanazawa-u.ac.jp>

> Hi,
>
> I have not used the Newick feature of bioruby but the behavior
> you showed seems doing quite right.
> What is your expectation? Or, what do you want?
>
> (A,(B,C),D)
> represents the following tree, which have 4 terminal and 2 internal nodes.
>
> +------A
> |
> |   +---B
> |   |
> +---+
> |   |
> |   +---C
> |
> +-----D
>
> The two internal nodes have no label and referred as (Node:43c98a8)
> (Node:43c91f0) in the representation.
>
> --
> Tomoaki NISHIYAMA
>
> Advanced Science Research Center,
> Kanazawa University,
> 13-1 Takara-machi,
> Kanazawa, 920-0934, Japan
>
>
>
> On 2009/01/22, at 8:11, K. Patil wrote:
>
>  Hi,
>>
>> I was trying some simple methods for the Newick tree. I did the following,
>>
>>  t = Bio::Newick.new("(A,(B,C),D)")
>>> t.tree.nodes
>>>
>> =>[(Node:43c98a8), (Node:"A"), (Node:"B"), (Node:"D"), (Node:43c91f0),
>> (Node:"C")]
>>
>>> t.tree.number_of_nodes
>>>
>> => 6
>>
>> Am I doing something wrong? I am using bioruby version 1.2.1 in ruby 1.8.
>> Any suggestions are welcome.
>>
>> Cheers,
>> Kaustubh
>>
>>
>>
>> _______________________________________________
>> BioRuby mailing list
>> BioRuby at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioruby
>>
>>
> _______________________________________________
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby
>



-- 
FYI: My email addresses at unimelb, uq and gmail all redirect to the same
place.



More information about the BioRuby mailing list