From 300158dbef8b23e122f258bf22a08a331efd6892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Fri, 17 Apr 2020 15:55:41 +1000 Subject: [PATCH] Record equivalency functions --- src/bam/record.jl | 13 +++++++++++++ src/sam/record.jl | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/bam/record.jl b/src/bam/record.jl index 13c5608..bf65078 100644 --- a/src/bam/record.jl +++ b/src/bam/record.jl @@ -45,6 +45,19 @@ function Base.convert(::Type{Record}, data::Vector{UInt8}) return record end +function Base.:(==)(a::Record, b::Record) + return a.block_size == b.block_size && + a.refid == b.refid && + a.pos == b.pos && + a.bin_mq_nl == b.bin_mq_nl && + a.flag_nc == b.flag_nc && + a.l_seq == b.l_seq && + a.next_refid == b.next_refid && + a.next_pos == b.next_pos && + a.tlen == b.tlen && + a.data[1:data_size(a)] == b.data[1:data_size(b)] +end + function Base.copy(record::Record) copy = Record() copy.block_size = record.block_size diff --git a/src/sam/record.jl b/src/sam/record.jl index a61e0df..f7f381c 100644 --- a/src/sam/record.jl +++ b/src/sam/record.jl @@ -74,6 +74,23 @@ function Base.convert(::Type{Record}, str::AbstractString) return Record(Vector{UInt8}(str)) end +function Base.:(==)(a::Record, b::Record) + return a.filled == b.filled && + a.qname == b.qname && + a.flag == b.flag && + a.rname == b.rname && + a.pos == b.pos && + a.mapq == b.mapq && + a.cigar == b.cigar && + a.rnext == b.rnext && + a.pnext == b.pnext && + a.tlen == b.tlen && + a.seq == b.seq && + a.qual == b.qual && + a.fields == b.fields && + a.data[a.filled] == b.data[b.filled] +end + function Base.show(io::IO, record::Record) print(io, summary(record), ':') if isfilled(record)