Loading...
Searching...
No Matches
empiricalHSShiftProcessor.h
Go to the documentation of this file.
#ifndef BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
#define BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
#ifndef BALL_MATHS_CUBICSPLINE2D_H
# include <BALL/MATHS/cubicSpline2D.h>
#endif
#ifndef BALL_MATHS_CUBICSPLINE1D_H
# include <BALL/MATHS/cubicSpline1D.h>
#endif
#ifndef BALL_FORMAT_GENERICMOLFILE_H
# include <BALL/FORMAT/genericMolFile.h>
#endif
#ifndef BALL_NMR_SHIFT_MODULE_H
# include<BALL/NMR/shiftModule.h>
#endif
#ifndef BALL_KERNEL_EXPRESSION_H
# include<BALL/KERNEL/expression.h>
#endif
#ifndef BALL_DATATYPE_OPTIONS_H
# include <BALL/DATATYPE/options.h>
#endif
#include <set>
#include <map>
namespace BALL
{
class Atom;
class BALL_EXPORT EmpiricalHSShiftProcessor
: public ShiftModule
{
public:
BALL_CREATE(EmpiricalHSShiftProcessor)
static const int VERBOSITY_LEVEL_CRITICAL;
static const int VERBOSITY_LEVEL_DEBUG;
struct BALL_EXPORT Option
{
static const char* VERBOSITY;
};
struct BALL_EXPORT Default
{
static const int VERBOSITY;
};
static const char* PROPERTY__EHS_SHIFT;
EmpiricalHSShiftProcessor();
virtual ~EmpiricalHSShiftProcessor();
virtual void init();
virtual bool start();
virtual Processor::Result operator () (Composite& composite);
virtual bool finish();
Options options;
void setDefaultOptions();
protected:
/*_ Neested class providing atom properties for the shift computations
* */
class BALL_EXPORT PropertiesForShift_
{
public:
PropertiesForShift_(int verbosity_ = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
Atom* current_atom;
bool computeProperties_(Atom* atom, std::set<String> properties);
std::pair<float, String> operator [] (const String& property_name);
static bool isDiscrete(String property);
static bool isMixed(String property);
protected:
// Storing the atoms properties
// ...as numerical value
std::map<String, float> properties_real_;
// ... as alphanumerical/discrete value
std::map<String, String> properties_string_;
protected:
float getChiAngle_(Residue* residue);
float getChi2Angle_(Residue* residue);
char getAminoAcid_(Residue* residue);
char getSecondaryStructure_(Residue* residue);
float getHA_HBondLen_(Residue* residue);
float getHA2_HBondLen_(Residue* residue);
float getHN_HBondLen_(Residue* residue);
float getO_HBondLen_(Residue* residue);
bool hasDisulfidBond_(Residue* residue);
bool hasHA_HBond_(Residue* residue);
bool hasHA2_HBond_(Residue* residue);
bool hasHN_HBond_(Residue* residue);
bool hasO_HBond_(Residue* residue);
private:
// verbosity of the classes methods
int verbosity_;
}; // end of nested class
/*_ Neested class handling the empirical hypersurfaces.
**/
class ShiftHyperSurface_
{
public:
typedef std::map<String, std::map<String, float> > tabletype;
enum HYPERSURFACE__TYPE{
REAL__REAL,
REAL__DISCRETE,
DISCRETE__REAL, // not used
DISCRETE__DISCRETE,
CHI__REAL, // not used
REAL__CHI,
CHI__DISCRETE,
DISCRETE__CHI,
CHI__CHI,
SINGLE__REAL,
SINGLE__DISCRETE,
SINGLE__CHI
};
/*_ Constructors and Destructors.
*/
ShiftHyperSurface_(int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
/*_ Detailed constructor.
* Creates a ShiftHyperSurface given the <b>filename<\b> of the data file,
* the atom type, and the two property types according to its deduced
* hypersurface types (see {\tt HYPERSURFACE__TYPE()}).
*
* If the data file cannot be found, no hypersurface is created.
*
* In the special case that the two properties have the same type, we create just one table entry in
* {\tt table_} or just one spline { \tt in s1d_ }.
*
* In case of hypersurfaces of type {\tt REAL__DISCRETE} the splines default values are set to the
* row-averages if given specified in the datafile.
*
* In case of hypersurfaces of type {\tt REAL__CHI, REAL__REAL } the splines default values are
* set to the splines averages.
*
* In all cases but look-up tables the bounds for the splines are set as specified in
* the datafile if specified.
*
* Note:
* The spline or value can be accessed
* by the {\tt operator () } given __not__ the property-value, but the property name.
*
* @throws BALL::Exception::FileNotFound
*/
ShiftHyperSurface_(String filename, String /* atomtype */,
String firstproperty, String secondproperty,
int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
virtual ~ShiftHyperSurface_();
float operator () (PropertiesForShift_& properties);
bool isvalid(){return !invalid_;}
// Returns the total average given in the input file.
float getTotalAverage() {return average_;}
private:
// Computes the average of the look-up table values.
float getTableAverage_();
// Computes the row average of the look-up table given a row name.
float getTableRowAverage_(const std::map<String, float>& row);
// Computes the column average of the look-up table given a column name.
float getTableColumnAverage_(const String& name);
bool tableHasColumn_(const String& name) ;
void parseDataFile_(BALL::File& file, String filename) ;
// Method to convert a vector of strings into a vector of floats {/tt output}.
void convertToReal_(const vector<String>& input, vector<float>& output);
void setType_(String firstproperty, String secondproperty);
// The type of the hypersurface.
int type_;
// The properties of the hypersurface.
String first_property_;
String second_property_;
// The hypersurface can be a 2D spline, 1D spline or a look-up table.
CubicSpline2D s2d_;
std::map <String, CubicSpline1D > s1d_;
// Note: access of the look--up table: first the discrete key x, second the numerical key y.
std::map <String, std::map<String, float> > table_;
// The averages of the hypersurface as read from the file.
// //TODO rename to row_defaults
std::map <String, float> row_averages_;
std::map <String, float> col_averages_;
// The spacing in x and y direction as read from the file.
float row_spacing_;
float col_spacing_;
// Flag to store whether the spline we created is valid.
bool invalid_;
// The average over the complete hypersurface as read from the file.
// Note: this average maybe weighted in non-obvious ways!
float average_;
// verbosity of the method
int verbosity_;
// The underlying data of the hypersurface as read from the file.
vector<String> y_axis_values_;
vector<vector<String> > x_axis_values_;
vector<vector<float> > sample_values_;
};
/*_ The target atoms collected by {\tt operator ()}.
*/
std::vector<PropertiesForShift_> targets_;
/*_ The target atom types stored as a vector of strings collected from the ini-file
* by {\tt init ()}.
*/
vector<String> target_names_;
/*_ The target properties used for determine the
* empirical hypersurface shifts. The properties are collected
* from the ini-file by {\tt init ()} and are stored per target atom
* in the same order as the target_names.
*/
vector< std::set<String> > target_property_names_;
/*_ The file names of the files storing the property-data-splines for computing the
* shift contributions are stored in a map, whose key is the pair of
* properties, to which the splines belong.
* The maps are stored per target atom type in the same order as the target_names.
* The files are specified in the section {\tt EmpiricalShiftHyperSurfaces}
* of the file {\tt ShiftX.ini} and are collected by {\tt init ()}.
*/
vector< std::map< std::pair<String, String>, String > > property_files_;
/*_ The property pairs for each atom type are stored in this map.
* The map is created in {\tt init ()}.
**/
std::map< String, vector< std::pair<String, String> > > property_pairs_;
/*_ The hypersurfaces are precomputed by {\tt init()}
* and then are stored per atom type in a map with key atom_type of
* maps with the property pair as key.
*/
std::map<String, std::map <std::pair<String, String>,EmpiricalHSShiftProcessor::ShiftHyperSurface_> > hypersurfaces_;
/*_ Option to exclude prolins from the shift computations.
Default is false.
*/
bool exclude_prolins_;
// Map containing possible correction terms for ssbonds.
std::map<String, float> ssbond_correction_;
private:
/*_ Some debugging functions printing parameter/effector/target information
* to the Log stream.
*/
void printParameters_();
void printTargets_();
/*_ A function to perform some ShiftX-y postprocessing:
add for all CA-atoms 0.2 times the EF-shift-value of the bound HA-atoms.
Due to some reason ShiftX does not perform this postprocessing
for the empirical Hypersurface contributions.
*/
void postprocessing_();
int verbosity_;
};// end of class
} // end of namespace
#endif // BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Atom
Definition atom.h:90
BALL::Composite
Definition composite.h:74
BALL::CubicSpline2D
Definition cubicSpline2D.h:18
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_
Definition empiricalHSShiftProcessor.h:196
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::hasHA_HBond_
bool hasHA_HBond_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::hasDisulfidBond_
bool hasDisulfidBond_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getSecondaryStructure_
char getSecondaryStructure_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getChi2Angle_
float getChi2Angle_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::current_atom
Atom * current_atom
Definition empiricalHSShiftProcessor.h:205
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getO_HBondLen_
float getO_HBondLen_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getAminoAcid_
char getAminoAcid_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::hasHA2_HBond_
bool hasHA2_HBond_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::isMixed
static bool isMixed(String property)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getHA2_HBondLen_
float getHA2_HBondLen_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::computeProperties_
bool computeProperties_(Atom *atom, std::set< String > properties)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::hasHN_HBond_
bool hasHN_HBond_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::isDiscrete
static bool isDiscrete(String property)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::hasO_HBond_
bool hasO_HBond_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::PropertiesForShift_
PropertiesForShift_(int verbosity_=EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getHN_HBondLen_
float getHN_HBondLen_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::properties_real_
std::map< String, float > properties_real_
Definition empiricalHSShiftProcessor.h:253
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::properties_string_
std::map< String, String > properties_string_
Definition empiricalHSShiftProcessor.h:255
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getHA_HBondLen_
float getHA_HBondLen_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::PropertiesForShift_::getChiAngle_
float getChiAngle_(Residue *residue)
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_
Definition empiricalHSShiftProcessor.h:283
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::isvalid
bool isvalid()
Definition empiricalHSShiftProcessor.h:357
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::tabletype
std::map< String, std::map< String, float > > tabletype
Definition empiricalHSShiftProcessor.h:285
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::~ShiftHyperSurface_
virtual ~ShiftHyperSurface_()
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::ShiftHyperSurface_
ShiftHyperSurface_(String filename, String, String firstproperty, String secondproperty, int verbosity=EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::getTotalAverage
float getTotalAverage()
Definition empiricalHSShiftProcessor.h:360
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::ShiftHyperSurface_
ShiftHyperSurface_(int verbosity=EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::HYPERSURFACE__TYPE
HYPERSURFACE__TYPE
Definition empiricalHSShiftProcessor.h:291
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::SINGLE__CHI
@ SINGLE__CHI
Definition empiricalHSShiftProcessor.h:303
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::REAL__CHI
@ REAL__CHI
Definition empiricalHSShiftProcessor.h:297
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::CHI__DISCRETE
@ CHI__DISCRETE
Definition empiricalHSShiftProcessor.h:298
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::DISCRETE__DISCRETE
@ DISCRETE__DISCRETE
Definition empiricalHSShiftProcessor.h:295
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::REAL__DISCRETE
@ REAL__DISCRETE
Definition empiricalHSShiftProcessor.h:293
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::DISCRETE__REAL
@ DISCRETE__REAL
Definition empiricalHSShiftProcessor.h:294
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::SINGLE__DISCRETE
@ SINGLE__DISCRETE
Definition empiricalHSShiftProcessor.h:302
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::DISCRETE__CHI
@ DISCRETE__CHI
Definition empiricalHSShiftProcessor.h:299
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::SINGLE__REAL
@ SINGLE__REAL
Definition empiricalHSShiftProcessor.h:301
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::CHI__REAL
@ CHI__REAL
Definition empiricalHSShiftProcessor.h:296
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::CHI__CHI
@ CHI__CHI
Definition empiricalHSShiftProcessor.h:300
BALL::EmpiricalHSShiftProcessor::ShiftHyperSurface_::REAL__REAL
@ REAL__REAL
Definition empiricalHSShiftProcessor.h:292
BALL::EmpiricalHSShiftProcessor::ssbond_correction_
std::map< String, float > ssbond_correction_
Definition empiricalHSShiftProcessor.h:492
BALL::EmpiricalHSShiftProcessor::options
Options options
options
Definition empiricalHSShiftProcessor.h:183
BALL::EmpiricalHSShiftProcessor::start
virtual bool start()
BALL::EmpiricalHSShiftProcessor::target_names_
vector< String > target_names_
Definition empiricalHSShiftProcessor.h:456
BALL::EmpiricalHSShiftProcessor::PROPERTY__EHS_SHIFT
static const char * PROPERTY__EHS_SHIFT
Definition empiricalHSShiftProcessor.h:78
BALL::EmpiricalHSShiftProcessor::exclude_prolins_
bool exclude_prolins_
Definition empiricalHSShiftProcessor.h:489
BALL::EmpiricalHSShiftProcessor::setDefaultOptions
void setDefaultOptions()
BALL::EmpiricalHSShiftProcessor::init
virtual void init()
BALL::EmpiricalHSShiftProcessor::finish
virtual bool finish()
BALL::EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL
static const int VERBOSITY_LEVEL_CRITICAL
Definition empiricalHSShiftProcessor.h:47
BALL::EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_DEBUG
static const int VERBOSITY_LEVEL_DEBUG
Definition empiricalHSShiftProcessor.h:48
BALL::EmpiricalHSShiftProcessor::~EmpiricalHSShiftProcessor
virtual ~EmpiricalHSShiftProcessor()
BALL::EmpiricalHSShiftProcessor::property_files_
vector< std::map< std::pair< String, String >, String > > property_files_
Definition empiricalHSShiftProcessor.h:472
BALL::EmpiricalHSShiftProcessor::targets_
std::vector< PropertiesForShift_ > targets_
Definition empiricalHSShiftProcessor.h:451
BALL::EmpiricalHSShiftProcessor::property_pairs_
std::map< String, vector< std::pair< String, String > > > property_pairs_
Definition empiricalHSShiftProcessor.h:477
BALL::EmpiricalHSShiftProcessor::hypersurfaces_
std::map< String, std::map< std::pair< String, String >, EmpiricalHSShiftProcessor::ShiftHyperSurface_ > > hypersurfaces_
Definition empiricalHSShiftProcessor.h:484
BALL::EmpiricalHSShiftProcessor::target_property_names_
vector< std::set< String > > target_property_names_
Definition empiricalHSShiftProcessor.h:463
BALL::EmpiricalHSShiftProcessor::EmpiricalHSShiftProcessor
EmpiricalHSShiftProcessor()
BALL::File
Definition file.h:136
BALL::Options
Definition options.h:48
BALL::Processor::Result
int Result
Definition processor.h:36
BALL::Residue
Definition residue.h:38
BALL::ShiftModule::ShiftModule
ShiftModule()
BALL::String
Definition string.h:57
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
cubicSpline1D.h
cubicSpline2D.h
expression.h
genericMolFile.h
BALL
Definition constants.h:13
options.h
shiftModule.h
BALL::EmpiricalHSShiftProcessor::Default
Default values for options.
Definition empiricalHSShiftProcessor.h:64
BALL::EmpiricalHSShiftProcessor::Default::VERBOSITY
static const int VERBOSITY
Definition empiricalHSShiftProcessor.h:65
BALL::EmpiricalHSShiftProcessor::Option
Option names.
Definition empiricalHSShiftProcessor.h:55
BALL::EmpiricalHSShiftProcessor::Option::VERBOSITY
static const char * VERBOSITY
Definition empiricalHSShiftProcessor.h:58