robinson foulds distance error
Hi, I am trying to run this example from the official documentation. http://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html#robinson-foulds-distance
from ete3 import Tree t1 = Tree('(((a,b),c), ((e, f), g));') t2 = Tree('(((a,c),b), ((e, f), g));') rf, max_rf, common_leaves, parts_t1, parts_t2 = t1.robinson_foulds(t2) print t1, t2 print "RF distance is %s over a total of %s" %(rf, max_rf) print "Partitions in tree2 that were not found in tree1:", parts_t1 - parts_t2 print "Partitions in tree1 that were not found in tree2:", parts_t2 - parts_t1
However python throwing back an error: "ValueError: too many values to unpack (expected 5)" for the Line where t1.robinson_foulds(t2) is executed.
When I read about the method I came along this here in the documentation.
http://etetoolkit.org/docs/latest/reference/reference_tree.html#ete3.TreeNode.robinson_foulds
"Returns: | (rf, rf_max, common_attrs, names, edges_t1, edges_t2, discarded_edges_t1, discarded_edges_t2) " As you can see, the method returns much more values than the example does. However neither the first nor the next attempt using the second way with more result values works.
Is the documentation outdated and how can I fix it?
it is indeed outdated. thanks for reporting this.
I have the same issue. Could you please inform us the correct output format?
http://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html#robinson-foulds-distance
Just found this in the source code
def robinson_foulds(self, t2, attr_t1="name", attr_t2="name",
"""
.. versionadded: 2.2
:returns: (rf, rf_max, common_attrs, names, edges_t1, edges_t2, discarded_edges_t1, discarded_edges_t2)
"""
min_comparison = None
if not min_comparison or min_comparison[0] > rf:
min_comparison = [rf, max_parts, common_attrs, edges1, edges2, discard_t1, discard_t2]
return min_comparison
It seems that the documentation of the code is also not correct (8 items). However, the returned variable min_comparison contains 7 !
Another strange thing is about if condition such a way that it is always true!
$ grep "min_comparison" tree.py
min_comparison = None
if not min_comparison or min_comparison[0] > rf:
min_comparison = [rf, max_parts, common_attrs, edges1, edges2, discard_t1, discard_t2]
return min_comparison