Edinburgh-Genome-Foundry / DnaChisel

:pencil2: A versatile DNA sequence optimizer
https://edinburgh-genome-foundry.github.io/DnaChisel/
MIT License
213 stars 38 forks source link

Fix a referenced-before-assignment bug in UniquifyAllKmers #49

Closed sukolsak closed 3 years ago

sukolsak commented 3 years ago

The following code

from dnachisel import *
sequence = random_dna_sequence(50000)
constraint = UniquifyAllKmers(10, include_reverse_complement=False)
problem = DnaOptimizationProblem(sequence, constraints=[constraint])
print(problem.constraints_text_summary())

produces the following error

  File "/dnachisel/lib/python3.8/site-packages/dnachisel/builtin_specifications/UniquifyAllKmers.py", line 53, in get_kmer_extractor_cached
    @lru_cache(maxsize=L)
UnboundLocalError: local variable 'L' referenced before assignment

This only happens when using UniquifyAllKmers with include_reverse_complement=False.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 89.084% when pulling 47322b2239000dff9691ec6d609b2204cee0b71d on sukolsak:fix-uniquify-all-k-mers into 726b2b0254a8dbd9f51a78998cbb4e43cb096057 on Edinburgh-Genome-Foundry:master.

veghp commented 3 years ago

Thank you! I added a test and merged your commit to the dev branch so it will be included in the next release.