Skip to content

Commit

Permalink
Bump BioSequences/BioSymbols to v3/v5 (#66)
Browse files Browse the repository at this point in the history
* Bump BioSequences/BioSymbols to v3/v5

* Bump Julia version
  • Loading branch information
jakobnissen committed Feb 20, 2022
1 parent 5ba5165 commit 81638d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = [
"Sabrina J. Ward <sabrinajward@protonmail.com>",
"Jakob N. Nissen <jakobnybonissen@gmail.com>"
]
version = "1.2.0"
version = "1.3.0"

[deps]
Automa = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/fasta/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/fastq/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand All @@ -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

"""
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import BioSequences:
@dna_str,
@rna_str,
@aa_str,
LongDNASeq,
LongAminoAcidSeq,
LongDNA,
LongAA,
LongSequence,
AminoAcidAlphabet,
DNAAlphabet,
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 81638d6

Please sign in to comment.