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

Compress::Gzip::Reader cannot open a file in BGZF format #14549

Open
kojix2 opened this issue May 1, 2024 · 0 comments · May be fixed by #14550
Open

Compress::Gzip::Reader cannot open a file in BGZF format #14549

kojix2 opened this issue May 1, 2024 · 0 comments · May be fixed by #14550

Comments

@kojix2
Copy link
Contributor

kojix2 commented May 1, 2024

The BGZF format is a GZip format used in the bioinformatics area and uses extra fields.
Crystal's standard library Compress::Gzip::Reader cannot open it.

Crystal Forum:
https://forum.crystal-lang.org/t/compress-reader-cannot-open-a-file-in-bgzf-format-is-this-a-bug/6262/2

Steps to Reproduce

  1. Install tabix:

    sudo apt install tabix
    dpkg -L tabix | grep bgzip
    # /usr/bin/bgzip
    # /usr/share/man/man1/bgzip.1.gz
    
  2. Compress a file with bgzip:

    bgzip -k your.txt
  3. Decompress and view the file:

    zcat your.txt.gz
  4. Read compressed file in Crystal:

    require "compress/gzip"
    
    string = File.open("your.txt.gz") do |file|
      Compress::Gzip::Reader.open(file) do |gzip|
        gzip.gets_to_end
      end
    end
Unhandled exception: deflate: invalid stored block lengths (Compress::Deflate::Error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants