From 6f03bef623cc52c7ce198c5b15e48a4d564b4715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Fri, 13 Mar 2020 20:40:41 +1100 Subject: [PATCH 1/4] Increment version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 18608d4..10f7cb4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "XAM" uuid = "d759349c-bcba-11e9-07c2-5b90f8f05f7c" authors = ["Kenta Sato ", "Ben J. Ward ", "Ciarán O'Mara "] -version = "0.1.0" +version = "0.1.1" [deps] Automa = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b" From 8d14563f9d77cb0996ce6ab7839dc29d932e238f Mon Sep 17 00:00:00 2001 From: Konrad Herbst Date: Thu, 2 Jan 2020 17:35:16 +0100 Subject: [PATCH 2/4] :bug: Fix SAM.alignlength(record::Record)::Int (#37) Fixes issue #37 by re-initializing `len` in `SAM.alignlength`. --- src/sam/record.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sam/record.jl b/src/sam/record.jl index 407fe2f..6d4b149 100644 --- a/src/sam/record.jl +++ b/src/sam/record.jl @@ -327,8 +327,8 @@ function alignlength(record::Record)::Int op = convert(BioAlignments.Operation, Char(c)) if BioAlignments.ismatchop(op) || BioAlignments.isdeleteop(op) ret += len - len = 0 end + len = 0 end end return ret From 6a33ac06a7a325de347950b8bb6a8f5beec782bb Mon Sep 17 00:00:00 2001 From: herbstk Date: Sun, 5 Jan 2020 22:18:36 +0530 Subject: [PATCH 3/4] :white_check_mark: Enhanced unit test for rightposition (#37) Added additional tests for SAM.Record and BAM.Record for `rightposition` (and implicitly `alignlength`). --- test/runtests.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index ffb2669..d76d99f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -151,6 +151,10 @@ end @test eof(reader) close(reader) + # rightposition (also implicitly alignlength) + records = collect(open(SAM.Reader, joinpath(samdir, "ce#5b.sam"))) + @test SAM.rightposition(records[6]) == rightposition(records[6]) == 83 + # iterator @test length(collect(open(SAM.Reader, joinpath(samdir, "ce#1.sam")))) == 1 @test length(collect(open(SAM.Reader, joinpath(samdir, "ce#2.sam")))) == 2 @@ -308,6 +312,10 @@ end @test record.tlen == new_record.tlen @test record.data == new_record.data + # rightposition (also implicitly alignlength) + records = collect(open(BAM.Reader, joinpath(bamdir, "ce#5b.bam"))) + @test BAM.rightposition(records[6]) == rightposition(records[6]) == 83 + # iterator @test length(collect(open(BAM.Reader, joinpath(bamdir, "ce#1.bam")))) == 1 @test length(collect(open(BAM.Reader, joinpath(bamdir, "ce#2.bam")))) == 2 From f272b410315c718bfbf76fecc82be37d07b91700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Fri, 13 Mar 2020 22:09:28 +1100 Subject: [PATCH 4/4] Flatten --- src/sam/record.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sam/record.jl b/src/sam/record.jl index 6d4b149..e627727 100644 --- a/src/sam/record.jl +++ b/src/sam/record.jl @@ -321,15 +321,15 @@ function alignlength(record::Record)::Int len = 0 # operation length for i in record.cigar c = record.data[i] - if c ∈ UInt8('0'):UInt8('9') + if in(c, UInt8('0'):UInt8('9')) len = len * 10 + (c - UInt8('0')) - else - op = convert(BioAlignments.Operation, Char(c)) - if BioAlignments.ismatchop(op) || BioAlignments.isdeleteop(op) - ret += len - end - len = 0 + continue end + op = convert(BioAlignments.Operation, Char(c)) + if BioAlignments.ismatchop(op) || BioAlignments.isdeleteop(op) #Note: reference consuming ops ('M', 'D', 'N', '=', 'X'). + ret += len + end + len = 0 end return ret end