taleinat / fuzzysearch

Find parts of long text or data, allowing for some changes/typos.
MIT License
301 stars 26 forks source link

ValueError: end_index must be non-negative #13

Closed theo-allnutt-bioinformatics closed 5 years ago

theo-allnutt-bioinformatics commented 5 years ago

Any idea what might be causing this error? Thanks.

T.

Traceback (most recent call last): File "/home/allnutt.t/scripts/primer_clip_fastq.py", line 111, in m=find_near_matches(primer,seq1,max_l_dist=mm) File "/home/allnutt.t/.conda/envs/py2/lib/python2.7/site-packages/fuzzysearch/init.py", line 51, in find_near_matches return search_func(subsequence, sequence, search_params) File "/home/allnutt.t/.conda/envs/py2/lib/python2.7/site-packages/fuzzysearch/init.py", line 87, in find_near_matches_levenshtein(subsequence, sequence, search_params.max_l_dist) File "/home/allnutt.t/.conda/envs/py2/lib/python2.7/site-packages/fuzzysearch/levenshtein.py", line 33, in find_near_matches_levenshtein max_l_dist) File "/home/allnutt.t/.conda/envs/py2/lib/python2.7/site-packages/fuzzysearch/levenshtein_ngram.py", line 176, in find_near_matches_levenshtein_ngrams for index in search_exact(subsequence[ngram_start:ngram_end], sequence, start_index, end_index): File "/home/allnutt.t/.conda/envs/py2/lib/python2.7/site-packages/fuzzysearch/common.py", line 159, in search_exact start_index, end_index if end_index is not None else -1) ValueError: end_index must be non-negative

theo-allnutt-bioinformatics commented 5 years ago

No problem.. I think its when the search string is longer than the subject sequence.

taleinat commented 5 years ago

Hi @theo-allnutt-bioinformatics,

This was indeed caused by an internal bug. It has now been fixed in commit 05f33c43 and will be included in the next release. Thanks for reporting this!

Regardless, I'm happy that you could quickly find a workaround :)

jtlz2 commented 4 years ago

@taleinat Amazing module - thanks - unfortunately I still get the problem above in 0.7.2. Should it have been fixed therein? Thanks again

taleinat commented 4 years ago

Hi @jtlz2,

The fix mentioned above is indeed included since version 0.6.2. You may be encountering a similar bug.

It would be great if you could open a new issue with example code that reproduces the error you're seeing!

taleinat commented 4 years ago

Also, could you please mention what platform you're running on and what version of Python you're using, including whether it is a 64-bit build?

Similar errors are occurring on the conda-forge Windows builds, but I haven't been able to reproduce these on my own machines.

jtlz2 commented 4 years ago

@taleinat Thanks - done - see #32