8 #ifndef IMPEM_RIGID_FITTING_H
9 #define IMPEM_RIGID_FITTING_H
19 #include <IMP/em/em_config.h>
24 #include <cereal/access.hpp>
25 #include <cereal/types/vector.hpp>
28 template<
class Archive>
void serialize(Archive &ar,
29 std::pair<IMP::algebra::Transformation3D, IMP::Float> &g) {
30 ar(g.first, g.second);
44 typedef std::pair<algebra::Transformation3D, Float> FittingSolution;
46 bool operator()(
const FittingSolution &s1,
47 const FittingSolution &s2)
const {
48 return s1.second < s2.second;
63 "The index requested ("
64 << i <<
") in get_transformation is out of range ("
65 << fs_.size() <<
")" << std::endl);
75 "The index requested ("
76 << i <<
") in get_transformation is out of range ("
77 << fs_.size() <<
")" << std::endl);
80 void set_score(
unsigned int i,
Float score) {
82 "The index requested ("
83 << i <<
") in get_transformation is out of range ("
84 << fs_.size() <<
")" << std::endl);
85 fs_[i].second = score;
90 void sort(
bool reverse =
false);
94 for (
unsigned int i = 0; i < fs_.size(); i++)
95 fs_[i].first = fs_[i].first * t;
99 for (
unsigned int i = 0; i < fs_.size(); i++)
100 all_ts.push_back(fs_[i].first);
103 void show(std::ostream &out = std::cout)
const {
104 for (std::vector<FittingSolution>::const_iterator it = fs_.begin();
105 it != fs_.end(); it++) {
106 out <<
"(" << it->first <<
" , " << it->second <<
")" << std::endl;
111 std::vector<FittingSolution> fs_;
114 friend class cereal::access;
116 template<
class Archive>
void serialize(Archive &ar) {
154 Int number_of_mc_steps = 10,
Int number_of_cg_steps = 100,
155 Float max_translation = 2.,
Float max_rotation = .3,
bool fast =
false);
188 Int number_of_optimization_runs = 5,
Int number_of_mc_steps = 10,
189 Int number_of_cg_steps = 100,
Float max_translation = 2.,
190 Float max_rotation = .3,
bool fast =
true) {
196 p, refiner, weight_key, dmap, rb_cen, display_log,
197 number_of_optimization_runs, number_of_mc_steps, number_of_cg_steps,
198 max_translation, max_rotation, fast);
225 Int number_of_mc_steps = 10,
Int number_of_cg_steps = 100,
226 Float max_translation = 2.,
Float max_rotation = .3);
250 Int max_voxels_translation = 2,
Int translation_step = 1,
251 Float max_angle_in_radians = 0.174,
Int number_of_rotations = 100);
272 IMPEMEXPORT FittingSolutions
275 bool fast_version =
false,
bool local_score =
false,
277 atom::Mass::get_mass_key());
293 transformations,
true);
306 FloatKey wei_key = atom::Mass::get_mass_key());
Simple conjugate gradients optimizer.
Calculate score based on fit to EM map.
Used to hold a set of related restraints.
algebra::Transformation3D get_transformation(unsigned int i) const
Get the score of the i'th solution.
Simple Monte Carlo optimizer.
Storage of a model, its restraints, constraints and particles.
A simple list of fitting solutions.
#define IMP_LOG_VERBOSE(expr)
algebra::Vector3D get_centroid(const XYZs &ps)
Get the centroid.
Class for handling density maps.
Class for handling density maps.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
functionality for defining rigid bodies
Float compute_fitting_score(const ParticlesTemp &ps, DensityMap *em_map, FloatKey wei_key=atom::Mass::get_mass_key())
Compute fitting scores for a given set of rigid transformations.
FittingSolutions compute_fitting_scores(DensityMap *em_map, core::RigidBody rb, Refiner *refiner, const algebra::Transformation3Ds &transformations)
Compute fitting scores for a given set of rigid transformations.
FittingSolutions local_rigid_fitting_around_point(Particle *p, Refiner *refiner, const FloatKey &weight_key, DensityMap *dmap, const algebra::Vector3D &anchor_centroid, OptimizerStates display_log, Int number_of_optimization_runs=5, Int number_of_mc_steps=10, Int number_of_cg_steps=100, Float max_translation=2., Float max_rotation=.3, bool fast=false)
Local rigid fitting of a rigid body around a center point.
virtual const ParticlesTemp get_refined(Particle *a) const =0
Refine the passed particle into a set of particles.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
FittingSolutions local_rigid_fitting(Particle *p, Refiner *refiner, const FloatKey &weight_key, DensityMap *dmap, OptimizerStates display_log, Int number_of_optimization_runs=5, Int number_of_mc_steps=10, Int number_of_cg_steps=100, Float max_translation=2., Float max_rotation=.3, bool fast=true)
Local rigid fitting of a rigid body.
double Float
Basic floating-point value (could be float, double...)
Abstract class to implement hierarchical methods.
void multiply(const algebra::Transformation3D &t)
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
int Int
Basic integer value.
FittingSolutions local_rigid_fitting_around_points(Particle *p, Refiner *refiner, const FloatKey &wei_key, DensityMap *dmap, const algebra::Vector3Ds &anchor_centroids, OptimizerStates display_log, Int number_of_optimization_runs=5, Int number_of_mc_steps=10, Int number_of_cg_steps=100, Float max_translation=2., Float max_rotation=.3)
Local rigid fitting of a rigid body around a set of center points.
FittingSolutions local_rigid_fitting_grid_search(const ParticlesTemp &ps, const FloatKey &wei_key, DensityMap *dmap, Int max_voxels_translation=2, Int translation_step=1, Float max_angle_in_radians=0.174, Int number_of_rotations=100)
Local grid search rigid fitting.
A decorator for a rigid body.
int get_number_of_solutions() const
Get the number of solutions in the set.
Float get_score(unsigned int i) const
Get the score of the i'th solution.