diff --git a/src/fasta/reader.jl b/src/fasta/reader.jl index 4f36a40..a3c87b8 100644 --- a/src/fasta/reader.jl +++ b/src/fasta/reader.jl @@ -39,18 +39,18 @@ AGA ``` """ mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader - stream::S + const stream::S + const record::Record automa_state::Int # set to typemin(Int) if reader uses seek, then the linenum is # irreversibly lost. encoded_linenum::Int index::Union{Index, Nothing} - record::Record copy::Bool function Reader{T}(io::T, index::Union{Index, Nothing}, copy::Bool) where {T <: TranscodingStream} record = Record(Vector{UInt8}(undef, 2048), 0, 0, 0) - new{T}(io, 1, 1, index, record, copy) + new{T}(io, record, 1, 1, index, copy) end end diff --git a/src/fasta/record.jl b/src/fasta/record.jl index 5c46782..4f34c8e 100644 --- a/src/fasta/record.jl +++ b/src/fasta/record.jl @@ -32,7 +32,7 @@ true mutable struct Record # Data contains the description, then the sequence immediately after # without newlines, or the initial > symbol, and then any unused trailing bytes - data::Vector{UInt8} + const data::Vector{UInt8} # These lengths are in bytes, not chars # Identifier is data[1:identifier_len] diff --git a/src/fasta/writer.jl b/src/fasta/writer.jl index fa70984..76070ca 100644 --- a/src/fasta/writer.jl +++ b/src/fasta/writer.jl @@ -26,9 +26,9 @@ end ``` """ mutable struct Writer{S <: TranscodingStream} <: BioGenerics.IO.AbstractWriter - output::S + const output::S # maximum sequence width (no limit when width ≤ 0) - width::Int + const width::Int function Writer{S}(output::S, width::Int) where {S <: TranscodingStream} finalizer(new{S}(output, width)) do writer diff --git a/src/fastq/reader.jl b/src/fastq/reader.jl index 2c7a473..d7ac037 100644 --- a/src/fastq/reader.jl +++ b/src/fastq/reader.jl @@ -36,15 +36,15 @@ Int8[73, 74, 26, 60] ``` """ mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader - stream::S + const stream::S + const record::Record automa_state::Int linenum::Int - record::Record copy::Bool function Reader{T}(io::T, copy::Bool) where {T <: TranscodingStream} record = Record(Vector{UInt8}(undef, 2048), 0, 0, 0) - new{T}(io, 1, 1, record, copy) + new{T}(io, record, 1, 1, copy) end end diff --git a/src/fastq/record.jl b/src/fastq/record.jl index 1270279..bb0cecb 100644 --- a/src/fastq/record.jl +++ b/src/fastq/record.jl @@ -36,7 +36,7 @@ mutable struct Record # all rest, including newlines and the @ and + symbol, are not stored. # The second description after + must be identical to first description. # The quality is not corrected for offset, i.e. it is stored as it in the input file - data::Vector{UInt8} + const data::Vector{UInt8} # In bytes, not chars identifier_len::Int32 diff --git a/src/fastq/writer.jl b/src/fastq/writer.jl index d33255e..25a0a1a 100644 --- a/src/fastq/writer.jl +++ b/src/fastq/writer.jl @@ -27,8 +27,8 @@ end ``` """ mutable struct Writer{S <: TranscodingStream} <: BioGenerics.IO.AbstractWriter - output::S - quality_header::UInt8 # 0x00: No, 0x01: Yes, 0x02: Same as when read + const output::S + const quality_header::UInt8 # 0x00: No, 0x01: Yes, 0x02: Same as when read function Writer{S}(output::S, quality_header::UInt8) where {S <: TranscodingStream} finalizer(new{S}(output, quality_header)) do writer