Skip to content

Commit daf3c50

Browse files
author
Ciarán O'Mara
committed
Flag tests
1 parent 564ecea commit daf3c50

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ end
3030
include("test_issues.jl")
3131
include("test_crosscheck.jl")
3232
include("test_convert.jl")
33+
include("test_flags.jl")
3334

3435
# Include doctests.
3536
DocMeta.setdocmeta!(XAM, :DocTestSetup, :(using XAM); recursive=true)

test/test_flags.jl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@testset "Flags" begin
2+
3+
flag_tests = [
4+
(XAM.ispaired, XAM.FLAG_PAIRED),
5+
(XAM.isproperpair, XAM.FLAG_PROPER_PAIR),
6+
(XAM.isunmapped, XAM.FLAG_UNMAPPED),
7+
(XAM.ismapped, ~XAM.FLAG_UNMAPPED),
8+
(XAM.isnextunmapped, XAM.FLAG_NEXT_UNMAPPED),
9+
(XAM.isnextmapped, ~XAM.FLAG_NEXT_UNMAPPED),
10+
(XAM.isreversecomplemented, XAM.FLAG_REVERSE),
11+
(XAM.isforwardstrand, ~XAM.FLAG_REVERSE),
12+
(XAM.ispositivestrand, ~XAM.FLAG_REVERSE),
13+
(XAM.isreversestrand, XAM.FLAG_REVERSE),
14+
(XAM.isnegativestrand, XAM.FLAG_REVERSE),
15+
(XAM.isnextreversecomplemented, XAM.FLAG_NEXT_REVERSE),
16+
(XAM.isfirstsegment, XAM.FLAG_FIRST_SEGMENT),
17+
(XAM.isread1, XAM.FLAG_FIRST_SEGMENT),
18+
(XAM.islastsegment, XAM.FLAG_LAST_SEGMENT),
19+
(XAM.isread2, XAM.FLAG_LAST_SEGMENT),
20+
(XAM.issecondaryalignment, XAM.FLAG_SECONDARY),
21+
(XAM.isqcfail, XAM.FLAG_QCFAIL),
22+
(XAM.isduplicate, XAM.FLAG_DUPLICATE),
23+
(XAM.issupplementaryalignment, XAM.FLAG_SUPPLEMENTARY),
24+
(XAM.isprimaryalignment, ~0x900),
25+
]
26+
27+
foreach(flag_tests) do (func, flag)
28+
# SAM Record
29+
io = IOBuffer()
30+
write(io, string(Int(flag)))
31+
bytes = take!(io)
32+
33+
sam_record = XAM.SAM.Record()
34+
sam_record.data = bytes
35+
sam_record.flags = sam_record.filled = 1:length(bytes)
36+
37+
@test flag == XAM.flags(sam_record)
38+
@test func(sam_record)
39+
40+
# BAM record
41+
bam_record = XAM.BAM.Record(sam_record)
42+
43+
@test typeof(bam_record) == XAM.BAM.Record
44+
@test flag == XAM.flags(bam_record)
45+
@test func(bam_record)
46+
end
47+
48+
end

0 commit comments

Comments
 (0)