BioJulia/BioStructures.jl

Strip whitespaces from atom/element names

Opened this issue · 1 comments

When looking at an atom record I discovered that the whitespaces do not get stripped from the atom/element names when they are parsed.

An example: Dict{String, AbstractAtom}(" CA " => Atom CA with serial ,.....

As you can see, CA is sorrounded by spaces, which is kind of inconvenient. I suggest changing the function parseatomname in pdb.jl to the following:

function parseatomname(line::String, line_n::Integer=1)
    try
            return strip(line[13:16])
    catch
            throw(PDBParseError("could not read atom name", line_n, line))
    end
end

And the same for parseelement.

atomname and similar functions strip the white space, and you can index into residues without the white space.

It does need to be kept though, since different spacings are used to indicate e.g. C-alpha vs calcium, and this should be preserved on writing out.