Skip to content

Commit

Permalink
Fix encoding process for ‘B, S’ type option in alignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
matsutomo81 committed Sep 5, 2022
1 parent c7cd8c4 commit 95fdd56
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cljam/io/bam/encoder.clj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
(lsb/write-bytes writer (byte-array 1 (byte \S)))
(lsb/write-int writer (count array))
(doseq [v array]
(lsb/write-short writer (Short/parseShort v))))
(lsb/write-ushort writer (Integer/parseInt v))))
\i nil
\I nil
\f nil))))
Expand Down
Binary file added test-resources/bam/include-BS-type-option.bam
Binary file not shown.
3 changes: 3 additions & 0 deletions test-resources/sam/include-BS-type-option.sam
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@SQ SN:ref LN:45
q001 0 ref 10 60 16M * 0 0 AAAAGGGGTTTTCCCC * Xa:A:p Xi:i:-100 Xf:f:-1.4e3 Xz:Z:AATTGGCC
q006 0 ref 10 60 16M * 0 0 AAAAGGGGTTTTCCCC * XS:B:S,0,32767,32768,65535
8 changes: 6 additions & 2 deletions test/cljam/io/sam_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
opts-sam-file
seq-asterisk-sam-file
seq-asterisk-bam-file
include-BS-type-option-sam-file
include-BS-type-option-bam-file
opts-bam-file
test-sam-blocks
test-bai-file
Expand Down Expand Up @@ -298,7 +300,8 @@
(is (= (seq alignments)
(seq (sam/read-alignments bam-rdr)))))))))
test-sam-file
seq-asterisk-sam-file))
seq-asterisk-sam-file
include-BS-type-option-sam-file))

(deftest bam->sam-convert-test
(are [target-bam]
Expand All @@ -316,7 +319,8 @@
(is (= (seq alignments)
(seq (sam/read-alignments sam-rdr)))))))))
test-bam-file
seq-asterisk-bam-file))
seq-asterisk-bam-file
include-BS-type-option-bam-file))

(deftest sam-writer-test
(with-before-after {:before (prepare-cache!)
Expand Down
5 changes: 5 additions & 0 deletions test/cljam/test_common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
(def opts-sam-file "test-resources/sam/opts.sam")

(def seq-asterisk-sam-file "test-resources/sam/seq-asterisk.sam")

(def include-BS-type-option-sam-file "test-resources/sam/include-BS-type-option.sam")

;; ### BAM files

(def test-bam-file "test-resources/bam/test.bam")
Expand All @@ -148,6 +151,8 @@
(def normalize-after-bam-file "test-resources/bam/normalize_after.bam")
(def opts-bam-file "test-resources/bam/opts.bam")

(def include-BS-type-option-bam-file "test-resources/bam/include-BS-type-option.bam")

;; ### BAM index files

(def test-bai-file "test-resources/bam/test.sorted.bam.bai")
Expand Down

0 comments on commit 95fdd56

Please sign in to comment.