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

support operation on combatible ResidueContribution objects #56

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
24 changes: 20 additions & 4 deletions src/tools/residue_contributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,24 @@ function ResidueContributions(
end

function _check_identity_of_residues(rc1::ResidueContributions, rc2::ResidueContributions)
if rc1.xticks != rc2.xticks
throw(ArgumentError("The residues in the two ResidueContributions objects differ."))
end
if rc1.d != rc2.d
throw(ArgumentError("The distances in the two ResidueContributions objects differ."))
throw(ArgumentError("""\n
Cannot operate on these contributions: the distance vectors in the two ResidueContributions objects differ.

"""))
end
if length(rc1) != length(rc2)
throw(ArgumentError("""\n
Cannot operate on these contributions: the number of residues in the two ResidueContributions objects differ.

"""))
end
if rc1.xticks[2] != rc2.xticks[2]
@warn """\n
The residue tick labels in the two ResidueContributions objects differ.
The resulting tick labels will be from the first object.

""" _file=nothing _line=nothing
end
return nothing
end
Expand Down Expand Up @@ -663,6 +676,9 @@ end
@test_throws ArgumentError ResidueContributions(result, select(atoms, "protein and resname XXX"))
@test_throws ArgumentError ResidueContributions(result, SoluteGroup("ALA"))

# Sum contributions of different, but compatible, objects (throws a warning message):
@test sum(rc[1:10] + rc[11:20]).residue_contributions ≈ sum(rc[1:20]).residue_contributions

acidic_residues = select(atoms, "protein and acidic")
basic_residues = select(atoms, "protein and basic")
protein = AtomSelection(select(atoms, "protein"), nmols=1,
Expand Down
Loading