mirror of
https://github.com/MillironX/XAM.jl.git
synced 2024-11-23 02:09:55 +00:00
Subtype from XAMReader and XAMWriter
This commit is contained in:
parent
50039e749f
commit
8151d877e7
8 changed files with 17 additions and 8 deletions
|
@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
- Added BAM.Reader index support for BAI object ([#56](https://github.com/BioJulia/XAM.jl/pull/56/files))
|
- 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]
|
## [0.3.1]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
module XAM
|
module XAM
|
||||||
|
|
||||||
|
using BioGenerics
|
||||||
|
|
||||||
export
|
export
|
||||||
SAM,
|
SAM,
|
||||||
BAM
|
BAM
|
||||||
|
|
||||||
|
abstract type XAMReader <: BioGenerics.IO.AbstractReader end
|
||||||
|
abstract type XAMWriter <: BioGenerics.IO.AbstractWriter end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
flag(record::Union{SAM.Record, BAM.Record})::UInt16
|
flag(record::Union{SAM.Record, BAM.Record})::UInt16
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module BAM
|
||||||
using BioGenerics
|
using BioGenerics
|
||||||
using GenomicFeatures
|
using GenomicFeatures
|
||||||
using XAM.SAM
|
using XAM.SAM
|
||||||
import ..XAM: flag
|
import ..XAM: flag, XAMReader, XAMWriter
|
||||||
|
|
||||||
import BGZFStreams
|
import BGZFStreams
|
||||||
import BioAlignments
|
import BioAlignments
|
||||||
|
|
|
@ -8,9 +8,9 @@ Create a data reader of the BAM file format.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `input`: data source
|
* `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}
|
stream::BGZFStreams.BGZFStream{T}
|
||||||
header::SAM.Header
|
header::SAM.Header
|
||||||
start_offset::BGZFStreams.VirtualOffset
|
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::BAI) = index
|
||||||
init_bam_index(index::Nothing) = nothing
|
init_bam_index(index::Nothing) = nothing
|
||||||
init_bam_index(index) = error("unrecognizable index argument")
|
init_bam_index(index) = error("unrecognizable index argument")
|
||||||
|
|
||||||
function _read!(reader::Reader, record)
|
function _read!(reader::Reader, record)
|
||||||
unsafe_read(
|
unsafe_read(
|
||||||
reader.stream,
|
reader.stream,
|
||||||
|
|
|
@ -10,7 +10,7 @@ Create a data writer of the BAM file format.
|
||||||
* `output`: data sink
|
* `output`: data sink
|
||||||
* `header`: SAM header object
|
* `header`: SAM header object
|
||||||
"""
|
"""
|
||||||
mutable struct Writer <: BioGenerics.IO.AbstractWriter
|
mutable struct Writer <: XAMWriter
|
||||||
stream::BGZFStreams.BGZFStream
|
stream::BGZFStreams.BGZFStream
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# SAM Reader
|
# SAM Reader
|
||||||
# =========
|
# =========
|
||||||
|
|
||||||
mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader
|
mutable struct Reader{S <: TranscodingStream} <: XAMReader
|
||||||
state::State{S}
|
state::State{S}
|
||||||
header::Header
|
header::Header
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ import BioGenerics.Exceptions: missingerror
|
||||||
import BioGenerics.Automa: State
|
import BioGenerics.Automa: State
|
||||||
import BioSequences
|
import BioSequences
|
||||||
import TranscodingStreams: TranscodingStreams, TranscodingStream
|
import TranscodingStreams: TranscodingStreams, TranscodingStream
|
||||||
import ..XAM: flag
|
import ..XAM: flag, XAMReader, XAMWriter
|
||||||
|
|
||||||
using Printf: @sprintf
|
using Printf: @sprintf
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ Create a data writer of the SAM file format.
|
||||||
* `output`: data sink
|
* `output`: data sink
|
||||||
* `header=Header()`: SAM header object
|
* `header=Header()`: SAM header object
|
||||||
"""
|
"""
|
||||||
mutable struct Writer <: BioGenerics.IO.AbstractWriter
|
mutable struct Writer <: XAMWriter
|
||||||
stream::IO
|
stream::IO
|
||||||
|
|
||||||
function Writer(output::IO, header::Header=Header())
|
function Writer(output::IO, header::Header=Header())
|
||||||
|
|
Loading…
Reference in a new issue