mitoNGS / MToolBox

A bioinformatics pipeline to analyze mtDNA from NGS data
http://sourceforge.net/projects/mtoolbox/?source=navbar
GNU General Public License v3.0
90 stars 38 forks source link

UnboundLocalError: local variable 'consensus_value' referenced before assignment #7

Closed asifzubair closed 8 years ago

asifzubair commented 8 years ago

Hi,

I was trying to do a test run of MToolBox after I had installed all of the dependencies and copied indexes/references. I ran the script in the test folder of MToolBox.

However, I got this error:

##### ASSEMBLING MT GENOMES WITH ASSEMBLEMTGENOME...

WARNING: values of tail < 5 are deprecated and will be replaced with 5

[sam_header_read2] 93 sequences loaded.
[mpileup] 1 samples in 1 input files
<mpileup> Set max per-file depth to 8000
Traceback (most recent call last):
  File "/MToolBox/MToolBox/assembleMTgenome.py", line 447, in <module>
    consensus_single = get_consensus_single(mut_events[mut_events.keys()[0]],hf=hf)
  File "/MToolBox/MToolBox/mtVariantCaller.py", line 1044, in get_consensus_single
    return consensus_value
UnboundLocalError: local variable 'consensus_value' referenced before assignment

I looked in the code for mtVariantCaller.py and it seems that there might be an unhandled case there.

If you look at L1008

def get_consensus_single(i, hf=0.8):
    if len(i) != 0:
        consensus_value = []
        #for var in dict_of_dicts[i]:
        for var in i:
            #print var[0], var[-1], max(var[6])
            if var[-1] == 'mism' and max(var[6]) >= hf:
                        ...
                        ...
            else:
                pass
    return consensus_value

Because consensus_value is defined inside the if statement, there is a chance that MToolBox is breaking when this condition is not meant.