PTreeGenerator  1.0
Simple phylogenetic tree generation from multiple sequence alignment.
 All Classes Namespaces Files Functions Variables
Functions
ptreegen.utilities.combination_utils Namespace Reference

Functions

def uniqueCombinationsGenerator
 A generator of unique combinations of size n from the given list of items.
def combinationsGenerator
 A generator of all non-unique combinations (permutations) of size n from the given list of items.

Function Documentation

def ptreegen.utilities.combination_utils.combinationsGenerator (   items,
  n 
)

A generator of all non-unique combinations (permutations) of size n from the given list of items.

Parameters
itemsan iterable to be processed
nsize of each of the combinations generated
Returns
returns all possible unique combinations as a list of lists

Definition at line 29 of file combination_utils.py.

29 
30 def combinationsGenerator(items, n):
31  if not n:
32  yield []
33  else:
34  for i in xrange(len(items)):
35  for comb in combinationsGenerator(items[:i]+items[i+1:],n-1):
36  yield [items[i]] + comb
def ptreegen.utilities.combination_utils.uniqueCombinationsGenerator (   items,
  n 
)

A generator of unique combinations of size n from the given list of items.

Parameters
itemsan iterable to be processed
nsize of each of the unique combinations generated
Returns
returns all possible unique combinations as a list of lists

Definition at line 14 of file combination_utils.py.

14 
15 def uniqueCombinationsGenerator(items, n):
16  if not n:
17  yield []
18  else:
19  for i in xrange(len(items)):
20  for comb in uniqueCombinationsGenerator(items[i+1:], n-1):
21  yield [items[i]] + comb