BioJulia / GenomicAnnotations.jl

MIT License
16 stars 4 forks source link

Error when loading genebank file from NCBI #7

Closed TorkelE closed 3 years ago

TorkelE commented 3 years ago

Hello, I have downloaded a genebank file from NCBI (https://www.ncbi.nlm.nih.gov/nuccore/NC_022898.1?report=genbank then send to -> file -> GeneBank (full))

I then try to open the file using

gbff = readgbk("sequence.gb")

but get an error:

ERROR: ArgumentError: invalid index: nothing of type Nothing
Stacktrace:
 [1] to_index(i::Nothing)
   @ Base ~/julia-1.3.1/bin/../share/julia/base/indices.jl:273

 [2] to_index(A::Array{SubString{String},1}, i::Nothing)
   @ Base ~/julia-1.3.1/bin/../share/julia/base/indices.jl:250

 [3] to_indices
   @ Base ~/julia-1.3.1/bin/../share/julia/base/indices.jl:301 [inlined]

 [4] to_indices
   @ Base ~/julia-1.3.1/bin/../share/julia/base/indices.jl:298 [inlined]

 [5] getindex
   @ ~/julia-1.3.1/bin/../share/julia/base/abstractarray.jl:981 [inlined]

 [6] parseheader(header::String)
   @ GenomicAnnotations.GenBank ~/.julia/packages/GenomicAnnotations/gigUo/src/GenBank/reader.jl:58

 [7] parsechromosome!(stream::TranscodingStreams.TranscodingStream{TranscodingStreams.Noop,IOStream}, record::GenomicAnnotations.Record{Gene})
   @ GenomicAnnotations.GenBank ~/.julia/packages/GenomicAnnotations/gigUo/src/GenBank/reader.jl:227

 [8] tryread!
   @ GenomicAnnotations.GenBank ~/.julia/packages/GenomicAnnotations/gigUo/src/GenBank/reader.jl:49 [inlined]

 [9] iterate
   @ GenomicAnnotations.GenBank ~/.julia/packages/GenomicAnnotations/gigUo/src/GenBank/reader.jl:42 [inlined]

[10] _collect(cont::UnitRange{Int64}, itr::GenomicAnnotations.GenBank.Reader{TranscodingStreams.TranscodingStream{TranscodingStreams.Noop,IOStream}}, ::Base.HasEltype, isz::Base.SizeUnknown)
   @ Base ~/julia-1.3.1/bin/../share/julia/base/array.jl:572

[11] collect
   @ Base ~/julia-1.3.1/bin/../share/julia/base/array.jl:560 [inlined]

[12] readgbk(input::String)
   @ GenomicAnnotations ~/.julia/packages/GenomicAnnotations/gigUo/src/utils.jl:65

[13] top-level scope
   @ REPL[15]:1

It should get noted that if I download the GeneBank file instead (no "(full)"), then I can load it (but there's not much actual content in it).

kdyrhage commented 3 years ago

Seems like the recent API change introduced this. The problem was an empty line at the end, so until the new version has been registered you can just remove the last line of the file.

TorkelE commented 3 years ago

Just confirming that this worked, thanks.