From 7d76d43a135e5f5bb4ed267c31e86c1501048e88 Mon Sep 17 00:00:00 2001 From: anton083 Date: Wed, 30 Oct 2024 02:07:41 +0100 Subject: [PATCH] Misc changes --- src/store/io.jl | 9 +++------ src/store/store.jl | 1 - src/store/utils.jl | 9 +++------ src/structure.jl | 6 ------ 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/store/io.jl b/src/store/io.jl index 258a921..9d125c9 100644 --- a/src/store/io.jl +++ b/src/store/io.jl @@ -100,15 +100,12 @@ function readproperty(group::HDF5.Group, ::Type{ProteinStructure{T}}, ::Val{:cha end function Base.write(group::HDF5.Group, structure::ProteinStructure{T}) where T - attributes = HDF5.attributes(group) - attributes["T"] = string(T) - attributes["n_residues"] = sum(length, structure) - attributes["n_chains"] = length(structure) - + HDF5.attributes(group)["T"] = string(T) + HDF5.attributes(group)["n_residues"] = sum(length, structure) + HDF5.attributes(group)["n_chains"] = length(structure) for fieldname in fieldnames(ProteinStructure) writeproperty(group, ProteinStructure{T}, Val(fieldname), getproperty(structure, fieldname)) end - return group end diff --git a/src/store/store.jl b/src/store/store.jl index 04c1632..fe40157 100644 --- a/src/store/store.jl +++ b/src/store/store.jl @@ -59,7 +59,6 @@ that can be lazily read from the file without loading the structure into memory These attributes are only written to the file when the structure is written, and are not preserved in memory after the structure has been read. -**Preset attributes:** - `T`: type of the coordinates in the structure. - `n_residues`: vector of number of residues per model in the structure. - `n_chains`: vector of number of chains per model in the structure. diff --git a/src/store/utils.jl b/src/store/utils.jl index b29ca9e..94cec9d 100644 --- a/src/store/utils.jl +++ b/src/store/utils.jl @@ -1,11 +1,8 @@ -struct InsertionCode - index::UInt16 - code::UInt8 -end +const InsertionCode = NamedTuple{(:index, :code), Tuple{UInt16, UInt8}} -encode_ins_codes(ins_codes::String) = filter(code -> code.code != 0x20, map(splat(InsertionCode), enumerate(codeunits(ins_codes)))) +encode_ins_codes(ins_codes::String) = filter(code -> code.code != 0x20, map(InsertionCode, enumerate(codeunits(ins_codes)))) -function decode_ins_codes(ins_codes, len::Integer) +function decode_ins_codes(ins_codes::Vector{InsertionCode}, len::Integer) data = fill(0x20, len) for code in ins_codes data[code.index] = code.code diff --git a/src/structure.jl b/src/structure.jl index 4ed2265..7d4edbb 100644 --- a/src/structure.jl +++ b/src/structure.jl @@ -6,12 +6,6 @@ - `atoms::Vector{Atom{T}}`: free atoms from the structure that were not part of any protein residue. - `chains::Vector{ProteinChain{T}}`: a collection of `ProteinChain`s. - `properties::NamedProperties`: arbitrary properties. - -## Examples - -```jldoctest -julia> structure = pdb"1ASS" -``` """ struct ProteinStructure{T} <: AbstractVector{ProteinChain{T}} name::String