This is a test version of Biostars. For the public version, visit https://www.biostars.org.
KeyError: "no key 'chr11' in database <SequenceFileDB 'hg38.fa’>" in python

Hi

I am getting an error while executing the parse_hgvs_name function of the "pyhgvs" module currently known as "hgvs" found at https://github.com/counsyl/hgvs. "pygr" module is also used here and the error message is pasted below. Note that the genome object has keys that include '11'.

>>> chrom, offset, ref, alt = pyhgvs.parse_hgvs_name('NM_000352.3:c.215A>G', genome, get_transcript=get_transcript)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".local/lib/python3.3/site-packages/pyhgvs-0.9.4-py3.3.egg/pyhgvs/__init__.py", line 1365, in parse_hgvs_name
  File ".local/lib/python3.3/site-packages/pyhgvs-0.9.4-py3.3.egg/pyhgvs/__init__.py", line 665, in get_vcf_allele
  File ".local/lib/python3.3/site-packages/pyhgvs-0.9.4-py3.3.egg/pyhgvs/__init__.py", line 510, in get_genomic_sequence
  File "pygr-0.8.2-py2.6-linux-x86_64.egg/pygr/seqdb.py", line 322, in __getitem__
KeyError: "no key 'chr11' in database <SequenceFileDB 'hg38.fa'>"

Thank you for your help

software-error pyhgvs python

1 answer

I think that some genome only use the chromosome number and not the 'chrXxxx' format. The key that is missing is 'chr11' and not just '11', see if some headers contain it.

Thanks cyril-cros! It took me a while to rename the fasta headers in the genome file to chr[\d+|\D+] format but I did and now the function works.

Log in to answer this question.