Sha256: df203f381cfb4f0da492895c2e3bdcf65db51a86f621b9473815183b46cb8286

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require 'zlib'

module Bio::BGZF

  # Packs +str+ into a BGZF block using 
  # given compression +level+.
  def pack(str, level=Zlib::BEST_COMPRESSION)
    zs = Zlib::Deflate.new level, -15
    cdata = zs.deflate str, Zlib::FINISH
    zs.close

    crc32 = Zlib.crc32 cdata, 0
    isize = str.length

    bsize = cdata.length + 19 + XLEN

    array = [   ID1, 
                ID2, 
                 CM, 
                FLG, 
              MTIME, 
                XFL,
                 OS,
               XLEN,
                SI1,
                SI2,
               SLEN,
              bsize,
              cdata,
              crc32,
              isize
            ]

     array.pack('CCCCVCCvCCvva*VV')
  end
  module_function :pack
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-bgzf-0.1.0 lib/bio-bgzf/pack.rb