BIMSBbioinfo/janggu

UnboundLocalError: local variable 'process_chrom' referenced before assignment

Closed this issue · 2 comments

Hi,

Your operating system name and version.
MacOS Big Sur version 11.3.1

Any details about your local setup that might be helpful in troubleshooting.
Local Environment includes these packages
conda 4.10.1
jupyter 1.0.0 py38_7
bedtools 2.30.0 h6eb76b4_0 bioconda
pybedtools 0.8.1 py38h4492e0f_2 bioconda
samtools 1.3.1 h2fe303a_7 bioconda
dash 1.19.0 pyhd3eb1b0_0
janggu 0.10.0 pypi_0 pypi
R version 4.0.3
rpy2 3.4.5 pypi_0 pypi
tzlocal 2.1 pypi_0 pypi
statsmodels 0.12.2 py38h9ed2024_0
numpy 1.20.2 py38h4b4dc7a_0
pandas 1.2.4 py38h23ab428_0

Detailed steps to reproduce the bug.
Even though I am trying to run: https://github.com/wkopp/janggu_usecases/tree/master/03_cage_prediction.py. The bug is produced
The bug is produced from running line 91 of this script: Cover.create_from_bam

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/lib/python3.8/site-packages/janggu/data/coverage.py", line 708, in create_from_bam
    cover = create_genomic_array(gsize, stranded=stranded,
  File "/opt/anaconda3/lib/python3.8/site-packages/janggu/data/genomicarray.py", line 1178, in create_genomic_array
    return NPGenomicArray(chroms, stranded=stranded,
  File "opt/anaconda3/lib/python3.8/site-packages/janggu/data/genomicarray.py", line 666, in __init__
    loader(self)
  File "/opt/anaconda3/lib/python3.8/site-packages/janggu/data/coverage.py", line 161, in __call__
    for process_chrom in unique_chroms:
UnboundLocalError: local variable 'process_chrom' referenced before assignment

Thank you for your help! I've tried troubleshooting and checked dependencies

wkopp commented

Hi @theheking ,

thank you for reporting the issue.
I've tried to reproduce this issue, but was not able to.
Here is the conda environment I've used conda environment. Note that here I am using the latest janggu version, rather than the janggu version that was used for the publication.
Furthermore, I don't have access to a MacOS system (but Linux) and I haven't tested python==3.8 but python==3.7. I'm not sure if these aspects contribute to the issue.

The issue is a bit strange, because it suggests that the variable process_chrom is undefined. Yet, the error occurs at the statement for process_chrom in unique_chroms where process_chrom should be generated by the for loop by iterating over the individual chromosome names in unique_chroms. So process_chrom shouldn't be undefined at that point. When I run the script on my end, process_chrom does not seem to be undefined, which is why I don't get the error.

If it is possible for you, could you try a different python version?

Best,
Wolfgang

Hi Wolfgang,
It works now so, thank you!
janggu_env_list.txt
This is my final janggu env list on osx-64! I was looking at the differences between python 3.7 and 3.8 but can't see any changes that could have triggered the error so it probably is something wrong with my local environment

Cheers for your quick response