-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm Protein type, Chain -> ProteinChain
- Loading branch information
1 parent
be6cb39
commit 8b046f7
Showing
10 changed files
with
55 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,3 @@ | ||
export Protein | ||
@inline Base.getindex(protein::AbstractVector{ProteinChain}, id::AbstractString) = protein[findfirst(c -> c.id == id, protein)] | ||
|
||
""" | ||
Protein <: AbstractVector{Chain} | ||
A wrapper for a vector of chains. | ||
Chains can be accessed by index or by ID. | ||
""" | ||
struct Protein <: AbstractVector{Chain} | ||
chains::Vector{Chain} | ||
id_dict::Dict{AbstractString, Chain} | ||
|
||
function Protein(chains::Vector{Chain}) | ||
@assert length(unique([chain.id for chain in chains])) == length(chains) | ||
id_dict = Dict{AbstractString, Chain}(chain.id => chain for chain in chains) | ||
return new(chains, id_dict) | ||
end | ||
end | ||
|
||
@inline Base.:(==)(protein1::Protein, protein2::Protein) = protein1.chains == protein2.chains | ||
@inline Base.size(protein::Protein) = size(protein.chains) | ||
@inline Base.length(protein::Protein) = length(protein.chains) | ||
@inline Base.getindex(protein::Protein, i) = protein.chains[i] | ||
@inline Base.getindex(protein::Protein, id::AbstractString) = protein.id_dict[String(id)] | ||
|
||
Base.summary(protein::Protein) = "Protein with $(length(protein)) chain$(length(protein) == 1 ? "" : "s")" | ||
|
||
has_assigned_ss(protein::Protein) = all(has_assigned_ss, protein.chains) | ||
has_assigned_ss(protein::AbstractVector{ProteinChain}) = all(has_assigned_ss, protein) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8b046f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
Chain
type toProteinChain
Protein
type in favor of simply representing proteins asVector{ProteinChain}
, and overloading some functions likegetindex
, to allow for indexing with chain IDs.Further rewrite and restructuring of types soon, see #10.
8b046f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/97109
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: