module

D4

D4 format library for Crystal

D4 is a format designed to store quantitative data associated with genomic intervals. It provides efficient compression and fast random access for depth data and similar genomic quantitative information.

Usage

Reading D4 files

D4.open("data.d4") do |file|
  puts file.chromosomes.map(&.name)
  puts file.mean("chr1", 1000, 2000)
  file.each_interval("chr1", 1000, 2000) do |interval|
    puts "#{interval.left}-#{interval.right}: #{interval.value}"
  end
end

Writing D4 files

D4.create("output.d4", chromosomes: [D4::Chromosome.new("chr1", 1000_i64)],
  dictionary: D4::Dictionary.new(0_i32, 8_i32)) do |writer|
  writer.write_values("chr1", 0, [1_i32, 2_i32, 3_i32])
end

Constants

D4Error = Error

Compatibility name for callers of the former d4binding wrapper.

VERSION = {{ (`shards version /tmp/tmp.jPCGAG/src/src/d4`).chomp.stringify }}

Class methods

build_indexes(path : String | Path, *, track : String | Nil = nil, kinds : Array(IndexKind) = [IndexKind::SecondaryFrames, IndexKind::Sum], control : WriteControl = WriteControl.new) : Nil
Source
create(path : String | Path, *, chromosomes : Array(Chromosome), dictionary : Dictionary = Dictionary.new(0, 64), denominator : Float64 = 1.0, default_value : Int32 = 0, options : WriteOptions = WriteOptions.new, control : WriteControl = WriteControl.new) : Writer
Source
create(path : String | Path, *, chromosomes : Array(Chromosome), dictionary : Dictionary = Dictionary.new(0, 64), denominator : Float64 = 1.0, default_value : Int32 = 0, options : WriteOptions = WriteOptions.new, control : WriteControl = WriteControl.new, & : Writer -> T) : T forall T
Source
open(path : String | Path, *, track : String | Nil = nil, options : ReadOptions = ReadOptions.new)

Convenience method to open a D4 file for reading

Source
open(path : String | Path, *, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) forall T

Convenience method to open a D4 file with a block

Source
open(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new)
Source
open(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) forall T
Source
open(io : IO, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new)
Source
open(io : IO, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) : T forall T
Source

Nested types