Skip to content

Commit

Permalink
Misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Oct 30, 2024
1 parent 775a485 commit 7d76d43
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
9 changes: 3 additions & 6 deletions src/store/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion src/store/store.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions src/store/utils.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d76d43

Please sign in to comment.