MurrellGroup / ProtPlot.jl

Protein ribbon plots implemented in Julia using Makie
MIT License
13 stars 1 forks source link

Weighted residues #30

Closed AntonOresten closed 4 months ago

AntonOresten commented 4 months ago

Since the segments are cut off at the alpha-carbons, the spline and colors should reflect that.

These two residue pairs should be approximately half as long, cause they start/end at the same residue. image Helix example: image The sizes of these segments exceed the size of one residue.

The segment transitions should look more like the ones shown here: image Takes from https://en.wikipedia.org/wiki/Ribbon_diagram#/media/File:Tubby-1c8z-pymol.png

I tried to implement this in the spline function with "weights" but it doesn't seem to do anything.

old spline function:

function spline(
    points::AbstractMatrix{<:Real};
    N::Integer = 10,
    k::Integer = min(3, size(points, 2)-1),
    r::UnitRange{Int} = 1:size(points, 2),
)
    L = size(points, 2)
    spl = Dierckx.ParametricSpline(1:L, points; k)
    return Dierckx.evaluate(spl, LinRange(r.start, r.stop, N))
end

new spline function:

function spline(
    points::AbstractMatrix{<:Real};
    N::Integer = 10,
    k::Integer = min(3, size(points, 2)-1),
    r::UnitRange{Int} = 1:size(points, 2),
    w::AbstractVector{<:Real} = ones(size(points, 2)),
)
    w[r.start] = w[r.stop] = 2.0 # weight the start and stop residues of the segment range
    L = size(points, 2)
    spl = Dierckx.ParametricSpline(1:L, points; k, w)
    return Dierckx.evaluate(spl, range(r.start, r.stop, N))
end

The residue colors shouldn't be trusted until this is fixed.

AntonOresten commented 4 months ago

It turned out to be easier to fix this by adding a weights argument to expand_colors, which takes the residue colors and expands them to match the size of one of the surface dimensions. image image Getting added in v0.4.2