Skip to content

Commit

Permalink
Add Bam::Header.parse() method
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Jul 19, 2023
1 parent 4556e3e commit 6652a6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hts/bam/header.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module HTS
class Bam < Hts
class Header
def self.parse(text)
self.new LibHTS.sam_hdr_parse(text.size, text)
end

def initialize(hts_file : Pointer(HTS::LibHTS::HtsFile))
@sam_hdr = LibHTS.sam_hdr_read(hts_file)
end
Expand Down
7 changes: 7 additions & 0 deletions test/hts/bam/header_test.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class BamHeaderTest < Minitest::Test
@bam ||= HTS::Bam.new(test_bam_path)
end

def test_parse
s = bam.header.to_s
b = HTS::Bam::Header.parse(s)
assert_instance_of HTS::Bam::Header, b
assert_equal s, b.to_s
end

def test_initialize
assert_instance_of HTS::Bam::Header, HTS::Bam::Header.new
end
Expand Down

0 comments on commit 6652a6c

Please sign in to comment.