From 5693494b13d629e3d7a79dab34ed4999e167432d Mon Sep 17 00:00:00 2001 From: AntonOresten Date: Thu, 10 Oct 2024 19:25:19 +0200 Subject: [PATCH] `addproperty` -> `addproperties` --- README.md | 6 +++--- src/ProteinChains.jl | 2 +- src/chain.jl | 14 +++++++------- src/properties.jl | 6 +++--- src/structure.jl | 4 ++-- test/runtests.jl | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6c5fc6b..3c6fbc1 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,16 @@ julia> propertynames(chain) (:id, :atoms, :sequence, :numbering) ``` -To store additional properties, `addproperty` can be used to attach persistent chain-level properties or indexable residue-level properties: +To store additional properties, `addproperties` can be used to attach persistent chain-level properties or indexable residue-level properties: ```julia julia> chain = structure["A"] 256-residue ProteinChain{Float64, @NamedTuple{}} (A) -julia> new_chain = addproperty(chain; taxid=PersistentProperty(83332)) +julia> new_chain = addproperties(chain; taxid=PersistentProperty(83332)) 256-residue ProteinChain{Float64, @NamedTuple{taxid::PersistentProperty{Int64}}} (A) -julia> new_chain = addproperty(new_chain; some_residue_property=IndexableProperty(rand(3,256))) # last dimension gets indexed +julia> new_chain = addproperties(new_chain; some_residue_property=IndexableProperty(rand(3,256))) # last dimension gets indexed 256-residue ProteinChain{Float64, @NamedTuple{taxid::PersistentProperty{Int64}, some_residue_property::IndexableProperty{Matrix{Float64}}}} (A) julia> new_chain[1:100].some_residue_property diff --git a/src/ProteinChains.jl b/src/ProteinChains.jl index 6da5c7d..49bb245 100644 --- a/src/ProteinChains.jl +++ b/src/ProteinChains.jl @@ -15,7 +15,7 @@ export Atom include("properties.jl") export PersistentProperty, IndexableProperty -export addproperty +export addproperties @compat public (AbstractProperty, NamedProperties) include("chain.jl") diff --git a/src/chain.jl b/src/chain.jl index 768995c..4aad811 100644 --- a/src/chain.jl +++ b/src/chain.jl @@ -2,7 +2,7 @@ ProteinChain{T<:Real,Ps<:NamedProperties} Represents a protein chain with a basic set of fields from which some other properties might be derived. -The [`addproperty`](@ref) function can be used to instantiate new chains with additional properties. +The [`addproperties`](@ref) function can be used to instantiate new chains with additional properties. ## Fields - `id::String`: Identifier for the protein chain. @@ -11,7 +11,7 @@ The [`addproperty`](@ref) function can be used to instantiate new chains with ad - `numbering::Vector{Int32}`: Residue numbering. - `properties::Ps`: Named properties associated with the chain. -See also [`addproperty`](@ref), [`PersistentProperty`](@ref), [`IndexableProperty`](@ref). +See also [`addproperties`](@ref), [`PersistentProperty`](@ref), [`IndexableProperty`](@ref). ``` """ struct ProteinChain{T<:Real,Ps<:NamedProperties} @@ -55,7 +55,7 @@ function Base.getindex(chain::ProteinChain, i::AbstractVector) end """ - addproperty(chain::ProteinChain; properties...) + addproperties(chain::ProteinChain; properties...) Creates a new `ProteinChain` instance with the added properties. Indexing behavior of property values can be specified by wrapping @@ -65,7 +65,7 @@ Values get wrapped by `PersistentProperty` by default. See also [`PersistentProperty`](@ref), [`IndexableProperty`](@ref) """ -function addproperty(chain::ProteinChain; properties...) +function addproperties(chain::ProteinChain; properties...) properties = map(p -> p isa AbstractProperty ? p : PersistentProperty(p), NamedTuple(properties)) return ProteinChain(chain.id, chain.atoms, chain.sequence, chain.numbering, merge(chain.properties, properties)) end @@ -133,12 +133,12 @@ end using AssigningSecondaryStructure: assign_secondary_structure """ - addproperty(chain::ProteinChain, names::Symbol...) - addproperty(chain::ProteinStructure, names::Symbol...) + addproperties(chain::ProteinChain, names::Symbol...) + addproperties(chain::ProteinStructure, names::Symbol...) Add predefined properties to a chain or chains of a structure. """ -addproperty(chain::ProteinChain, names::Symbol...) = addproperty(chain; NamedTuple{names}(calculate_property(chain, name) for name in names)...) +addproperties(chain::ProteinChain, names::Symbol...) = addproperties(chain; NamedTuple{names}(calculate_property(chain, name) for name in names)...) calculate_property(x, name::Symbol, args...) = calculate_property(x, Val(name), args...) diff --git a/src/properties.jl b/src/properties.jl index 5924b65..4bd73c8 100644 --- a/src/properties.jl +++ b/src/properties.jl @@ -8,7 +8,7 @@ Base.getindex(p::AbstractProperty) = p.value A property of arbitrary type that persists after residue indexing of a chain. ```jldoctest -julia> chain = addproperty(pdb"1ASS"A; x=PersistentProperty(1)); +julia> chain = addproperties(pdb"1ASS"A; x=PersistentProperty(1)); julia> chain.x == chain[1:10].x true @@ -31,7 +31,7 @@ residue indexing of the chain being propagated to the last dimension of the arra ```jldoctest julia> chain = pdb"1ASS"A; -julia> chain = addproperty(pdb"1ASS"A; y=IndexableProperty(rand(2,152))); +julia> chain = addproperties(pdb"1ASS"A; y=IndexableProperty(rand(2,152))); julia> chain.y == chain[1:10].y false @@ -48,4 +48,4 @@ Base.getindex(p::IndexableProperty, i::AbstractVector) = selectdim(p.value, ndim const NamedProperties{names} = NamedTuple{names,<:Tuple{Vararg{AbstractProperty}}} -function addproperty end \ No newline at end of file +function addproperties end \ No newline at end of file diff --git a/src/structure.jl b/src/structure.jl index 562a706..4fac8ec 100644 --- a/src/structure.jl +++ b/src/structure.jl @@ -55,5 +55,5 @@ function map_atoms!(f::Function, structure::ProteinStructure, args...) return structure end -addproperty(structure::ProteinStructure, names::Symbol...) = - ProteinStructure(structure.name, structure.atoms, addproperty.(structure.chains, names...)) \ No newline at end of file +addproperties(structure::ProteinStructure, names::Symbol...) = + ProteinStructure(structure.name, structure.atoms, addproperties.(structure.chains, names...)) \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 0d9ea41..d665600 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -39,7 +39,7 @@ using Test @testset "store" begin mktempdir() do dir filename = joinpath(dir, "store.h5") - structures = [addproperty(pdb"1EYE", :backbone), addproperty(pdb"3HFM", :backbone, :bond_lengths)] + structures = [addproperties(pdb"1EYE", :backbone), addproperties(pdb"3HFM", :backbone, :bond_lengths)] ProteinChains.serialize(filename, structures) structures_copy = ProteinChains.deserialize(filename) @test structures == structures_copy