Skip to content

Commit

Permalink
Merge pull request #56 from m3g/compatible_res_operations
Browse files Browse the repository at this point in the history
support operation on combatible ResidueContribution objects
  • Loading branch information
lmiq authored Dec 2, 2024
2 parents dd3aba6 + b90c838 commit 68892e3
Showing 1 changed file with 20 additions and 4 deletions.
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

0 comments on commit 68892e3

Please sign in to comment.