Skip to content

Commit

Permalink
Fail restraint setup if invalid particles are given
Browse files Browse the repository at this point in the history
Rather than ignoring non-rigid invalid particles, or
passing rigid invalid particles on, throw an exception.
Closes salilab/pmi#262.
  • Loading branch information
benmwebb committed Nov 18, 2023
1 parent ac5844f commit f7e964c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/saxs/src/RigidBodiesProfileHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ RigidBodiesProfileHandler::RigidBodiesProfileHandler(
} else {
particles_.push_back(particles[i]);
}
} else {
IMP_THROW("SAXS::RigidBodiesProfileHandler: invalid particle provided "
"(only " << (ff_type == RESIDUES ? "Atom or Residue" : "Atom")
<< " particles are considered): " << particles[i],
IMP::TypeException);
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/saxs/test/test_saxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def test_saxs_residue_particle_restraint(self):
score = saxs_restraint.evaluate(False)
self.assertAlmostEqual(score, 1.0307, delta=0.01)

# Atomic restraint should fail given residue information
self.assertRaises(TypeError, IMP.saxs.Restraint, saxs_particles,
exp_profile, IMP.saxs.HEAVY_ATOMS)

def test_background_adjust(self):
"""Test Profile.background_adjust"""
exp_profile = IMP.saxs.Profile(self.get_input_file_name('lyzexp.dat'))
Expand Down

0 comments on commit f7e964c

Please sign in to comment.