I'm trying to write a script to calculate all of the possible fuzzy string match matches to for a short string, or 'kmer', and the same code that works in Python 2.7.X gives me a non-deterministic answer with Python 3.3.X, and I can't figure out why.
I iterate over a dictionary, itertools.product, and itertools.combinations in my code, but I iterate over all of them to completion with no breaks or continues. In addition, I store all of my results in a separate dictionary instead of the one I'm iterating over. In short - I'm not making any mistakes that are obvious to me, so why is the behavior different between Python2 and Python3?
Sample, slightly simplified code below:
import itertools
def find_best_fuzzy_kmer( kmers ):
for kmer, value in kmers.items():
for similar_kmer in permute_string( kmer, m ):
# Tabulate Kmer
def permute_string( query, m ):
query_list = list(query)
output = set() # hold output
for i in range(m+1):
# pre-calculate the possible combinations of new bases
base_combinations = list(itertools.product('AGCT', repeat=i))
# for each combination `idx` in idxs, replace str[idx]
for positions in itertools.combinations(range(len(query_list)), i):
for bases in base_combinations:
# Generate Permutations and add to output
return output