MToolBox icon indicating copy to clipboard operation
MToolBox copied to clipboard

Out of bounds error

Open jeffgreen123 opened this issue 8 years ago • 3 comments

Running i get the following error Traceback (most recent call last): File "mtoolbox/1.0.2/MToolBox/assembleMTgenome.py", line 443, in mut_events = mtvcf_main_analysis(mt_table, sam_file, sample_name, tail=tail) File "mtoolbox/1.0.2/MToolBox/mtVariantCaller.py", line 856, in mtvcf_main_analysis qs1.append(median(qs2)) File "mtoolbox/1.0.2/MToolBox/mtVariantCaller.py", line 402, in median m1 = sorted(l)[(len(l)/2)+1-1] IndexError: list index out of range

two points m1 = sorted(l)[(len(l)/2)+1-1] is a little weird with the +1 -1 (compiler will most likely take out anyways, but a little strange).

Also this would only occur if len(l) == 0 (as far as i can tell), is it possible to put a check for this and return 0 as median (assuming this is correct behaviour)

Let me know if you have any questions or concerns :)

jeffgreen123 avatar Aug 15 '17 12:08 jeffgreen123

I have the same issue (see. issue #38 ) . I write a comment here to receive the follow-up and/or updates. Thank you again.

3i-v avatar Aug 15 '17 15:08 3i-v

I met this problem also! Mark and hope get the follow-up. Thx

jich-MCTP avatar Oct 24 '17 13:10 jich-MCTP

Now I have a solution to fix this issue. open this file:~/MToolBox/MToolBox/mtVariantCaller.py change line 406: except ZeroDivisionError: to except IndexError:

This issue reason is : when input parameter "l" is empty, python will throw an error "IndexError", it is not error "ZeroDivisionError".

I re-run my two samples which met this issue, both of them are fixed and get the right results.

If you still encounter this problem, you can left a message at here.

Best!

jich-MCTP avatar Oct 30 '17 17:10 jich-MCTP