sergio-santos-group / ProtoSyn.jl

A Julia-based framework for molecular modelling
https://sergio-santos-group.github.io/ProtoSyn.jl/stable/
GNU Affero General Public License v3.0
58 stars 7 forks source link

Error loading PDB with insertion codes #54

Open zznidar opened 1 year ago

zznidar commented 1 year ago

Sometimes, residues in PDB files are not numbered using numbers only, but contain a letter suffix (100A, 100B, 100C ... 100H, for example). These are called insertion codes and can often be seen some antibodies, such as PDB 1HZH.

However, when trying to load the mentioned PDB-file using pose = ProtoSyn.Peptides.load("1hzh.pdb"), an error is thrown:

ERROR: MethodError: no method matching getindex(::Nothing, ::String)
Stacktrace:
 [1] load(::Type{Float64}, io::IOStream, ::Type{Val{1}}; alternative_location::String, ignore_residues::Vector{String}, ignore_chains::Vector{String})
   @ ProtoSyn C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Core\Methods\io-read.jl:85
 [2] load(::Type{Float64}, filename::String, ::Type{Val{1}}; bonds_by_distance::Bool, alternative_location::String, infer_parenthood::Bool, ignore_residues::Vector{String}, ignore_chains::Vector{String})
   @ ProtoSyn C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Core\Methods\io.jl:222
 [3] load(::Type{Float64}, filename::String; bonds_by_distance::Bool, alternative_location::String, ignore_residues::Vector{String}, ignore_chains::Vector{String})
   @ ProtoSyn C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Core\Methods\io.jl:55
 [4] load(::Type{Float64}, filename::String; bonds_by_distance::Bool, alternative_location::String, include_residues::Vector{String}, ignore_residues::Vector{String}, ignore_chains::Vector{String}, sort_atoms_by_graph::Bool)
   @ ProtoSyn.Peptides C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Peptides\Methods\io.jl:49
 [5] #load#21
   @ C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Peptides\Methods\io.jl:169 [inlined]
 [6] load(filename::String)
   @ ProtoSyn.Peptides C:\Users\user\.julia\packages\ProtoSyn\Xt3a1\src\Peptides\Methods\io.jl:168
 [7] top-level scope
   @ c:\Users\user\Documents\user\myFile.jl:4

If I delete the residues with insertion codes, the file loads fine (but the deleted residues are missing then).

JosePereiraUA commented 1 year ago

ProtoSyl.jl uses a quite complex regex string to parse PDB files. I'd have to check against this example and update it. Unfortunately I'm currently away from a computer for a while. I'll take a look at this whenever I have a chance.