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" diff --git a/src/sam/record.jl b/src/sam/record.jl index 407fe2f..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 - len = 0 - end + 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 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