Skip to content

Commit

Permalink
TST+BUG Fix CIGAR size calculation for insertions
Browse files Browse the repository at this point in the history
closes #109
  • Loading branch information
unode committed Jun 7, 2019
1 parent 384e4a2 commit 2652e5f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 1.0.0+
* Reintroduce zstd compression (after fixes upstream)
* Fix CIGAR interpretation (#109) occurring when I is present

Version 1.0.0 2019-04-24 by luispedro
* Fix multiple features usage (#63)
Expand Down
1 change: 1 addition & 0 deletions NGLess/Data/Sam.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ matchSize' includeSoft cigar
'M' -> n
'=' -> n
'X' -> n
'I' -> n
'S'
| includeSoft -> n
_ -> 0
Expand Down
6 changes: 6 additions & 0 deletions Tests-Src/Tests/Select.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ simulated:1:1:38:663#0 0 Ref1 1018 3 69M16S = 1018 0 TTCGAGAAGATGGGTATCGTGGGAAAT
complex = [here|
SRR070372.3 16 V 7198336 21 26M3D9M3D6M6D8M2D21M * 0 0 CCCTTATGCAGGTCTTAACACAATTCTTGTATGTTCCATCGTTCTCCAGAATGAATATCAATGATACCAA 014<<BBBBDDFFFDDDDFHHFFD?@??DBBBB5555::?=BBBBDDF@BBFHHHHHHHFFFFFD@@@@@ NM:i:14 MD:Z:26^TTT9^TTC6^TTTTTT8^AA21 AS:i:3 XS:i:0|]

refinsert = [here|
SRR6028238.2619770 417 X 1319005 0 5M1I40M54H = 2019245 700291 TTTTCCGCTGAATATGCCCAAAGTGCAACAACGACGACCGCCGCCA @DDDEDDDDBDDDEEECDDDDDCAACCCCBBDDDBBBBBB<@BBDB NM:i:1 MD:Z:45 MC:Z:51M50H AS:i:40|]

case_read_one_Sam_Line = readSamLine samLineFlat @?= Right samLine
case_encode = (BL.toStrict . BB.toLazyByteString . encodeSamLine $ samLine) @?= samLineFlat

Expand All @@ -48,7 +51,10 @@ case_match_identity_soft = fromRight (matchIdentity samLine) == 0.975 @? "Soft c
case_matchSize1 = fromRight (matchSize =<< readSamLine complex) @?= (26+ 9+ 6+ 8+ 21)
--26M3D9M3D6M6D8M2D21M
case_matchSize2 = fromRight (matchSize =<< readSamLine simple) @?= 69
case_matchSize3 = fromRight (matchSize =<< readSamLine refinsert) @?= 46

case_cigarOK = fixCigar "9M" 9 @?= Right "9M"
case_cigarH = fixCigar "4H5M" 9 @?= Right "4S5M"
case_cigarH2 = fixCigar "4H5M2H" 11 @?= Right "4S5M2S"
case_cigarH3 = fixCigar "5M1I40M54H" 46 @?= Right "5M1I40M54H"
case_cigarH4 = fixCigar "5M1I40M54H" 100 @?= Right "5M1I40M54S"
8 changes: 8 additions & 0 deletions tests/regression-cigar-filter/expected.result.sam
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@HD VN:1.3 SO:queryname
@SQ SN:JPJG01000058 LN:30739
@SQ SN:JPJG01000046 LN:31516
@SQ SN:JPJG01000064 LN:32447
@SQ SN:JPJG01000062 LN:34508
@SQ SN:JPJG01000019 LN:57080
CAU6DANXX170407:1:1305:7399:79647 321 JPJG01000058 21821 0 32S35M1I12M20S JPJG01000019 27967 0 CGCGCATGTCGCGCCAAAAAACGATTAAAATTTATTTCGCGTCTGCGGACGCGAAAGTCTGCGACGCTGGCGCCTGTTTTCTGCCCGCAAGGGCAGAAAA FFFFFF<FFBFFFBFFFFBFFFFFFFFFFFFFFFFFBFFFFF<FFFFFFFFFFFFFFFFFFFFFFFFFFFFBBFFFFFFBFFFFFFFFFFFFFFFBBBBB NM:i:1 MD:Z:47 MC:Z:101M AS:i:40
CAU6DANXX170407:1:1305:7399:79647 161 JPJG01000019 27967 60 101M JPJG01000062 32728 0 GGCATCGGCATCGCCGTGGAAAAGGGCTTCCAGGGCGGCGGTGACCGCTTCCGCGCGAGCGGTATCCCCTACAAGGCACTCGCCGTCATCGAAAAGGCGGA BBBBBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF<FFFFFFFFFFFFBFFFFFFBBBFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFF< NM:i:1 MD:Z:77G23 MC:Z:15S53M32S AS:i:96 XS:i:35
2 changes: 1 addition & 1 deletion tests/regression-cigar-filter/select_sort.ngl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mapped = select(mapped) using |mr|:

mapped = samtools_sort(mapped, by={name})

write(mapped, ofile='result.sam')
write(mapped, ofile='output.result.sam')

0 comments on commit 2652e5f

Please sign in to comment.