Subtype from XAMReader and XAMWriter

develop
Ciarán O'Mara 1 year ago
parent 50039e749f
commit 8151d877e7

@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added BAM.Reader index support for BAI object ([#56](https://github.com/BioJulia/XAM.jl/pull/56/files))
### Changed
- Subtype from XAMReader and XAMWriter from common abstract types.
## [0.3.1]
### Changed

@ -1,9 +1,14 @@
module XAM
using BioGenerics
export
SAM,
BAM
abstract type XAMReader <: BioGenerics.IO.AbstractReader end
abstract type XAMWriter <: BioGenerics.IO.AbstractWriter end
"""
flag(record::Union{SAM.Record, BAM.Record})::UInt16

@ -6,7 +6,7 @@ module BAM
using BioGenerics
using GenomicFeatures
using XAM.SAM
import ..XAM: flag
import ..XAM: flag, XAMReader, XAMWriter
import BGZFStreams
import BioAlignments

@ -8,9 +8,9 @@ Create a data reader of the BAM file format.
# Arguments
* `input`: data source
* `index=nothing`: filepath to a random access index (currently *bai* is supported) or BAI object
* `index=nothing`: filepath to a random access index (currently *bai* is supported) or BAI object
"""
mutable struct Reader{T} <: BioGenerics.IO.AbstractReader
mutable struct Reader{T} <: XAMReader
stream::BGZFStreams.BGZFStream{T}
header::SAM.Header
start_offset::BGZFStreams.VirtualOffset
@ -124,7 +124,7 @@ init_bam_index(index::AbstractString) = BAI(index)
init_bam_index(index::BAI) = index
init_bam_index(index::Nothing) = nothing
init_bam_index(index) = error("unrecognizable index argument")
function _read!(reader::Reader, record)
unsafe_read(
reader.stream,

@ -10,7 +10,7 @@ Create a data writer of the BAM file format.
* `output`: data sink
* `header`: SAM header object
"""
mutable struct Writer <: BioGenerics.IO.AbstractWriter
mutable struct Writer <: XAMWriter
stream::BGZFStreams.BGZFStream
end

@ -1,7 +1,7 @@
# SAM Reader
# =========
mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader
mutable struct Reader{S <: TranscodingStream} <: XAMReader
state::State{S}
header::Header
end

@ -11,7 +11,7 @@ import BioGenerics.Exceptions: missingerror
import BioGenerics.Automa: State
import BioSequences
import TranscodingStreams: TranscodingStreams, TranscodingStream
import ..XAM: flag
import ..XAM: flag, XAMReader, XAMWriter
using Printf: @sprintf

@ -10,7 +10,7 @@ Create a data writer of the SAM file format.
* `output`: data sink
* `header=Header()`: SAM header object
"""
mutable struct Writer <: BioGenerics.IO.AbstractWriter
mutable struct Writer <: XAMWriter
stream::IO
function Writer(output::IO, header::Header=Header())

Loading…
Cancel
Save