BALL  1.5.0
scoringFunction.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_SCORING_COMMON_SCORINGFUNCTION_H
6 #define BALL_SCORING_COMMON_SCORINGFUNCTION_H
7 
8 #include <set>
9 
10 #include <BALL/KERNEL/system.h>
11 #include <BALL/DATATYPE/options.h>
12 #include <BALL/DATATYPE/string.h>
13 #include <BALL/DATATYPE/hashGrid.h>
20 
21 namespace BALL
22 {
23  typedef std::list<std::pair<Atom*, Atom*> > AtomPairList;
24  typedef std::vector<std::pair<Atom*, Atom*> > AtomPairVector;
25 
26  class ScoringComponent;
27 
29  {
30 
32  friend class SideChainOptimizer;
33 
34  public:
35 
36  static const char* SUBCATEGORY_NAME;
37 
38  struct Option
39  {
42  static const char* VERBOSITY;
43 
46  static const char* BASE_FUNCTION_TYPE;
47 
50  static const char* HASHGRID_RESOLUTION;
51 
54  static const char* HASHGRID_SIZE;
55 
58  static const char* NONBONDED_CUTOFF;
59 
62  static const char* CONFORMATION_SCALE;
63 
66  static const char* ALL_LIG_NONB_PAIRS;
67 
70  static const char* USE_STATIC_LIG_FRAGMENTS;
71 
74  static const char* IGNORE_H_CLASHES;
75 
78  static const char* ALLOWED_INTERMOL_OVERLAP;
79 
82  static const char* ALLOWED_INTRAMOL_OVERLAP;
83 
86  static const char* BURIAL_DEPTH_SCALE;
87  };
88 
89 
90  struct Default
91  {
94  static const Size VERBOSITY;
95 
98  static const Size BASE_FUNCTION_TYPE;
99 
101  static double HASHGRID_RESOLUTION;
102 
104  static int HASHGRID_SIZE;
105 
106  static double NONBONDED_CUTOFF;
107 
109  static double CONFORMATION_SCALE;
110 
112  static bool ALL_LIG_NONB_PAIRS;
113 
116 
118  static bool IGNORE_H_CLASHES;
119 
122 
125 
126  static int BURIAL_DEPTH_SCALE;
127  };
128 
130  ScoringFunction();
131 
133  ScoringFunction(const ScoringFunction& sf);
134 
136  ScoringFunction(AtomContainer& receptor, AtomContainer& ligand);
137 
139  ScoringFunction(AtomContainer& receptor, AtomContainer& ligand,
140  const Options& options);
141 
142  ScoringFunction(AtomContainer& receptor,
143  AtomContainer& ligand, Options& options);
144 
149  ScoringFunction(AtomContainer& receptor, Vector3& hashgrid_origin, Options& options);
150 
152  virtual ~ScoringFunction();
153 
155  virtual void clear();
156 
158  ScoringFunction& operator = (const ScoringFunction& sf);
159 
161  bool setup();
162 
164  bool setup(AtomContainer& receptor, AtomContainer& ligand);
165 
167  bool setup(AtomContainer& receptor, AtomContainer& ligand, const Options& options);
168 
170  void setMaximumNumberOfErrors(Size nr);
171 
173  Size getMaximumNumberOfErrors() const;
174 
176  void setFirstMolecule(AtomContainer& molecule1);
177 
179  AtomContainer* getFirstMolecule() const;
180 
182  void setSecondMolecule(AtomContainer& molecule2);
183 
185  AtomContainer* getSecondMolecule() const;
186 
190  void setReceptor(AtomContainer& receptor);
191 
195  AtomContainer* getReceptor() const;
196 
200  void setLigand(AtomContainer& ligand);
201 
205  AtomContainer* getLigand() const;
206 
208  void setIntercept(double intercept);
209 
211  double getIntercept() const;
212 
214  void setBaseFunction(ScoringBaseFunction& base_function);
215 
219  ScoringBaseFunction* getBaseFunction() const;
220 
225  void insertComponent(ScoringComponent* component);
226 
232  void insertComponent(ScoringComponent* component, float coefficient);
233 
239  void removeComponent(const ScoringComponent* component);
240 
247  void removeComponent(const String& name);
248 
253  void setCoefficient(const ScoringComponent* component, float coefficient);
254 
260  void setCoefficient(const String& name, float coefficient);
261 
266  bool getCoefficient(const ScoringComponent* component,
267  float& coefficient) const;
268 
273  bool getCoefficient(const String& name, float& coefficient) const;
274 
278  ScoringComponent* getComponent(const String& name) const;
279 
283  ScoringComponent* getComponent(const Size index) const;
284 
286  double calculateScore();
287 
289  const HashSet<const Atom*>& getUnassignedAtoms() const;
290 
292  HashSet<const Atom*>& getUnassignedAtoms();
293 
295  static HashGrid3<Atom*>* initializeHashGrid(AtomContainer* sys,
296  Vector3& center,
297  double& resolution,
298  int hashgrid_size);
299 
304  double getExpEnergyStddev();
305 
306  void enableStoreInteractionsOnlyForPhContraints();
307 
311  String convertTime(double seconds);
312 
316  virtual void update();
317 
321  virtual double updateScore();
322 
327  virtual void printResult(bool detail = 0);
328 
329  void getScoreContributions(vector<double>& score_contributions, vector<String>& names);
330 
334  static void getDefaultOptions(Options& options);
335 
339  String getEquation();
340 
345  void enableStoreInteractions(bool b = true);
346 
350  String getName();
351 
352  int getBurialDepthScale();
353 
354  String valueToString(double value);
355 
360  void unsetTrainingParameters();
361 
366  void setNormalizationParameters(double stddev, double mean);
367 
368  const HashGrid3<Atom*>* getHashGrid();
369 
373  const Vector3& getLigandCenter() const;
374 
375  double getLigandRadius() const;
376 
381  bool storeInteractionsEnabled();
382 
387  virtual int getNoNeighboringReceptorAtoms();
388 
392  int getNoLigandAtoms();
393 
397  Options getOptions();
398 
402  Options* getOptionsToModify();
403 
410  void createStaticLigandFragments();
411 
412  const vector<Bond*>* getRotatableLigandBonds() const;
413 
414  const vector<StaticLigandFragment*>* getStaticLigandFragments() const;
415 
416  bool hasFlexibleResidues();
417 
418  void setFlexibleResidues(const std::set<Residue*>& flexible_residues);
419 
427  bool assignRotamer(Residue* residue, ResidueRotamerSet* rotamer_set, const Rotamer* rotamer);
428 
434  void resetFlexibleResidues();
435 
441  Size countNeighboringReceptorAtoms(const Atom* atom,
442  double distance_threshold,
443  bool onePerCell = 0,
444  int* number_of_overlaps = 0) const;
445 
446  void resetResiduePositions(Residue* residue, list<Vector3>& old_positions);
447 
451  double getScore();
452 
453  const std::map<Atom*, int>* getAtomFragmentMap();
454 
460  list<Constraint*> constraints {};
461 
462  protected:
463  /* @name Protected structs */
464  struct Result
465  {
470 
475 
479  vector<double> refArea_penalties;
480  };
481 
485  void setName(String name);
486 
487  void updateComponent(int id, AtomPairList*);
488 
493  Vector3 calculateGeometricalCenter(AtomContainer* s, int* no_ligand_atoms = NULL);
494 
498  double calculateMoleculeRadius(AtomContainer* sys, Vector3& center);
499 
500  void setupFlexibleResidues_();
501 
507  virtual void setupReferenceLigand();
508 
512  int checkForAtomOverlaps(const AtomPairVector* pair_vector);
513 
525  AtomPairVector* createNonbondedPairVector(HashGrid3<Atom*>* hashgrid, int& overlaps, bool rec_lig, bool check_fragments = 0, bool intra_fragment = 0);
526 
535  AtomPairVector* createLigandNonbondedPairVector(bool intra_fragment, int& overlaps);
536 
537  bool hasPharmacophoreConstraints_();
538 
542  void clearStoredInteractions_();
543 
547  double calculateConstraintsScore();
548 
553  void enableInteractionComponents_(const list<String>& type_names);
554 
555  virtual double getES();
556 
560  void enableAllComponents_();
561 
567  void fetchStaticLigandFragment(Atom* a1, int index);
568 
573  int countCovalentBonds(const Atom* atom, int threshold = -1);
574 
580  virtual void createAllLigandNonBondedPairs();
581 
586  virtual double calculateStaticLigandFragmentEnergy();
587 
591  bool isPeptideBond(const Bond* bond) const;
592 
596  String name_ {""};
597 
601  Options options_ {};
602 
606  AtomContainer* receptor_ {nullptr};
607 
611  AtomContainer* ligand_ {nullptr};
612 
616  double score_ {0.0};
617 
621  double intercept_ {0.0};
622 
626  ScoringBaseFunction* base_function_ {nullptr};
627 
631  vector<ScoringComponent*> scoring_components_ {};
632 
636  HashSet<const Atom*> unassigned_atoms_ {};
637 
641  Size max_number_of_errors_ {0};
642 
646  Size number_of_errors_ {0};
647 
651  double ligand_radius_ {0.0};
652 
657  int ligand_atoms_ {0};
658 
662  Vector3 ligand_center_ {};
663 
667  HashGrid3<Atom*>* hashgrid_ {nullptr};
668 
669  HashGrid3<Atom*>* all_residues_hashgrid_ {nullptr};
670  HashGrid3<Atom*>* static_residues_hashgrid_ {nullptr};
671  HashGrid3<Atom*>* flexible_residues_hashgrid_ {nullptr};
672 
676  double resolution_ {0.0};
677 
681  std::map<Atom*, int> atoms_to_fragments_ {};
682 
687  int reference_neighbors_ {0};
688 
693  int neighboring_target_atoms_ {0};
694 
699  int misplaced_ligand_atoms_ {0};
700 
704  int hashgrid_search_radius_ {0};
705 
709  double nonbonded_cutoff_ {0.0};
710 
714  double nonbonded_cutoff_2_ {0.0};
715 
719  bool ignore_h_clashes_ {false};
720 
724  int overlaps_ {0};
725 
729  int ligand_intramol_overlaps_ {0};
730 
735  double allowed_intermolecular_overlap_ {0.0};
736 
741  double allowed_intramolecular_overlap_ {0.0};
742 
747  double neighbor_cutoff_2_ {0.0};
748 
756  vector<StaticLigandFragment*> static_ligand_fragments_ {};
757 
763  bool store_interactions_ {false};
764 
765  bool store_interactions_phC_only_ {false};
766 
770  AtomPairVector* all_ligand_nonbonded_ {nullptr};
771 
775  double conformation_scale_ {0.0};
776 
780  bool use_all_lig_nonb_ {false};
781 
785  bool use_static_lig_fragments_ {false};
786 
787  int burial_depth_scale_ {0};
788 
792  double exp_energy_stddev_ {0.0};
793 
797  double exp_energy_mean_ {0.0};
798 
799  std::set<Residue*> flexible_residues_ {};
800 
804  Result result_ {};
805 
809  double static_ligand_energy_ {0.0};
810 
815  vector<Bond*> rotatable_ligand_bonds_ {};
816 
821  list<list<Vector3> > flexres_org_positions_ {};
822 
823  };
824 
825 } // namespace BALL
826 
827 #endif // BALL_SCORING_COMMON_SCORINGFUNCTION_H
BALL::PharmacophoreConstraint
Definition: constraints.h:144
BALL::ScoringFunction::Default
Definition: scoringFunction.h:90
BALL::ScoringFunction::Default::NONBONDED_CUTOFF
static double NONBONDED_CUTOFF
Definition: scoringFunction.h:106
BALL::ScoringFunction::Option::NONBONDED_CUTOFF
static const char * NONBONDED_CUTOFF
Definition: scoringFunction.h:58
BALL::ScoringFunction::Result::ligand_conformation
double ligand_conformation
Definition: scoringFunction.h:469
BALL::Options
Definition: options.h:46
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::ScoringFunction
Definition: scoringFunction.h:28
system.h
BALL::ScoringFunction::Option::USE_STATIC_LIG_FRAGMENTS
static const char * USE_STATIC_LIG_FRAGMENTS
Definition: scoringFunction.h:70
BALL::ScoringFunction::Option::VERBOSITY
static const char * VERBOSITY
Definition: scoringFunction.h:42
BALL::Residue
Definition: residue.h:36
BALL::ScoringFunction::Result::refArea_penalties
vector< double > refArea_penalties
Definition: scoringFunction.h:479
BALL::HashSet
Definition: hashSet.h:45
BALL::ScoringFunction::Option::HASHGRID_RESOLUTION
static const char * HASHGRID_RESOLUTION
Definition: scoringFunction.h:50
BALL::AtomPairList
std::list< std::pair< Atom *, Atom * > > AtomPairList
Definition: scoringFunction.h:23
BALL::ScoringFunction::Default::HASHGRID_RESOLUTION
static double HASHGRID_RESOLUTION
Definition: scoringFunction.h:101
BALL::ScoringFunction::Default::HASHGRID_SIZE
static int HASHGRID_SIZE
Definition: scoringFunction.h:104
BALL::SideChainOptimizer
Definition: sideChainOptimizer.h:21
BALL::Bond
Definition: bond.h:54
BALL::TVector3< float >
BALL::AtomContainer
Definition: atomContainer.h:29
BALL_SIZE_TYPE
BALL::ResidueRotamerSet
Definition: residueRotamerSet.h:87
BALL::ScoringFunction::Default::ALL_LIG_NONB_PAIRS
static bool ALL_LIG_NONB_PAIRS
Definition: scoringFunction.h:112
BALL::Atom
Definition: atom.h:87
BALL::ScoringFunction::Option::BASE_FUNCTION_TYPE
static const char * BASE_FUNCTION_TYPE
Definition: scoringFunction.h:46
BALL
Definition: constants.h:12
BALL::ScoringFunction::Default::BURIAL_DEPTH_SCALE
static int BURIAL_DEPTH_SCALE
Definition: scoringFunction.h:126
BALL::ScoringFunction::Result
Definition: scoringFunction.h:464
BALL::String
Definition: string.h:56
residueRotamerSet.h
BALL::ScoringFunction::Option::ALLOWED_INTERMOL_OVERLAP
static const char * ALLOWED_INTERMOL_OVERLAP
Definition: scoringFunction.h:78
BALL::Rotamer
Definition: residueRotamerSet.h:37
scoringComponent.h
BALL::ScoringFunction::Option::ALLOWED_INTRAMOL_OVERLAP
static const char * ALLOWED_INTRAMOL_OVERLAP
Definition: scoringFunction.h:82
BALL::ScoringFunction::Option::IGNORE_H_CLASHES
static const char * IGNORE_H_CLASHES
Definition: scoringFunction.h:74
options.h
BALL::ScoringFunction::Option
Definition: scoringFunction.h:38
hashGrid.h
BALL::ScoringFunction::Option::BURIAL_DEPTH_SCALE
static const char * BURIAL_DEPTH_SCALE
Definition: scoringFunction.h:86
BALL::ScoringFunction::Result::interaction_score
double interaction_score
Definition: scoringFunction.h:474
BALL::HashGrid3
Three-dimensional Hash Grid Class.
Definition: hashGrid.h:38
BALL::ScoringFunction::Default::ALLOWED_INTERMOL_OVERLAP
static double ALLOWED_INTERMOL_OVERLAP
Definition: scoringFunction.h:121
BALL::ScoringFunction::Default::CONFORMATION_SCALE
static double CONFORMATION_SCALE
Definition: scoringFunction.h:109
BALL::ScoringFunction::Default::USE_STATIC_LIG_FRAGMENTS
static bool USE_STATIC_LIG_FRAGMENTS
Definition: scoringFunction.h:115
BALL::ScoringComponent
Definition: scoringComponent.h:20
string.h
BALL::ScoringFunction::Default::IGNORE_H_CLASHES
static bool IGNORE_H_CLASHES
Definition: scoringFunction.h:118
BALL::ScoringFunction::Default::VERBOSITY
static const Size VERBOSITY
Definition: scoringFunction.h:94
BALL::ScoringFunction::Default::BASE_FUNCTION_TYPE
static const Size BASE_FUNCTION_TYPE
Definition: scoringFunction.h:98
BALL::ScoringFunction::Default::ALLOWED_INTRAMOL_OVERLAP
static double ALLOWED_INTRAMOL_OVERLAP
Definition: scoringFunction.h:124
constraints.h
staticLigandFragment.h
atomContainer.h
BALL::ScoringFunction::Option::CONFORMATION_SCALE
static const char * CONFORMATION_SCALE
Definition: scoringFunction.h:62
BALL::RTTI::getName
const char * getName()
Definition: rtti.h:97
BALL::ScoringFunction::Option::HASHGRID_SIZE
static const char * HASHGRID_SIZE
Definition: scoringFunction.h:54
BALL::AtomPairVector
std::vector< std::pair< Atom *, Atom * > > AtomPairVector
Definition: scoringFunction.h:24
baseFunction.h
BALL::ScoringFunction::Option::ALL_LIG_NONB_PAIRS
static const char * ALL_LIG_NONB_PAIRS
Definition: scoringFunction.h:66
BALL::ScoringFunction::SUBCATEGORY_NAME
static const char * SUBCATEGORY_NAME
Definition: scoringFunction.h:36
BALL::ScoringBaseFunction
Definition: baseFunction.h:14