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_name) ⇒ Faidx

Returns a new instance of Faidx.



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

def initialize(file_name)
  @file_name = file_name
  @fai = LibHTS.fai_load(@file_name)

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

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



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

def file_name
  @file_name
end

Instance Method Details

#cgetObject

FIXME: naming and syntax



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

def cget; end

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

return the length of the requested chromosome.



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

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



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

def close
  LibHTS.fai_destroy(@fai)
end

#getObject

FIXME: naming and syntax



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

def get; end

#sizeObject Also known as: length

the number of sequences in the index.



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

def size
  LibHTS.faidx_nseq(@fai)
end