00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPSAXS_FORM_FACTOR_TABLE_H
00009 #define IMPSAXS_FORM_FACTOR_TABLE_H
00010
00011 #include "saxs_config.h"
00012
00013 #include <IMP/Particle.h>
00014 #include <IMP/base_types.h>
00015 #include <IMP/atom/Residue.h>
00016 #include <IMP/atom/Atom.h>
00017 #include <IMP/atom/element.h>
00018 #include <IMP/algebra/utility.h>
00019
00020 #include <iostream>
00021 #include <vector>
00022
00023 IMPSAXS_BEGIN_NAMESPACE
00024
00025
00026
00027
00028 class IMPSAXSEXPORT FormFactorTable {
00029 public:
00030
00031 FormFactorTable();
00032
00033
00034 FormFactorTable(const String& table_name, Float min_q, Float max_q,
00035 Float delta_q);
00036
00037
00038 enum FormFactorType { ALL_ATOMS, HEAVY_ATOMS };
00039
00040
00041 Float get_form_factor(Particle* p, FormFactorType ff_type=HEAVY_ATOMS) const;
00042
00043 Float get_vacuum_form_factor(Particle* p,
00044 FormFactorType ff_type=HEAVY_ATOMS) const;
00045 Float get_dummy_form_factor(Particle* p,
00046 FormFactorType ff_type=HEAVY_ATOMS) const;
00047 Float get_radius(Particle* p, FormFactorType ff_type=HEAVY_ATOMS) const;
00048
00049 Float get_water_form_factor() const { return zero_form_factors_[OH2]; }
00050 Float get_vacuum_water_form_factor() const {
00051 return vacuum_zero_form_factors_[OH2];
00052 }
00053 Float get_dummy_water_form_factor() const {
00054 return dummy_zero_form_factors_[OH2];
00055 }
00056
00057
00058 const Floats& get_form_factors(Particle* p,
00059 FormFactorType ff_type = HEAVY_ATOMS) const;
00060
00061
00062 void show(std::ostream &out=std::cout, std::string prefix="") const;
00063
00064
00065 static Float rho_;
00066
00067 private:
00068
00069
00070
00071
00072 enum FormFactorAtomType {
00073 H, C, N, O, S, P, He, Ne, Na, Mg, Ca, Fe, Zn, Se, Au, ALL_ATOM_SIZE = 15,
00074 CH=15, CH2=16, CH3=17, NH=18, NH2=19, NH3=20, OH=21, OH2=22, SH=23,
00075 HEAVY_ATOM_SIZE=24, UNK=25};
00076
00077
00078 static std::map<atom::Element, FormFactorAtomType> element_ff_type_map_;
00079
00080
00081 static Float zero_form_factors_[];
00082
00083 static Float vacuum_zero_form_factors_[];
00084
00085 static Float dummy_zero_form_factors_[];
00086
00087
00088 static IntKey form_factor_type_key_;
00089
00090
00091 class AtomFactorCoefficients {
00092 public:
00093 String atom_type_;
00094 Float a_[5];
00095 Float b_[5];
00096 Float c_;
00097 Float excl_vol_;
00098 };
00099
00100
00101 friend std::istream& operator>>(std::istream& s,
00102 AtomFactorCoefficients& atom_factor_coefficients);
00103
00104
00105 friend std::ostream& operator<<(std::ostream& s,
00106 const AtomFactorCoefficients& atom_factor_coefficients);
00107
00108 private:
00109 int read_form_factor_table(const String& table_name);
00110
00111 void init_element_form_factor_map();
00112
00113 void compute_form_factors_all_atoms();
00114
00115 void compute_form_factors_heavy_atoms();
00116
00117 FormFactorAtomType get_form_factor_atom_type(atom::Element e) const;
00118
00119 FormFactorAtomType get_form_factor_atom_type(Particle* p,
00120 FormFactorType ff_type) const;
00121
00122 FormFactorAtomType get_carbon_atom_type(const atom::AtomType& atom_type,
00123 const atom::ResidueType& residue_type) const;
00124
00125 FormFactorAtomType get_nitrogen_atom_type(const atom::AtomType& atom_type,
00126 const atom::ResidueType& residue_type) const;
00127
00128 FormFactorAtomType get_oxygen_atom_type(const atom::AtomType& atom_type,
00129 const atom::ResidueType& residue_type) const;
00130
00131 FormFactorAtomType get_sulfur_atom_type(const atom::AtomType& atom_type,
00132 const atom::ResidueType& residue_type) const;
00133
00134 private:
00135
00136 std::vector<AtomFactorCoefficients> form_factors_coefficients_;
00137
00138
00139 std::vector<Floats> form_factors_;
00140
00141
00142 Float min_q_, max_q_, delta_q_;
00143
00144 WarningContext warn_context_;
00145 };
00146
00147 IMPSAXSEXPORT FormFactorTable* default_form_factor_table();
00148
00149 IMPSAXS_END_NAMESPACE
00150
00151 #endif