00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPSAXS_SCORE_H
00009 #define IMPSAXS_SCORE_H
00010
00011 #include "saxs_config.h"
00012 #include "Distribution.h"
00013 #include "Profile.h"
00014
00015 #include <IMP/Model.h>
00016
00017 #include <iostream>
00018 #include <vector>
00019
00020 IMPSAXS_BEGIN_NAMESPACE
00021
00022 class Profile;
00023 class Restraint;
00024
00025
00026
00027
00028
00029
00030 class IMPSAXSEXPORT Score: public RefCounted {
00031 public:
00032
00033
00034
00035
00036 Score(const Profile& exp_profile);
00037
00038
00039 Float compute_chi_score(const Profile& model_profile,
00040 bool use_offset = false,
00041 const std::string fit_file_name = "") const {
00042 return sqrt(compute_chi_square_score(model_profile,
00043 use_offset, fit_file_name));
00044 }
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 Float fit_profile(Profile& partial_profile, float& c1, float& c2,
00055 bool fixed_c1 = false, bool fixed_c2 = false,
00056 bool use_offset = false,
00057 const std::string fit_file_name = "") const;
00058
00059
00060 Float fit_profile(Profile& partial_profile,
00061 bool use_offset = false,
00062 const std::string fit_file_name = "") const {
00063
00064 float c1, c2;
00065 return fit_profile(partial_profile, c1, c2, false, false,
00066 use_offset, fit_file_name);
00067 }
00068
00069
00070 Float compute_chi_square_score(const Profile& model_profile,
00071 bool use_offset = false,
00072 const std::string fit_file_name = "") const;
00073
00074
00075
00076 Float compute_scale_factor(const Profile& model_profile,
00077 Float offset = 0.0) const;
00078
00079 Float compute_offset(const Profile& model_profile) const;
00080
00081 private:
00082
00083 void resample(const Profile& model_profile, Profile& resampled_profile) const;
00084
00085
00086 Float compute_chi_square_score_internal(const Profile& model_profile,
00087 const std::string& fit_file_name,
00088 bool use_offset = false) const;
00089
00090
00091 Float compute_chi_square_score_internal(const Profile& model_profile,
00092 const Float c, const Float offset) const;
00093
00094
00095 void write_SAXS_fit_file(const std::string& file_name,
00096 const Profile& model_profile,
00097 const Float chi_square,
00098 const Float c=1, const Float offset=0) const;
00099
00100
00101
00102 void compute_profile_difference(const Profile& model_profile,
00103 const Float c, const Float offset,
00104 Floats& profile_diff) const;
00105
00106
00107 void compute_sinc_cos(Float pr_resolution, Float max_distance,
00108 const Profile& model_profile,
00109 std::vector<Floats>& output_values) const;
00110 IMP_REF_COUNTED_DESTRUCTOR(Score);
00111 friend class Restraint;
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 void compute_chi_derivative(const Profile& model_profile,
00125 const Particles& particles1,
00126 const Particles& particles2,
00127 std::vector<algebra::VectorD<3> >& derivatives,
00128 bool use_offset = false) const;
00129 void compute_chi_derivative(const Profile& model_profile,
00130 const Particles& particles,
00131 std::vector<algebra::VectorD<3> >& derivatives,
00132 bool use_offset = false) const {
00133 return compute_chi_derivative(model_profile, particles, particles,
00134 derivatives, use_offset);
00135 }
00136
00137 void compute_chi_real_derivative(const Profile& model_profile,
00138 const Particles& particles1,
00139 const Particles& particles2,
00140 std::vector<algebra::VectorD<3> >& derivatives,
00141 bool use_offset) const;
00142
00143
00144 const Profile exp_profile_;
00145 };
00146
00147 IMPSAXS_END_NAMESPACE
00148
00149 #endif