Sha256: 17f708cb59671539da704f709e1a183cbdb411a69ffb39df124e8a8a891a178f

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

module Bio::BGZF
  
  class Reader
    include Bio::BGZF

    attr_reader :f

    def initialize(f)
      @f = f
      @cur_block = nil
    end

    def tell
      f.tell << 16
    end

    def read_block
      decompress_block(f)
    end

    def read_block_at(vo)
      block_offset = vo_block_offset(vo)
      data_offset = vo_data_offset(vo)
      f.seek(block_offset)
      block_data = decompress_block(f)
      if data_offset == 0
        return block_data
      else
        return block_data.slice(data_offset...block_data.size)
      end
    end

    def each_block
      if block_given?
        while b = read_block
          yield b
        end
      else
        enum_for(:each_block)
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bio-bgzf-0.1.1 lib/bio-bgzf/reader.rb
bio-bgzf-0.1.0 lib/bio-bgzf/reader.rb