set_operations.py¶
Some set operations that are particularly useful for visualizing set differences
-
set_operations.combinations(keys, issorted=True)[source]¶ Return a list of comma-spliced combinations of the given keys
-
set_operations.maximal_subsets(intersections)[source]¶ takes output of set_combinations and eliminates keys whose elements are strict subsets of other keys.
returns the set of maximal sets and their lengths.
-
set_operations.obsolete_sort_setsize_and_keylength(x, y)[source]¶ Specific to the output of set_combinations or a dict of corresponding set sizes.
Sort pairs by the numeric (second element) followed by number of comma-separated elements in the key (first element)
Return descending order of size and keylength, ascending alphetic key names
-
set_operations.select_keyset_of_largest_intersection(setdict, intersected_combinations=None, howmany=3)[source]¶ Expects a dict of sets, and computes the intersections of all combinations of those sets, and returns a reduced dict of the howmany keys in setdict whose sets have the largest intersection.
intersected_combinations can be provided to facilitate re-use of a one-time calculation, but no effort is made to determine that it was calculated from setdict.
howmany is the size of the subset of setdict.keys() that should be measured. Default of 3 facilitates 3-way Venn diagrams.
-
set_operations.set_combinations(setdict)[source]¶ Build and return a dict of sets keyed by all combinations of the dictionary’s keys
-
set_operations.sort_by_setsize_and_keylength(rlist)[source]¶ Specific to the output of set_combinations or a dict of corresponding set sizes.
Sort pairs by the numeric (second element) followed by number of
1 comma-separated elements in the key (first element)
Return descending order of size and keylength, ascending alphetic key names
-
set_operations.write_distance_matrix(sets, dist_matrix, matrix=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, map=None, phylip=True, rooting=[])[source]¶ Given a dictionary of named sets, and a jaccard distance between them, write a distance matrix suitable for input to phylip or phylip-like tree-ing packages.
matrix (the output) defaults to stdout.