mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences
https://pypi.python.org/pypi/pyfaidx
Other
449 stars 75 forks source link

The default_seq argument is not supported with using BGZF compression. #140

Closed UnkindPartition closed 6 years ago

UnkindPartition commented 6 years ago

I tried to use faidx to create the chromosome sizes file as recommended here.

My command was

faidx hg38.fa.gz -i chromsizes -o hg38.chromsizes

In response I got an error:

Traceback (most recent call last):
  File "/mnt/fls01-home01/mbmhtrcb/miniconda3/bin/faidx", line 6, in <module>
    sys.exit(pyfaidx.cli.main())
  File "/mnt/fls01-home01/mbmhtrcb/miniconda3/lib/python3.6/site-packages/pyfaidx/cli.py", line 197, in main
    write_sequence(args)
  File "/mnt/fls01-home01/mbmhtrcb/miniconda3/lib/python3.6/site-packages/pyfaidx/cli.py", line 16, in write_sequence
    fasta = Fasta(args.fasta, default_seq=args.default_seq, key_function=eval(args.header_function), strict_bounds=not args.lazy, split_char=args.delimiter, filt_function=filt_function, read_long_names=args.long_names, rebuild=not args.no_rebuild)
  File "/mnt/fls01-home01/mbmhtrcb/miniconda3/lib/python3.6/site-packages/pyfaidx/__init__.py", line 962, in __init__
    rebuild=rebuild)
  File "/mnt/fls01-home01/mbmhtrcb/miniconda3/lib/python3.6/site-packages/pyfaidx/__init__.py", line 382, in __init__
    "The default_seq argument is not supported with using BGZF compression. Please decompress your FASTA file and try again."
pyfaidx.FetchError: The default_seq argument is not supported with using BGZF compression. Please decompress your FASTA file and try again.

The error is either confusing or wrong because I didn't specify anything similar to a "default_seq argument".

This is pyfaidx version 0.5.3 build py36_0.

mdshw5 commented 6 years ago

Looks like this file is bgzip compressed, and I'll add this as a supported use case for the faidx cli script. This was an oversight on my part it seems.

mdshw5 commented 6 years ago

I've just released a new version (0.5.4.1) that should fix this bug. I'm not sure how you installed pyfaidx, but you can grab the latest version right now using pip install --upgrade pyfaidx or if you installed from bioconda you can wait until my pull request is merged (https://github.com/bioconda/bioconda-recipes/pull/9482)

UnkindPartition commented 6 years ago

Thanks!

mdshw5 commented 6 years ago

Let me know if you have any further issues.