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

KeyError from pyfaidx can mean that the chromosome labels in the ref fasta and vcf don't match #23

Open
TeresaPegan opened this issue Jul 4, 2022 · 0 comments

Comments

@TeresaPegan
Copy link

Hi,
I got this error and I figured it out, but I thought I would post this here because it requires a close look at the scripts to figure out how to interpret the error. As a low-priority suggestion, it might be worth adding a more user-friendly error for this situation.

Here is the error I initially got:

Traceback (most recent call last):
  File "/Users/teresapegan/opt/miniconda3/envs/helmsman/lib/python3.6/site-packages/pyfaidx/__init__.py", line 997, in __getitem__
    return self.records[rname]
KeyError: '1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "helmsman/helmsman.py", line 413, in <module>
    main()
  File "helmsman/helmsman.py", line 329, in main
    data_in = util.processInput(args.mode, args, subtypes_dict)
  File "/Users/teresapegan/helmsman/util.py", line 283, in __init__
    self.data = self.process_vcf(args.input)
  File "/Users/teresapegan/helmsman/util.py", line 400, in process_vcf
    sequence = fasta_reader[row_chr]
  File "/Users/teresapegan/opt/miniconda3/envs/helmsman/lib/python3.6/site-packages/pyfaidx/__init__.py", line 999, in __getitem__
    raise KeyError("{0} not in {1}.".format(rname, self.filename))
KeyError: '1 not in MutSpect/Spalm_arbitrary_reference.fasta.'

It turns out this was simply because my VCF had a chromosome label of "1" and my reference fasta had a more complex chromosome label with species name in it. When I changed the reference fasta chromosome label, then helmsman worked.

Hope this is helpful,
-Teresa

@TeresaPegan TeresaPegan changed the title KeyError: '1' from pyfaidx can mean that the chromosome labels in the ref fasta and vcf don't match KeyError from pyfaidx can mean that the chromosome labels in the ref fasta and vcf don't match Jul 4, 2022
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

1 participant