9 #ifndef IMPMULTIFIT_FFT_BASED_RIGID_FITTING_H
10 #define IMPMULTIFIT_FFT_BASED_RIGID_FITTING_H
13 #include <IMP/multifit/multifit_config.h>
16 #include <IMP/multifit/internal/FFTWGrid.h>
18 #include <IMP/multifit/internal/FFTWPlan.h>
22 #include <IMP/multifit/internal/fft_fitting_utils.h>
23 #include <boost/scoped_array.hpp>
25 IMPMULTIFIT_BEGIN_NAMESPACE
27 class IMPMULTIFITEXPORT FFTFittingOutput :
public base::Object {
29 FFTFittingOutput() : base::Object(
"FFTFittingOutput%1%") {}
32 { out << best_fits_.size() <<
" final fits; "
33 << best_trans_per_rot_.size()
34 <<
" best translations per rotation"; }, {});
40 class IMPMULTIFITEXPORT FFTFitting :
public base::Object {
47 algebra::Transformation3D cen_trans_;
48 atom::Hierarchy high_mol_;
50 unsigned int nx_,ny_,nz_;
52 unsigned int nx_half_,ny_half_,nz_half_;
54 double origx_,origy_,origz_;
55 internal::FFTWGrid<double> low_map_data_;
56 Pointer<em::DensityMap> low_map_;
57 Pointer<em::SampledDensityMap> sampled_map_;
58 internal::FFTWGrid<double> sampled_map_data_,fftw_r_grid_mol_;
60 internal::FFTWGrid<double> reversed_fftw_data_;
61 boost::scoped_array<double> kernel_filter_;
62 unsigned int kernel_filter_ext_;
63 boost::scoped_array<double> gauss_kernel_;
64 unsigned int gauss_kernel_ext_;
65 unsigned long gauss_kernel_nvox_;
66 boost::scoped_array<double> filtered_kernel_;
69 unsigned filtered_kernel_ext_;
71 double sampled_norm_, asmb_norm_;
74 unsigned long fftw_nvox_r2c_;
75 unsigned long fftw_nvox_c2r_;
76 internal::FFTWGrid<fftw_complex> fftw_grid_lo_,fftw_grid_hi_;
77 internal::FFTWPlan fftw_plan_forward_lo_,fftw_plan_forward_hi_;
78 internal::FFTWPlan fftw_plan_reverse_hi_;
82 atom::Hierarchy orig_mol_;
83 atom::Hierarchy orig_mol_copy_;
84 atom::Hierarchy copy_mol_;
86 core::RigidBody orig_rb_;
87 int num_angle_per_voxel_;
88 int num_fits_reported_;
93 double fftw_pad_factor_;
94 unsigned int fftw_zero_padding_extent_[3];
95 unsigned margin_ignored_in_conv_[3];
97 internal::RotScoresVec fits_hash_;
99 internal::FFTScores fft_scores_;
100 unsigned int inside_num_;
101 unsigned int inside_num_flipped_;
102 internal::FFTScores fft_scores_flipped_;
104 multifit::internal::EulerAnglesList rots_;
106 void prepare_probe(atom::Hierarchy mol2fit);
107 void prepare_lowres_map (em::DensityMap *dmap);
108 void prepare_kernels();
109 void copy_density_data(em::DensityMap *dmap,
double *data_array);
110 void get_unwrapped_index (
int wx,
int wy,
int wz,
111 int &ix,
int &iy,
int &iz);
112 void prepare_poslist_flipped (em::DensityMap *dmap);
113 void prepare_poslist(em::DensityMap *dmap);
114 void pad_resolution_map();
115 em::DensityMap* crop_margin(em::DensityMap *in_map);
117 void fftw_translational_search(
const multifit::internal::EulerAngles &rot,
121 const internal::RotScoresVec &rot_scores,
122 bool cluster_fits,
double max_translation,
123 double max_clustering_trans,
124 double max_clustering_rotation);
126 FFTFitting() : base::Object(
"FFTFitting%1%") {}
144 FFTFittingOutput *do_global_fitting(em::DensityMap *dmap,
145 double density_threshold,
146 atom::Hierarchy mol2fit,
147 double angle_sampling_interval_rad,
148 int num_fits_to_report,
149 double max_clustering_translation,
150 double max_clustering_angle,
151 bool cluster_fits=
true,
152 int num_angle_per_voxel=1,
153 const std::string &angles_filename=
"");
173 FFTFittingOutput *do_local_fitting(em::DensityMap *dmap,
174 double density_threshold,
175 atom::Hierarchy mol2fit,
176 double angle_sampling_interval_rad,
177 double max_angle_sampling_rad,
178 double max_translation,
179 int num_fits_to_report,
181 int num_angle_per_voxel,
182 double max_clustering_translation,
183 double max_clustering_rotation,
184 const std::string &angles_filename=
"");
195 atom::Hierarchy mol2fit,
196 em::DensityMap *dmap,
197 double density_threshold,
198 double angle_sampling_interval_rad);
200 IMPMULTIFIT_END_NAMESPACE