Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'i' referenced before assignment #22

Open
rkworkhelp1 opened this issue Mar 6, 2024 · 4 comments
Open

Comments

@rkworkhelp1
Copy link

Hello,

I encountered the following errors when trying to run uLTRA index and uLTRA align.
Help resolving this issue would be greatly appreciated.
See image for more details.

ultra_error

@ksahlin
Copy link
Owner

ksahlin commented Mar 6, 2024

Hi,

which version of uLTRA is this? You can run uLTRA --version to check.

If it is not v0.1 I suggest you update it to the latest version. If it is v0.1, I will have an extra look.

thanks,
Kristoffer

@gootee
Copy link

gootee commented Mar 22, 2024

@ksahlin Hi Kristoffer. I'm getting this same error in a confirmed v0.1 container.

File "/usr/local/lib/python3.10/site-packages/modules/create_augmented_gene.py", line 442, in create_graph_from_exon_parts
if i > 0:
UnboundLocalError: local variable 'i' referenced before assignment

In create_augmented_gene.py, is it possible that 442-449 need an additional tab to be include in the FOR loop block iterating with 'i' that begins on 311?

Thanks,
John

@ksahlin
Copy link
Owner

ksahlin commented Mar 25, 2024

Hi @gootee and @rkworkhelp1 ,

(TLDR: check that the input GTF is formatted in the way uLTRA expects it - with theexon feature in the file, column 3 in the GTF.)

I looked at the code and figured out the error. What happens is that your database does not have any exon fields in the GTF. Therefore, the loop starting at 311 in create_augmented_gene.py is never initialized. Hence, i is never initialized. This throws an error on line 442 because we expect the loop to have done some work.

I verified this by running e.g.,

def test():
  for i, x in enumerate([]):
    pass

  if i > 0:
    pass

test()

which gives the same error.

So, while the error is confusing (i should have inserted a check that db.features_of_type('exon', order_by='seqid') is not empty), fixing the error won't lead to any success on your data.

You probably need to check that the input GTF is formatted in the way uLTRA expects it (with theexon feature in the file, column 3) and then you won't get the runtime error.

HTH,
Kristoffer

@gootee
Copy link

gootee commented Mar 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants