From 81638d6acefbec49c81a27503722011412ee60db Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Sat, 19 Feb 2022 17:46:16 +0100 Subject: [PATCH] Bump BioSequences/BioSymbols to v3/v5 (#66) * Bump BioSequences/BioSymbols to v3/v5 * Bump Julia version --- Project.toml | 6 +++--- src/fasta/record.jl | 8 ++++---- src/fastq/record.jl | 6 +++--- test/runtests.jl | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index c7a9220..9a3cf0a 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,7 @@ authors = [ "Sabrina J. Ward ", "Jakob N. Nissen " ] -version = "1.2.0" +version = "1.3.0" [deps] Automa = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b" @@ -16,8 +16,8 @@ TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" [compat] Automa = "0.7, 0.8" BioGenerics = "0.1" -BioSequences = "2.0.2" -BioSymbols = "4" +BioSequences = "3" +BioSymbols = "5" TranscodingStreams = "0.9.5" julia = "1.6" # LTS diff --git a/src/fasta/record.jl b/src/fasta/record.jl index 19f149e..3c47ab4 100644 --- a/src/fasta/record.jl +++ b/src/fasta/record.jl @@ -243,7 +243,7 @@ If `part` argument is given, it returns the specified part of the sequence. function sequence(::Type{S}, record::Record, part::UnitRange{Int}=1:lastindex(record.sequence))::S where S <: BioSequences.LongSequence checkfilled(record) seqpart = record.sequence[part] - return S(record.data, first(seqpart), last(seqpart)) + return S(@view(record.data[seqpart])) end function sequence(::Type{String}, record::Record, part::UnitRange{Int}=1:lastindex(record.sequence))::String @@ -343,12 +343,12 @@ function predict_seqtype(seq::Vector{UInt8}, range) # the threshold (= 0.95) is somewhat arbitrary if (a + c + g + t + u + n) / alpha > 0.95 if t ≥ u - return BioSequences.LongDNASeq + return BioSequences.LongDNA{4} else - return BioSequences.LongRNASeq + return BioSequences.LongRNA{4} end else - return BioSequences.LongAminoAcidSeq + return BioSequences.LongAA end end diff --git a/src/fastq/record.jl b/src/fastq/record.jl index 435501a..1e60fe6 100644 --- a/src/fastq/record.jl +++ b/src/fastq/record.jl @@ -271,7 +271,7 @@ If `part` argument is given, it returns the specified part of the sequence. function sequence(::Type{S}, record::Record, part::UnitRange{Int}=1:lastindex(record.sequence))::S where S <: BioSequences.LongSequence checkfilled(record) seqpart = record.sequence[part] - return S(record.data, first(seqpart), last(seqpart)) + return S(@view(record.data[seqpart])) end """ @@ -295,8 +295,8 @@ Get the sequence of `record` as a DNA sequence. If you have a sequence already and want to fill it with the sequence data contained in a fastq record, you can use `Base.copyto!`. """ -function sequence(record::Record, part::UnitRange{Int}=1:lastindex(record.sequence))::BioSequences.LongDNASeq - return sequence(BioSequences.LongDNASeq, record, part) +function sequence(record::Record, part::UnitRange{Int}=1:lastindex(record.sequence))::BioSequences.LongDNA{4} + return sequence(BioSequences.LongDNA{4}, record, part) end """ diff --git a/test/runtests.jl b/test/runtests.jl index 012e030..baae492 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,8 +8,8 @@ import BioSequences: @dna_str, @rna_str, @aa_str, - LongDNASeq, - LongAminoAcidSeq, + LongDNA, + LongAA, LongSequence, AminoAcidAlphabet, DNAAlphabet, @@ -37,7 +37,7 @@ import BioSequences: @test FASTA.hassequence(record) @test FASTA.sequence(LongDNASeq, record) == dna"ACGT" @test collect(FASTA.sequence_iter(DNA, record)) == [DNA_A, DNA_C, DNA_G, DNA_T] - @test FASTA.sequence(LongDNASeq, record, 2:3) == LongDNASeq(collect(FASTA.sequence_iter(DNA, record, 2:3))) == dna"CG" + @test FASTA.sequence(record, 2:3) == LongDNA{4}(collect(FASTA.sequence_iter(DNA, record, 2:3))) == dna"CG" @test FASTA.sequence(String, record) == "ACGT" @test FASTA.sequence(String, record, 2:3) == "CG"