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

Unable to index gzipped fasta file by name: KeyError: 'chrY does not exist in fasta file' #62

Open
jolo2486 opened this issue Mar 22, 2023 · 1 comment

Comments

@jolo2486
Copy link

jolo2486 commented Mar 22, 2023

I have loaded a few example gzipped fasta files, e.g. the following one:
hgdownload.cse.ucsc.edu/goldenPath/dm6/bigZips/dm6.fa.gz

I can load it, iterate and so on, and:

fasta = pyfastx.Fasta(./data/genomes/dm6.fa.gz)
fasta[0]
Out[49]: <Sequence> chr2L with length of 23513712

but

fasta['chr2L']
KeyError: 'chr2L does not exist in fasta file'

Also:

keys = fasta.keys()
keys[0]
Out[57]: 'chr2L'

but

fasta[keys[0]]
KeyError: 'chr2L does not exist in fasta file'

I sincerely hope that I have not misunderstood anything, I went by what was listed in the docs:

>>> # get sequence like dictionary
>>> s1 = fa['JZ822577.1']
>>> s1
<Sequence> JZ822577.1 with length of 333

I am in a conda environment, and installed pyfastx 0.9.1 using pip.

  • Ubuntu 22.04.2 LTS
  • conda 23.1.0
  • python 3.8.16
  • pyfastx 0.9.1
@lmdu
Copy link
Owner

lmdu commented Mar 26, 2023

Try the latest version 1.0.0. We have fixed this issue.

victorlin added a commit to nextstrain/augur that referenced this issue Nov 7, 2023
The motivation is that version 0.9.0 added support for Python 3.10 and
3.11¹, which we want to support for Augur.

However, 0.9.0 also introduced a bug that prevented access by sequence
ID. This was fixed in version 1.0.0.²

Looking at the rest of the changelog, I don't see any other breaking
changes through the current version (2.0.1), at least for Augur's use
case. Assuming this will hold true for other 2.x versions, allow both
major versions 1 and 2.

¹ https://github.com/lmdu/pyfastx/blob/ee7303d1402d5f83db1a6ec74b5140b912ae75bb/docs/changelog.rst
² lmdu/pyfastx#62
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