Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Jul 31, 2024
1 parent 6b4bed7 commit dd18fe0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProtPlot"
uuid = "77b3afcc-388a-4e14-926d-b99c82d1a01f"
authors = ["Anton Oresten <anton.oresten42@gmail.com>"]
version = "0.4.4"
version = "0.4.5"

[deps]
AssigningSecondaryStructure = "8ed43e74-60fb-4e11-99b9-91deed37aef7"
Expand Down
22 changes: 12 additions & 10 deletions src/ProtPlot.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
module ProtPlot

export Ribbon, ribbon, ribbon!
export ribbon_scene

export Ramachandran, ramachandran, ramachandran!

export PDBEntry

using Makie
using ColorTypes

Expand All @@ -9,17 +16,12 @@ export Backboner, readpdb

import BioStructures

function PDBEntry(pdbid::AbstractString; format=BioStructures.PDBFormat, kwargs...)
chains = mktempdir() do temp_dir
path = BioStructures.downloadpdb(pdbid; dir=temp_dir, kwargs...)
Backboner.Protein.readchains(path, format)
end
return chains
end

export PDBEntry

include("Ribbon/Ribbon.jl")
include("ramachandran.jl")

PDBEntry(pdbid::AbstractString; format=BioStructures.PDBFormat, kwargs...) = mktempdir() do dir
path = BioStructures.downloadpdb(pdbid; dir, format, kwargs...)
Backboner.Protein.readchains(path, format)
end

end
5 changes: 1 addition & 4 deletions src/Ribbon/Ribbon.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export Ribbon, ribbon, ribbon!, ribbon_scene

using Makie

@recipe(Ribbon, chains) do scene
Attributes(
secondary_structures = nothing,
Expand Down Expand Up @@ -32,6 +28,7 @@ include("render.jl")
# TODO: observe chains and re-render when they change
function Makie.plot!(ribbon::Ribbon{<:Tuple{<:AbstractVector{<:AbstractArray{T,3}}}}) where T<:Real
chain_backbones = convert.(Array{T,3}, collect(ribbon[1][]))
filter!(c -> size(c, 3) > 1, chain_backbones)
isnothing(ribbon.secondary_structures[]) && (ribbon.secondary_structures[] = _assign_secondary_structure(chain_backbones))
isnothing(ribbon.colors[]) && (ribbon.colors[] = [range(0, 1, size(chain_backbone, 3)) for chain_backbone in chain_backbones])
render!(ribbon, chain_backbones)
Expand Down
4 changes: 2 additions & 2 deletions src/Ribbon/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end

function render_lines_between_subchains!(ribbon::Ribbon, chain_backbone_partitions::Vector{Array{T,3}}, color=:lightgray, linewidth=2) where T<:Real
for i in 1:length(chain_backbone_partitions)-1
startpoint, endpoint = @views chain_backbone_partitions[i][:, 2, end], chain_backbones_partitions[i+1][:, 2, 1]
startpoint, endpoint = @views chain_backbone_partitions[i][:, 2, end], chain_backbone_partitions[i+1][:, 2, 1]
n_segments = trunc(Int, norm(endpoint - startpoint) / 0.8)
xs, ys, zs = [range(startpoint[i], endpoint[i], 2*n_segments) for i in 1:3]
linesegments!(ribbon, xs, ys, zs; linewidth=linewidth, color=color, transparency=true)
Expand Down Expand Up @@ -48,4 +48,4 @@ function render!(ribbon::Ribbon, chain_backbones::Vector{Array{T,3}}) where T<:R
render_lines_between_subchains!(ribbon, chain_backbone_partitions)
end
return nothing
end
end
2 changes: 1 addition & 1 deletion src/Ribbon/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ function get_subchain_ranges(chain_backbone::Array{T,3}, cn_distance_tolerance=2
end
push!(ranges, start_i+1:chain_length)
return ranges
end
end
4 changes: 1 addition & 3 deletions src/ramachandran.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export Ramachandran, ramachandran, ramachandran!

@recipe(Ramachandran, phi_angles, psi_angles) do scene
Attributes(
color = :black,
Expand Down Expand Up @@ -33,4 +31,4 @@ function Makie.convert_arguments(::Type{<:Ramachandran}, chains::Vector{Backbone
return (phi_angles, psi_angles)
end

Makie.convert_arguments(T::Type{<:Ramachandran}, pdbfile::AbstractString) = Makie.convert_arguments(T, Backboner.Protein.readchains(pdbfile))
Makie.convert_arguments(T::Type{<:Ramachandran}, pdbfile::AbstractString) = Makie.convert_arguments(T, Backboner.Protein.readchains(pdbfile))

2 comments on commit dd18fe0

@AntonOresten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Fix error when trying to render empty protein chains.
  • Fix typo

@JuliaRegistrator
Copy link

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/112115

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:

git tag -a v0.4.5 -m "<description of version>" dd18fe073fb0ae6d8091d09aea135f608a4393fa
git push origin v0.4.5

Please sign in to comment.