1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-11-22 17:59:55 +00:00

Subtype from XAMReader and XAMWriter

This commit is contained in:
Ciarán O'Mara 2023-01-09 12:30:36 +11:00
parent 50039e749f
commit 8151d877e7
8 changed files with 17 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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())