-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CIGARs longer than 65535 operations
- Loading branch information
1 parent
33e5f1b
commit b62bd28
Showing
8 changed files
with
347 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
(ns cljam.io.bam.decoder-test | ||
"Tests for cljam.io.bam.decoder." | ||
(:require [clojure.test :refer [deftest is are testing]] | ||
[cljam.io.protocols] | ||
[cljam.io.bam.decoder :as decoder] | ||
[cljam.test-common :as test-common])) | ||
|
||
((deftest first-cigar-operation-clips-entire-read?-test | ||
(are [expected cigar l-seq] | ||
(= expected | ||
(#'decoder/first-cigar-operation-clips-entire-read? cigar l-seq)) | ||
true "34S" 34 | ||
true "1000000000S20N" 1000000000 | ||
false "10S20N" 11 | ||
false "10S" 11 | ||
false "10H20N" 10))) | ||
|
||
(deftest B-I-type-cigar-str->cigar-str-test | ||
(is (= "1M2I3D4N5S10H11P12=13X" | ||
(#'decoder/B-I-type-cigar-str->cigar-str | ||
"I,1,0,2,1,3,2,4,3,5,4,10,5,11,6,12,7,13,8")))) | ||
|
||
(deftest get-cigar-from-options-test | ||
(are [expected-cigar sample-option] | ||
(= expected-cigar (#'decoder/get-cigar-from-options sample-option)) | ||
"12S34N" | ||
'({:CG {:type "B", :value "I,12,4,34,3"}} | ||
{:Xa {:type "A", :value \p}} | ||
{:Xi {:type "i", :value -100}} | ||
{:Xf {:type "f", :value -1400.0}} | ||
{:Xz {:type "Z", :value "AATTGGCC"}} | ||
{:Xh {:type "H", :value (map unchecked-byte [0x1A 0xE3 0x01])}} | ||
{:Xc {:type "B", :value "c,-128,0,127"}} | ||
{:XC {:type "B", :value "C,0,127,255"}} | ||
{:Xs {:type "B", :value "s,-32768,0,32767"}} | ||
{:XS {:type "B", :value "S,0,32767,65535"}} | ||
{:Xi {:type "B", :value "i,-2147483648,0,2147483647"}} | ||
{:XI {:type "B", :value "I,0,2147483647,4294967295"}} | ||
{:Xf {:type "B", :value "f,-0.3,0.0,0.3"}}) | ||
|
||
"1M2I4D8N16S32H64P128=256X" | ||
'({:MD {:type "Z" :value "2G0C0"}} | ||
{:XT {:type "A", :value \R}} | ||
{:NM {:type "i", :value 44}} | ||
{:cg {:type "Z", :value "foo"}} | ||
{:CG {:type "B", :value "I,1,0,2,1,4,2,8,3,16,4,32,5,64,6,128,7,256,8"}}))) | ||
|
||
(deftest remove-cigar-from-options-test | ||
(are [expected-option sample-option] | ||
(= expected-option (#'decoder/remove-cigar-from-options sample-option)) | ||
'({:Xa {:type "A", :value \p}} | ||
{:Xi {:type "i", :value -100}} | ||
{:Xf {:type "f", :value -1400.0}} | ||
{:Xz {:type "Z", :value "AATTGGCC"}} | ||
{:Xh {:type "H", :value (map unchecked-byte [0x1A 0xE3 0x01])}} | ||
{:Xc {:type "B", :value "c,-128,0,127"}} | ||
{:XC {:type "B", :value "C,0,127,255"}} | ||
{:Xs {:type "B", :value "s,-32768,0,32767"}} | ||
{:XS {:type "B", :value "S,0,32767,65535"}} | ||
{:Xi {:type "B", :value "i,-2147483648,0,2147483647"}} | ||
{:XI {:type "B", :value "I,0,2147483647,4294967295"}} | ||
{:Xf {:type "B", :value "f,-0.3,0.0,0.3"}}) | ||
'({:CG {:type "B", :value "I,12,4,34,3"}} | ||
{:Xa {:type "A", :value \p}} | ||
{:Xi {:type "i", :value -100}} | ||
{:Xf {:type "f", :value -1400.0}} | ||
{:Xz {:type "Z", :value "AATTGGCC"}} | ||
{:Xh {:type "H", :value (map unchecked-byte [0x1A 0xE3 0x01])}} | ||
{:Xc {:type "B", :value "c,-128,0,127"}} | ||
{:XC {:type "B", :value "C,0,127,255"}} | ||
{:Xs {:type "B", :value "s,-32768,0,32767"}} | ||
{:XS {:type "B", :value "S,0,32767,65535"}} | ||
{:Xi {:type "B", :value "i,-2147483648,0,2147483647"}} | ||
{:XI {:type "B", :value "I,0,2147483647,4294967295"}} | ||
{:Xf {:type "B", :value "f,-0.3,0.0,0.3"}}) | ||
|
||
'({:MD {:type "Z" :value "2G0C0"}} | ||
{:XT {:type "A", :value \R}} | ||
{:NM {:type "i", :value 44}} | ||
{:cg {:type "B", :value "I,3,1"}}) | ||
'({:MD {:type "Z" :value "2G0C0"}} | ||
{:XT {:type "A", :value \R}} | ||
{:NM {:type "i", :value 44}} | ||
{:cg {:type "B", :value "I,3,1"}} | ||
{:CG {:type "B", :value "I,34,0"}}) | ||
|
||
'() | ||
'({:CG {:type "B", :value "I,34,7"}}))) | ||
|
||
(deftest two-arguments-decode-alignment-test | ||
(let [encoded-sam-byte-without-CG-tag | ||
[0 0 0 0 8 0 0 0 5 30 73 18 2 0 0 0 6 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 | ||
0 0 114 48 48 51 0 85 0 0 0 96 0 0 0 20 40 17 -1 -1 -1 -1 -1 -1 88 88 | ||
66 83 4 0 0 0 17 49 2 0 20 0 112 0] | ||
encoded-sam-byte-including-CG-tag | ||
[0 0 0 0 6 0 0 0 5 30 73 18 2 0 -93 0 19 0 0 0 0 0 0 0 36 0 0 0 39 0 0 | ||
0 114 48 48 49 0 52 1 0 0 3 1 0 0 -120 20 24 17 20 20 65 -127 40 64 | ||
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 67 71 66 73 | ||
10 0 0 0 8 0 0 0 0 0 0 0 4 0 0 0 1 0 0 0 4 0 0 0 0 0 0 0 1 0 0 0 2 | ||
0 0 0 3 0 0 0 0 0 0 0]] | ||
(testing "two-arguments-decode-alignment-test" | ||
(are [expected-aln byte] | ||
(= expected-aln | ||
(decoder/decode-alignment | ||
[{:name "ref", :len 0}] | ||
{:data (byte-array (map unchecked-byte byte))})) | ||
(test-common/to-sam-alignment | ||
{:qname "r003" :flag 0, :rname "ref", :pos 9, :end 14, :mapq 30, | ||
:cigar "5H6M", :rnext "*", :pnext 0, :tlen 0, :seq "AGCTAA", | ||
:qual "*" :options [{:XX {:type "B", :value "S,12561,2,20,112"}}]}) | ||
encoded-sam-byte-without-CG-tag | ||
|
||
(test-common/to-sam-alignment | ||
{:qname "r001", :flag 163, :rname "ref", :pos 7, :end 22, :mapq 30, | ||
:cigar "8M4I4M1D3M", :rnext "=", :pnext 37, :tlen 39, | ||
:seq "TTAGATAAAGAGGATACTG", :qual "*", :options ()}) | ||
encoded-sam-byte-including-CG-tag)) | ||
|
||
(testing "four-arguments-decode-alignment-test" | ||
(are [expected-aln byte start end] | ||
(= expected-aln | ||
(decoder/decode-alignment | ||
[{:name "ref", :len 0}] | ||
{:data (byte-array (map unchecked-byte byte))} start end)) | ||
(test-common/to-sam-alignment | ||
{:qname "r003", :flag 0, :rname "ref", :pos 9, :end 14, :mapq 30, | ||
:cigar "5H6M", :rnext "*", :pnext 0, :tlen 0, :seq "AGCTAA", :qual "*", | ||
:options [{:XX {:type "B", :value "S,12561,2,20,112"}}]}) | ||
encoded-sam-byte-without-CG-tag | ||
14 9 | ||
|
||
nil | ||
encoded-sam-byte-without-CG-tag | ||
14 8 | ||
|
||
nil | ||
encoded-sam-byte-without-CG-tag | ||
15 9 | ||
|
||
(test-common/to-sam-alignment | ||
{:qname "r001", :flag 163, :rname "ref", :pos 7, :end 22, :mapq 30, | ||
:cigar "8M4I4M1D3M", :rnext "=", :pnext 37, :tlen 39, | ||
:seq "TTAGATAAAGAGGATACTG", :qual "*", :options ()}) | ||
encoded-sam-byte-including-CG-tag | ||
22 7 | ||
|
||
nil | ||
encoded-sam-byte-including-CG-tag | ||
22 6 | ||
|
||
nil | ||
encoded-sam-byte-including-CG-tag | ||
23 7)))) |
Oops, something went wrong.