Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better support for non-protein residues in ResidueContribution plots #53

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ext/Plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,23 @@ function Plots.contourf(
tick_range = 1:step:length(rc.xticks[1])
tick_marks = rc.xticks[1][tick_range]
tick_labels = rc.xticks[2][tick_range]
tick_resnums = rc.resnums[tick_range]
warned = false
xticks = if oneletter
for i in eachindex(tick_labels)
resnum = "$(rc.resnums[i])"
resnum = "$(tick_resnums[i])"
# The following will allow custom residue names to be identified
# in the tick label string, by removing the residue number
residue_name = string(strip(tick_labels[i][1:(first(findlast(resnum, tick_labels[i]))-1)]))
tick_labels[i] = PDBTools.oneletter(residue_name) * resnum
one_letter_code = PDBTools.oneletter(residue_name)
if one_letter_code == "X"
if !warned
@warn "One-letter code for residue(s) not found. Using full residue name." _file=nothing _line=nothing
warned = true
end
one_letter_code = residue_name
end
tick_labels[i] = one_letter_code * resnum
end
(tick_marks, tick_labels)
else
Expand Down
7 changes: 6 additions & 1 deletion src/tools/residue_contributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,12 @@
end
print(io, " ")
for i in 1:rstride*8:length(rc.xticks[1])
tick = "$(PDBTools.oneletter(rc.xticks[2][i][1:3]))$(rc.resnums[i])"
_tick = rc.xticks[2][i]
_resname = PDBTools.oneletter(_tick[1:min(lastindex(_tick),3)])
if _resname == "X"
_resname = _tick[1:1]

Check warning on line 431 in src/tools/residue_contributions.jl

View check run for this annotation

Codecov / codecov/patch

src/tools/residue_contributions.jl#L431

Added line #L431 was not covered by tests
end
tick = "$_resname$(rc.resnums[i])"
tick *= repeat(" ", 8 - length(tick))
print(io, tick)
end
Expand Down
Loading
Loading