Class: HTS::Faidx

Inherits:
Object
  • Object
show all
Defined in:
lib/hts/faidx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Faidx

Returns a new instance of Faidx.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hts/faidx.rb', line 14

def initialize(file_path)
  @file_path = File.expand_path(file_path)
  @fai = LibHTS.fai_load(file_path)

  # IO like API
  if block_given?
    begin
      yield self
    ensure
      close
    end
  end
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



8
9
10
# File 'lib/hts/faidx.rb', line 8

def file_path
  @file_path
end

Instance Method Details

#cgetObject

FIXME: naming and syntax



52
# File 'lib/hts/faidx.rb', line 52

def cget; end

#chrom_size(chrom) ⇒ Object Also known as: chrom_length

return the length of the requested chromosome.



39
40
41
42
43
44
45
46
47
48
# File 'lib/hts/faidx.rb', line 39

def chrom_size(chrom)
  unless chrom.is_a?(String) || chrom.is_a?(Symbol)
    # FIXME
    raise ArgumentError, "Expect chrom to be String or Symbol"
  end

  chrom = chrom.to_s
  result = LibHTS.faidx_seq_len(@fai, chrom)
  result == -1 ? nil : result
end

#closeObject



28
29
30
# File 'lib/hts/faidx.rb', line 28

def close
  LibHTS.fai_destroy(@fai)
end

#getObject

FIXME: naming and syntax



55
# File 'lib/hts/faidx.rb', line 55

def get; end

#sizeObject Also known as: length

the number of sequences in the index.



33
34
35
# File 'lib/hts/faidx.rb', line 33

def size
  LibHTS.faidx_nseq(@fai)
end