def robinson_foulds(self, <EOL>t2, <EOL>attr_t1="<STR_LIT:name>", <EOL>attr_t2="<STR_LIT:name>",<EOL>unrooted_trees=False, <EOL>expand_polytomies=False,<EOL>polytomy_size_limit=<NUM_LIT:5>, <EOL>skip_large_polytomies=False,<EOL>correct_by_polytomy_size=False, <EOL>min_support_t1=<NUM_LIT:0.0>,<EOL>min_support_t2=<NUM_LIT:0.0>):
ref_t = self<EOL>target_t = t2<EOL>if not unrooted_trees and (len(ref_t.children) > <NUM_LIT:2> or len(target_t.children) > <NUM_LIT:2>):<EOL><INDENT>raise TreeError("<STR_LIT>")<EOL><DEDENT>if expand_polytomies and correct_by_polytomy_size:<EOL><INDENT>raise TreeError("<STR_LIT>")<EOL><DEDENT>if expand_polytomies and unrooted_trees:<EOL><INDENT>raise TreeError("<STR_LIT>")<EOL><DEDENT>attrs_t1 = set([getattr(n, attr_t1) for n in ref_t.iter_leaves() if hasattr(n, attr_t1)])<EOL>attrs_t2 = set([getattr(n, attr_t2) for n in target_t.iter_leaves() if hasattr(n, attr_t2)])<EOL>common_attrs = attrs_t1 & attrs_t2<EOL>attrs_t1, attrs_t2 = None, None<EOL>size1 = len([True for n in ref_t.iter_leaves() if getattr(n, attr_t1, None) in common_attrs])<EOL>size2 = len([True for n in target_t.iter_leaves() if getattr(n, attr_t2, None) in common_attrs])<EOL>if size1 > len(common_attrs):<EOL><INDENT>raise TreeError('<STR_LIT>')<EOL><DEDENT>if size2 > len(common_attrs):<EOL><INDENT>raise TreeError('<STR_LIT>')<EOL><DEDENT>if expand_polytomies:<EOL><INDENT>ref_trees = [<EOL>TreeNode(nw) for nw in<EOL>ref_t.expand_polytomies(<EOL>map_attr=attr_t1,<EOL>polytomy_size_limit=polytomy_size_limit,<EOL>skip_large_polytomies=skip_large_polytomies<EOL>)<EOL>]<EOL>target_trees = [<EOL>TreeNode(nw) for nw in<EOL>target_t.expand_polytomies(<EOL>map_attr=attr_t2,<EOL>polytomy_size_limit=polytomy_size_limit,<EOL>skip_large_polytomies=skip_large_polytomies,<EOL>)<EOL>]<EOL>attr_t1, attr_t2 = "<STR_LIT:name>", "<STR_LIT:name>"<EOL><DEDENT>else:<EOL><INDENT>ref_trees = [ref_t]<EOL>target_trees = [target_t]<EOL><DEDENT>polytomy_correction = <NUM_LIT:0><EOL>if correct_by_polytomy_size:<EOL><INDENT>corr1 = sum([<NUM_LIT:0>]+[len(n.children) - <NUM_LIT:2> for n in ref_t.traverse() if len(n.children) > <NUM_LIT:2>])<EOL>corr2 = sum([<NUM_LIT:0>]+[len(n.children) - <NUM_LIT:2> for n in target_t.traverse() if len(n.children) > <NUM_LIT:2>])<EOL>if corr1 and corr2:<EOL><INDENT>raise TreeError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>polytomy_correction = max([corr1, corr2])<EOL><DEDENT><DEDENT>min_comparison = None<EOL>for t1 in ref_trees:<EOL><INDENT>t1_content = t1.get_cached_content()<EOL>t1_leaves = t1_content[t1]<EOL>if unrooted_trees:<EOL><INDENT>edges1 = set([<EOL>tuple(sorted([tuple(sorted([getattr(n, attr_t1) for n in content if hasattr(n, attr_t1) and getattr(n, attr_t1) in common_attrs])),<EOL>tuple(sorted([getattr(n, attr_t1) for n in t1_leaves-content if hasattr(n, attr_t1) and getattr(n, attr_t1) in common_attrs]))]))<EOL>for content in six.itervalues(t1_content)])<EOL>edges1.discard(((),()))<EOL><DEDENT>else:<EOL><INDENT>edges1 = set([<EOL>tuple(sorted([getattr(n, attr_t1) for n in content if hasattr(n, attr_t1) and getattr(n, attr_t1) in common_attrs]))<EOL>for content in six.itervalues(t1_content)])<EOL>edges1.discard(())<EOL><DEDENT>if min_support_t1:<EOL><INDENT>support_t1 = dict([<EOL>(tuple(sorted([getattr(n, attr_t1) for n in content if hasattr(n, attr_t1) and getattr(n, attr_t1) in common_attrs])), branch.support)<EOL>for branch, content in six.iteritems(t1_content)])<EOL><DEDENT>for t2 in target_trees:<EOL><INDENT>t2_content = t2.get_cached_content()<EOL>t2_leaves = t2_content[t2]<EOL>if unrooted_trees:<EOL><INDENT>edges2 = set([<EOL>tuple(sorted([<EOL>tuple(sorted([getattr(n, attr_t2) for n in content if hasattr(n, attr_t2) and getattr(n, attr_t2) in common_attrs])),<EOL>tuple(sorted([getattr(n, attr_t2) for n in t2_leaves-content if hasattr(n, attr_t2) and getattr(n, attr_t2) in common_attrs]))]))<EOL>for content in six.itervalues(t2_content)])<EOL>edges2.discard(((),()))<EOL><DEDENT>else:<EOL><INDENT>edges2 = set([<EOL>tuple(sorted([getattr(n, attr_t2) for n in content if hasattr(n, attr_t2) and getattr(n, attr_t2) in common_attrs]))<EOL>for content in six.itervalues(t2_content)])<EOL>edges2.discard(())<EOL><DEDENT>if min_support_t2:<EOL><INDENT>support_t2 = dict([<EOL>(tuple(sorted(([getattr(n, attr_t2) for n in content if hasattr(n, attr_t2) and getattr(n, attr_t2) in common_attrs]))), branch.support)<EOL>for branch, content in six.iteritems(t2_content)])<EOL><DEDENT>discard_t1, discard_t2 = set(), set()<EOL>if min_support_t1 and unrooted_trees:<EOL><INDENT>discard_t1 = set([p for p in edges1 if support_t1.get(p[<NUM_LIT:0>], support_t1.get(p[<NUM_LIT:1>], <NUM_LIT>)) < min_support_t1])<EOL><DEDENT>elif min_support_t1:<EOL><INDENT>discard_t1 = set([p for p in edges1 if support_t1[p] < min_support_t1])<EOL><DEDENT>if min_support_t2 and unrooted_trees:<EOL><INDENT>discard_t2 = set([p for p in edges2 if support_t2.get(p[<NUM_LIT:0>], support_t2.get(p[<NUM_LIT:1>], <NUM_LIT>)) < min_support_t2])<EOL><DEDENT>elif min_support_t2:<EOL><INDENT>discard_t2 = set([p for p in edges2 if support_t2[p] < min_support_t2])<EOL><DEDENT>rf = len(((edges1 ^ edges2) - discard_t2) - discard_t1) - polytomy_correction<EOL>if unrooted_trees:<EOL><INDENT>max_parts = (len([p for p in edges1 - discard_t1 if len(p[<NUM_LIT:0>])><NUM_LIT:1> and len(p[<NUM_LIT:1>])><NUM_LIT:1>]) +<EOL>len([p for p in edges2 - discard_t2 if len(p[<NUM_LIT:0>])><NUM_LIT:1> and len(p[<NUM_LIT:1>])><NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>max_parts = (len([p for p in edges1 - discard_t1 if len(p)><NUM_LIT:1>]) +<EOL>len([p for p in edges2 - discard_t2 if len(p)><NUM_LIT:1>])) - <NUM_LIT:2><EOL><DEDENT>if not min_comparison or min_comparison[<NUM_LIT:0>] > rf:<EOL><INDENT>min_comparison = [rf, max_parts, common_attrs, edges1, edges2, discard_t1, discard_t2]<EOL><DEDENT><DEDENT><DEDENT>return min_comparison<EOL>
Returns the Robinson-Foulds symmetric distance between current
tree and a different tree instance.

Parameters:
-----------
t2: 
    reference tree
attr_t1: 
    Compare trees using a custom node attribute as a node name.
attr_t2: 
    Compare trees using a custom node attribute as a node name in target tree.
attr_t2: 
    If True, consider trees as unrooted.
False expand_polytomies: 
    If True, all polytomies in the reference and target tree will be 
    expanded into all possible binary trees. Robinson-foulds distance 
    will be calculated between all tree combinations and the minimum 
    value will be returned.
    See also, :func:`NodeTree.expand_polytomy`.

Returns:
--------
(rf, rf_max, common_attrs, names, edges_t1, edges_t2, 
 discarded_edges_t1, discarded_edges_t2)