Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error that occurs when encoding a value greater than 32767 with ‘B, S’ data type in encoding alignment in encoding alignment. #264

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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