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 'columns' referenced before assignment #73

Open
Bo-UT opened this issue Aug 1, 2024 · 2 comments
Open

Comments

@Bo-UT
Copy link

Bo-UT commented Aug 1, 2024

Hi,

I tried to run fuc maf-vcf2maf input.vcf > output.maf with the annotated vcf from vep. I got the error saying

  File "/Users/bzhao2/miniconda3/envs/single-cell/lib/python3.10/site-packages/fuc/api/pyvcf.py", line 2429, in from_string
    columns[0] = 'CHROM'
UnboundLocalError: local variable 'columns' referenced before assignment

I also tried to load the annotated vcf by pyvcf.VcfFrame.from_file, but got the same error. It did work for the vcf file without annotation.

Thank you.

@sbslee
Copy link
Owner

sbslee commented Aug 3, 2024

Hi @Bo-UT,

  1. What version of fuc are you currently using?
  2. Can you share your VCF file with me via [email protected]? It's difficult to solve a problem without seeing some data. I don't need to see your entire dataset; I just need a minimal example to replicate the issue. However, no worries if you can't share any data. We can still work this out.
  3. My best guess is that your VCF is missing the column headers. The error is complaining the fact that the VCF does not have a line that starts with #CHROM and therefore the columns variable is never set:

fuc/fuc/api/pyvcf.py

Lines 2422 to 2433 in 7b0fbfb

skiprows = 0
meta = []
for line in s.split('\n'):
if line.startswith('##'):
meta.append(line.strip())
skiprows += 1
elif line.startswith('#CHROM'):
columns = line.strip().split('\t')
skiprows += 1
else:
break
columns[0] = 'CHROM'

@Bo-UT
Copy link
Author

Bo-UT commented Aug 4, 2024

Hi @sbslee ,

Thank you!
I am running the latest version of fuc. Yes, my .vcf file missed the line starting with #CHROM. I reran ensembl-vep with the output option --vcf and now it works. Thanks for the great tool!!

I have one more question regarding maf-vcf2maf. I got an error

File "/Users/bzhao2/miniconda3/envs/single-cell/lib/python3.10/site-packages/fuc/api/pymaf.py", line 451, in from_vcf
    ncbi_build = re.search(r'assembly="(.*?)"', line).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

I guess my .vcf file is missing assembly=. Our data is from hamster, and the reference is in form of contig, not chromosome. Do you have suggestions on the conversion? I sent you the .vcf file. Thank you!

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

2 participants