/usr/include/BALL/NMR/empiricalHSShiftProcessor.h is in libball1.4-dev 1.4.3~beta1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | #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;
/** Shift assignment processor implementing the empirical hypersurface contribution.
\ingroup ShiftModulesNMR
*/
class BALL_EXPORT EmpiricalHSShiftProcessor
: public ShiftModule
{
public:
BALL_CREATE(EmpiricalHSShiftProcessor)
static const int VERBOSITY_LEVEL_CRITICAL;
static const int VERBOSITY_LEVEL_DEBUG;
/** @name Constant Definitions
*/
//@{
/// Option names
struct BALL_EXPORT Option
{
/** verbosity of the processor
*/
static const char* VERBOSITY;
};
/// Default values for options
struct BALL_EXPORT Default
{
static const int VERBOSITY;
};
//@}
/** @name Enums and Constants.
*/
//@{
/** A symbolic name for the empirical hypersurfaces contribution to the chemical shift.
@see ShiftModule::PROPERTY__SHIFT
*/
static const char* PROPERTY__EHS_SHIFT;
//@}
/** @name Constructors and Destructors.
*/
//@{
/** Default constructor.
*/
EmpiricalHSShiftProcessor();
/** Destructor.
*/
virtual ~EmpiricalHSShiftProcessor();
//@}
/** @name Accessors.
*/
//@{
/** Initialization method.
This method reads the parameter section <b>SSBondCorrection</b>, parses, and stores its content
in the vector \link ssbond_correction_ ssbond_correction_ \endlink.
The parameter section <b>SSBondCorrection</b> defines atom types of residues, which have a disulfid bond, and
the corresponding shift contribution.
In addition, this method reads the parameter section <b>EmpiricalShiftHyperSurfaces</b> and
parses its content.
The parameter section <b>EmpiricalShiftHyperSurfaces</b>
defines target atom types, associated hypersurface property pairs and the corresponding datafiles.
All target atom types are stored in a vector \link target_names_ target_names_ \endlink.
All properties relevant for an atom type are stored in a set. The sets are stored per target atom
in the vector \link target_property_names_ target_property_names_ \endlink
in the same order as in the vector \link target_names_ target_names\endlink.
The property pairs for each atom type are stored as pairs in vectors. These vectors are themselves
stored per atom type in a map \link property_pairs_ property_pairs_ \endlink.
The file names of the hypersurface data files of an atom type are stored in a map,
whose key is the pair of properties, to which the hypersurface data belong.
The maps themselfes are stored per target atom type in the vector
\link property_files_ property_files_\endlink the same order as the atom types in
the vector \link target_names_ target_names\endlink.
For each atom type's property combinations a hypersurface is created and stored in
the map \link hypersurfaces_ hypersurfaces_ \endlink key {\tt atom type} of maps with
key property pair. The hypersurfaces will be evaluated for each target atom
in \link finish () finish () \endlink.
The flag {\tt exclude_prolins}, denoting the consideration of prolins in the shift computations,
is read from this section too.
@see finish ()
*/
virtual void init();
//@}
/** @name Processor specific functions.
*/
//@{
/** Processor start method.
This method clears the \link targets_ \endlink list.
It fails if no parameters were assigned.
@return bool, <b>false</b> if <tt>parameters_ == 0</tt>
*/
virtual bool start();
/** operator ().
* This method collects all target atoms, whose atom type was specified in the section
{\tt EmpiricalShiftHyperSurfaces} of the {\tt ShiftX.ini} - file and stored in
\link target_names_ target_names_ \endlink,
and computes all target atoms properties, which were likewise specified
for each target atom type in the {\tt ShiftX.ini} - file and stored in
\link target_property_names_ target_property_names_ \endlink.
The atoms and their properties are stored in the list
\link targets_ targets_ \endlink .
@return Processor::CONTINUE
@param composite an arbitrary composite. All non-atom objects are ignored.
*/
virtual Processor::Result operator () (Composite& composite);
/** Finish method.
This method performs the chemical shift calculation for all
previously collected target atoms (\link targets_ targets_ \endlink)
iteratively by evaluating all
atom type relevant hypersurfaces (\link hypersurfaces_ hypersurfaces_ \endlink)
iteratively using the precomputed atoms properties (\link targets_ targets_\endlink).
For disulfid bonds, a special term as specified in section
{\tt SSBondCorrection} of the {\tt ShiftX.ini} - file is added.
According to the flag {\tt exclude_prolins_} (default false) (pecification in the {\tt ShiftX.ini} - file)
prolins my by excluded from shift computations.
If the processor found no target atoms or had no hypersurfaces,
the processor returns immediately.
The empirical hypersurface related chemical shift is stored for each target atom
using the named property \link PROPERTY__EF_SHIFT PROPERTY__EF_SHIFT \endlink and
added to the named property \link ShiftModule::PROPERTY__SHIFT ShiftModule::PROPERTY__SHIFT \endlink .
@return bool, <b>false</b> if <tt>invalid_ </tt>
*/
virtual bool finish();
//@}
/** @name Public Attributes
*/
//@{
/// options
Options options;
/** reset the options to default values
*/
void setDefaultOptions();
//@}
protected:
/*_ Neested class providing atom properties for the shift computations
* */
class BALL_EXPORT PropertiesForShift_
{
public:
/** Default constructor.
*/
PropertiesForShift_(int verbosity_ = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
/** A pointer to the atom, whose properties are computed and stored.
*/
Atom* current_atom;
/** Method to set the atom and to compute all atom's properites as specified in
* the given set {\tt properties}.
* The property values are stored either in the map {\tt properties_real_} with
* property type as key or in the map {\tt properties_string_} with property type
* as key. The values can be accessed via the \link operator [] operator [] \endlink
* given the property type.
* The angles are given in the range (-180, 180).
* Note: In case of property type CHI, numerical _and_ alphanumeric values are possible:
* x e(-180,180) or x e {"ALA", "GLY", "Unknown"}
* If a certain property value is not available, the property gets
* the predefined values FLOAT_VALUE_NA or STRING_VALUE_NA.
* This is needed, to access the default values of the hypersurfaces.
*
* The method fails if the atom does not belong to a residue.
* @return bool, <b>false</b> if <tt> !a->getResidue()</tt>
**/
bool computeProperties_(Atom* atom, std::set<String> properties);
/** Method to obtain a property's value.
* A std::pair<float, String> is returned, such that
* the first element is std::numeric_limits<float>::min()
* if it is a alphanumeric/discrete property value
* the second element is the string "invalid"
* if it is a numeric property value.
* NOTE: make sure, that all properties (except from CHI) are stored either
* in properties_real_ or in properties_string_
* otherwise the operator is not able to return the correct value!
* @return pair<float, String>
*/
std::pair<float, String> operator [] (const String& property_name);
/** Method to check the type of a property.
* @return bool, <b>false</b> if <tt> property is of type
* "PSI" || "PHI" || "HA2L" || "HA1L" || "HNL" || "OHL"|| "CHI" </tt>
*/
static bool isDiscrete(String property);
/** Method to check the type of a property.
* @return bool, <b>false</b> if <tt> property != "CHI" || "CHI2" </tt>
*/
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;
/** @name Enums and Constants
*/
//@{
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.
*
*/
ShiftHyperSurface_(String filename, String atomtype,
String firstproperty, String secondproperty,
int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
throw(Exception::FileNotFound);
/** Destructor.
*/
virtual ~ShiftHyperSurface_();
/** Method to evaluate the empirical hypersurface given the properties of an atom.
* In case of a SINGLE__?? property type, the property type string works as
* first accessor.
* If only one factor is out of bounds {/tt FLOAT_VALUE_NA} or {/tt STRING_VALUE_NA},
* we return the all-values average. (We tried to simulate the SHIFTX behaviour)
*
* If one of the property values is set to { /tt FLOAT_VALUE_IGNORE},
* zero is returned.
*/
float operator () (PropertiesForShift_& properties);
/** Method to check if the hypersurface is valid.
* @return bool, <b>false</b> if <tt> hypersurface is invalid.
*/
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);
/** Method to check if the hypersurface's look--up table
* has a column named "name".
* @return bool, <b>false</b> if <tt> the look-up table has no column "name".
*/
bool tableHasColumn_(const String& name) ;
/** Method to read the datafile of a shift hypersurface.
*
* We assume the datafile to have the following structure:
atomtype factorx factory
total_average
(row_average_1;row_average_2;...;row_average_n|N/A)
(col_averages_1;col_averages_2;...;col_averages_n|N/A)
(row_spacing|N/A)
(col_spacing|N/A)
(y_axis_1;...;y_axis_n|N/A)
x_axis_11;...;x_axis_1m
value_11;...;value_1m
...
x_axis_n1;...;x_axis_nm
value_n1;...;value_nm
where ( | ) denotes alternatives and "N/A" an empty entry.
*/
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);
/** Method to set the type of the hypersurface according to two input property types
* (see {\tt HYPERSURFACE__TYPE()} )
*/
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_();
/// The verbosity of this class as taken from the options
int verbosity_;
};// end of class
} // end of namespace
#endif // BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
|