From 5da017052b32433ecbd41042600271e7e0c4a387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Sun, 23 Feb 2020 14:43:34 +1100 Subject: [PATCH] Add messages to assertions --- src/bam/overlap.jl | 4 +++- src/bam/writer.jl | 2 +- src/sam/flags.jl | 3 +-- src/sam/record.jl | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bam/overlap.jl b/src/bam/overlap.jl index e6212ed..fb28b1f 100644 --- a/src/bam/overlap.jl +++ b/src/bam/overlap.jl @@ -50,7 +50,9 @@ function Base.iterate(iter::OverlapIterator) if refindex === nothing throw(ArgumentError("sequence name $(iter.refname) is not found in the header")) end - @assert iter.reader.index !== nothing + + @assert iter.reader.index !== nothing "Reader index cannot be nothing." + chunks = Indexes.overlapchunks(iter.reader.index.index, refindex, iter.interval) if isempty(chunks) return nothing diff --git a/src/bam/writer.jl b/src/bam/writer.jl index 2460b3f..81bdf23 100644 --- a/src/bam/writer.jl +++ b/src/bam/writer.jl @@ -37,7 +37,7 @@ function Base.write(writer::Writer, record::Record) end function write_header(stream, header, refseqnames, refseqlens) - @assert length(refseqnames) == length(refseqlens) + @assert length(refseqnames) == length(refseqlens) "Lengths of refseq names and lengths must match." n = 0 # magic bytes diff --git a/src/sam/flags.jl b/src/sam/flags.jl index 7b476fa..ded0df1 100644 --- a/src/sam/flags.jl +++ b/src/sam/flags.jl @@ -16,7 +16,7 @@ for (name, bits, doc) in [ (:QCFAIL, UInt16(0x200), "QC failure" ), (:DUP, UInt16(0x400), "optical or PCR duplicate" ), (:SUPPLEMENTARY, UInt16(0x800), "supplementary alignment" ),] - @assert bits isa UInt16 + @assert bits isa UInt16 "The bits must be of type UInt16." sym = Symbol("FLAG_", name) docstring = """ $sym SAM/BAM flag: $doc @@ -27,4 +27,3 @@ for (name, bits, doc) in [ @doc $(docstring) const $(sym) = $(bits) end end - diff --git a/src/sam/record.jl b/src/sam/record.jl index b241687..ef8bb6d 100644 --- a/src/sam/record.jl +++ b/src/sam/record.jl @@ -494,7 +494,7 @@ function Base.getindex(record::Record, tag::AbstractString) end if typ == UInt8('A') - @assert lo == hi + @assert lo == hi "Values lo and hi must be equivalent." return Char(record.data[lo]) end if typ == UInt8('i')