ian-small / Chloe.jl

5 stars 6 forks source link

LoadError: BoundsError: attempt to access 8640-element Vector{UInt64} at index #18

Open bm-silva opened 1 week ago

bm-silva commented 1 week ago

Hi! I encountered a BoundsError while running Chloe for chloroplast genome annotation. The issue appears to occur during the reverse_complement transformation, as called in Chloe.Annotator. Below is the error message:

ERROR: LoadError: BoundsError: attempt to access 8640-element Vector{UInt64} at index [0x0000000000000001:0x0400000000000000]
Stacktrace:
  [1] throw_boundserror(A::Vector{UInt64}, I::Tuple{UnitRange{UInt64}})
    @ Base ./essentials.jl:14
  [2] checkbounds
    @ ./abstractarray.jl:699 [inlined]
  [3] getindex
    @ ./array.jl:925 [inlined]
  [4] _copy_seqview(T::Type{BioSequences.LongSequence{BioSequences.DNAAlphabet{2}}}, s::BioSequences.LongSubSeq{BioSequences.DNAAlphabet{2}})
    @ BioSequences /opt/chloe/.julia/packages/BioSequences/vqe0o/src/longsequences/seqview.jl:138
  [5] LongSequence
    @ /opt/chloe/.julia/packages/BioSequences/vqe0o/src/longsequences/seqview.jl:133 [inlined]
  [6] copy
    @ /opt/chloe/.julia/packages/BioSequences/vqe0o/src/longsequences/seqview.jl:36 [inlined]
  [7] reverse
    @ /opt/chloe/.julia/packages/BioSequences/vqe0o/src/biosequence/transformations.jl:160 [inlined]
  [8] reverse_complement
    @ /opt/chloe/.julia/packages/BioSequences/vqe0o/src/biosequence/transformations.jl:197 [inlined]
  [9] flip!(target::Chloe.Annotator.FwdRev{Chloe.Annotator.CircularSequence}, result::Chloe.Annotator.ChloeAnnotation, fliprange::UnitRange{Int64})
    @ Chloe.Annotator /opt/chloe/src/restructure.jl:47
 [10] transform!(target::Chloe.Annotator.FwdRev{Chloe.Annotator.CircularSequence}, result::Chloe.Annotator.ChloeAnnotation, templates::Dict{String, Chloe.Annotator.FeatureTemplate})
    @ Chloe.Annotator /opt/chloe/src/restructure.jl:197
 [11] annotate_one(db::Chloe.Annotator.ReferenceDb, target_id::String, target::Chloe.Annotator.FwdRev{Chloe.Annotator.CircularSequence}, output::String, config::Chloe.Annotator.ChloeConfig)
    @ Chloe.Annotator /opt/chloe/src/annotate_genomes.jl:567
 [12] annotate
    @ /opt/chloe/src/annotate_genomes.jl:599 [inlined]
 [13] #143
    @ /opt/chloe/src/annotate_genomes.jl:621 [inlined]
 [14] open(f::Chloe.Annotator.var"#143#146"{Chloe.Annotator.ReferenceDb, Chloe.Annotator.ChloeConfig, Chloe.Annotator.var"#142#145"{String}, String, String}, args::String; kwargs::@Kwargs{})
    @ Base ./io.jl:410
 [15] open(f::Function, args::String)
    @ Base ./io.jl:407
 [16] maybe_gzread
    @ /opt/chloe/src/utilities.jl:80 [inlined]
 [17] annotate_batch(db::Chloe.Annotator.ReferenceDb, fa_files::Vector{String}, config::Chloe.Annotator.ChloeConfig, output::String, use_id::Bool)
    @ Chloe.Annotator /opt/chloe/src/annotate_genomes.jl:620
 [18] chloe(; reference_dir::String, fasta_files::Vector{String}, sensitivity::Float64, output::String, no_transform::Bool, sff::Bool, no_filter::Bool, use_id::Bool)
    @ Chloe.CmdLine /opt/chloe/src/chloe_cmd.jl:45
 [19] (::Chloe.CmdLine.var"#2#3"{Dict{Symbol, Any}})()
    @ Chloe.CmdLine /opt/chloe/src/chloe_cmd.jl:141
 [20] with_logstate(f::Chloe.CmdLine.var"#2#3"{Dict{Symbol, Any}}, logstate::Base.CoreLogging.LogState)
    @ Base.CoreLogging ./logging/logging.jl:522
 [21] with_logger(f::Function, logger::Base.CoreLogging.ConsoleLogger)
    @ Base.CoreLogging ./logging/logging.jl:632
 [22] chloe_main(args::Vector{String})
    @ Chloe.CmdLine /opt/chloe/src/chloe_cmd.jl:133
 [23] top-level scope
    @ /opt/chloe/chloe.jl:3
in expression starting at /opt/chloe/chloe.jl:1

I'm running Chloe.jl with the following cmd:

julia --project=/opt/chloe /opt/chloe/chloe.jl annotate -o results/chloe "$fasta_file"

And the software is running in a docker image, by the following Dockerfile:

FROM julia:bullseye

RUN apt-get update && apt-get install -y git

RUN git clone https://github.com/ian-small/chloe /opt/chloe
RUN git clone https://github.com/ian-small/chloe_references /opt/chloe_references

WORKDIR /opt/chloe

ENV JULIA_DEPOT_PATH="/opt/chloe/.julia"

RUN julia --project=. -e 'import Pkg; Pkg.instantiate()'

Before running it, I make sure that are only ACTG in the sequence file. Is there any workaround for this issue? Thank you for your assistance!

ian-small commented 1 week ago

I've added a fix that prevents Chloe defining overlapping inverted repeats, which I think is the cause of this issue. If it isn't fixed in the latest version of the code, let me know, and if possible, share the genome sequence that is causing the problem.

bm-silva commented 6 days ago

Thanks for your work on the fix! I tested the file on my local machine, and it ran successfully. Unfortunately, I can’t share the FASTA file since it’s part of a private, unpublished project.

If I encounter any further issues, I’ll be sure to report them. Thanks again for your effort on this!