Class: HTS::Bcf::Record
- Inherits:
-
Object
- Object
- HTS::Bcf::Record
- Defined in:
- lib/hts/bcf/record.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
- #allele_count ⇒ Object
- #alleles ⇒ Object
- #alleles=(values) ⇒ Object
- #alt ⇒ Object
- #chrom ⇒ Object
- #clear_id ⇒ Object
-
#each_allele_raw ⇒ Object
Native migration replacement for the former pointer-yielding API.
- #each_filter_id(&block) ⇒ Object
- #endpos ⇒ Object
- #filter ⇒ Object
- #filter_id?(target_id) ⇒ Boolean
- #filter_ids ⇒ Object
- #format(key = nil) ⇒ Object
- #id ⇒ Object
- #id=(value) ⇒ Object
- #info(key = nil) ⇒ Object
-
#initialize(header, native_record = nil) ⇒ Record
constructor
A new instance of Record.
- #pos ⇒ Object
- #pos=(value) ⇒ Object
- #qual ⇒ Object
- #qual=(value) ⇒ Object
- #ref ⇒ Object
- #rid ⇒ Object
- #rid=(value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(header, native_record = nil) ⇒ Record
Returns a new instance of Record.
8 9 10 11 |
# File 'lib/hts/bcf/record.rb', line 8 def initialize(header, native_record = nil) @native = native_record || Native::BcfRecordHandle.create @header = header end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
6 7 8 |
# File 'lib/hts/bcf/record.rb', line 6 def header @header end |
Instance Method Details
#allele_count ⇒ Object
41 |
# File 'lib/hts/bcf/record.rb', line 41 def allele_count = alleles.length |
#alleles ⇒ Object
38 |
# File 'lib/hts/bcf/record.rb', line 38 def alleles = @native.alleles |
#alleles=(values) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/hts/bcf/record.rb', line 43 def alleles=(values) values = Array(values).map(&:to_s) raise ArgumentError, "at least one allele is required" if values.empty? @native.set_alleles(@header.__send__(:native_handle), values.join(",")) values end |
#alt ⇒ Object
40 |
# File 'lib/hts/bcf/record.rb', line 40 def alt = alleles.drop(1) |
#chrom ⇒ Object
19 |
# File 'lib/hts/bcf/record.rb', line 19 def chrom = @header.id2name(rid) |
#clear_id ⇒ Object
33 34 35 36 |
# File 'lib/hts/bcf/record.rb', line 33 def clear_id @native.set_id(@header.__send__(:native_handle), ".") nil end |
#each_allele_raw ⇒ Object
Native migration replacement for the former pointer-yielding API.
52 53 54 55 56 57 |
# File 'lib/hts/bcf/record.rb', line 52 def each_allele_raw return to_enum(__method__) unless block_given? alleles.each { |allele| yield allele, allele.bytesize } self end |
#each_filter_id(&block) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/hts/bcf/record.rb', line 74 def each_filter_id(&block) return to_enum(__method__) unless block_given? @native.filter_ids.each(&block) self end |
#endpos ⇒ Object
26 |
# File 'lib/hts/bcf/record.rb', line 26 def endpos = pos + @native.core_get(:rlen) |
#filter ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/hts/bcf/record.rb', line 65 def filter names = @native.filter_names(@header.__send__(:native_handle)) case names.length when 0 then "PASS" when 1 then names.first else names end end |
#filter_id?(target_id) ⇒ Boolean
82 |
# File 'lib/hts/bcf/record.rb', line 82 def filter_id?(target_id) = filter_ids.include?(Integer(target_id)) |
#filter_ids ⇒ Object
81 |
# File 'lib/hts/bcf/record.rb', line 81 def filter_ids = @native.filter_ids |
#format(key = nil) ⇒ Object
89 90 91 92 |
# File 'lib/hts/bcf/record.rb', line 89 def format(key = nil) accessor = (@format_accessor ||= Format.new(self)) key ? accessor.get(key) : accessor end |
#id ⇒ Object
27 |
# File 'lib/hts/bcf/record.rb', line 27 def id = @native.id |
#id=(value) ⇒ Object
29 30 31 |
# File 'lib/hts/bcf/record.rb', line 29 def id=(value) @native.set_id(@header.__send__(:native_handle), value) end |
#info(key = nil) ⇒ Object
84 85 86 87 |
# File 'lib/hts/bcf/record.rb', line 84 def info(key = nil) accessor = (@info_accessor ||= Info.new(self)) key ? accessor.get(key) : accessor end |
#pos ⇒ Object
20 |
# File 'lib/hts/bcf/record.rb', line 20 def pos = @native.core_get(:pos) |
#pos=(value) ⇒ Object
22 23 24 |
# File 'lib/hts/bcf/record.rb', line 22 def pos=(value) @native.core_set(:pos, value) end |
#qual ⇒ Object
59 |
# File 'lib/hts/bcf/record.rb', line 59 def qual = @native.core_get(:qual) |
#qual=(value) ⇒ Object
61 62 63 |
# File 'lib/hts/bcf/record.rb', line 61 def qual=(value) @native.core_set(:qual, value) end |
#ref ⇒ Object
39 |
# File 'lib/hts/bcf/record.rb', line 39 def ref = alleles.first |
#rid ⇒ Object
13 |
# File 'lib/hts/bcf/record.rb', line 13 def rid = @native.core_get(:rid) |
#rid=(value) ⇒ Object
15 16 17 |
# File 'lib/hts/bcf/record.rb', line 15 def rid=(value) @native.core_set(:rid, value) end |
#to_s ⇒ Object
94 |
# File 'lib/hts/bcf/record.rb', line 94 def to_s = @native.format_record(@header.__send__(:native_handle)) |