File size: 4,103 Bytes
8efb4bd | 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 | #ifndef GEOM_SCORE_H
#define GEOM_SCORE_H
#include <stack>
#include <utility>
#include <vector>
#include <Surface.h>
#include <MoleculeGrid.h>
#include "MultiResolution.h"
#include <Match.h>
#include <Particle.h>
//#include "MMonteCarlo.h"
class MyMatch : public Match {
public:
void setScore(unsigned int pairIndex, float score) { pairs[pairIndex].score = score; }
};
class RangeParams {
public:
RangeParams(const std::vector<int>& wts);
unsigned int findRange(float dist) const {
for(unsigned int i=0; i< ranges.size(); i++)
if(dist <= ranges[i]) return i;
return ranges.size();
}
public:
std::vector<float> ranges;
std::vector<int> weights;
};
class ScoreData {
public:
ScoreData() { score=0; asScore=0; interfaceArea=0;}
int score;
int asScore;
float interfaceArea;
float maxPenetration;
public:
// int getSurfaceRange() {return pointsInRanges[3];}
friend std::ostream& operator<<(std::ostream& s, const ScoreData& data) {
s.width(5); s << data.score << "|";
s.width(5); s << data.asScore << "|";
s.width(5); s << data.maxPenetration << "|";
s.width(5); s << data.interfaceArea << "|";
return s;
}
};
class ScorePair : public std::pair<ScoreData, ScoreData> {
public:
ScorePair(ScoreData f, ScoreData s, RigidTrans3 trans) : std::pair<ScoreData, ScoreData> (f,s) {
trans_ = trans;
score_ = f.score + s.score - abs(f.score - s.score);
}
int score() const { return score_; }
const RigidTrans3& rigidTrans() const { return trans_; }
friend std::ostream& operator<<(std::ostream& s, const ScorePair& p) {
s << p.first << "|";
s << std::endl << " ";
s << p.second << "|";
return s;
}
protected:
RigidTrans3 trans_;
int score_;
};
class GeomScore {
public:
typedef MultiResolution<SurfacePoint>::Node Node;
typedef MultiResolution<SurfacePoint>::Level Level;
GeomScore(const Surface& lowLevel, MoleculeGrid* grid,
const std::vector<int>& wts, float penetration_thr, float ns_thr, float density=10.0, float gridMargins=7.0);
GeomScore(const Surface& lowLevel,
const std::vector<int>& wts, float penetration_thr, float ns_thr, float density=10.0, float gridMargins=7.0);
GeomScore(MoleculeGrid* grid,
const std::vector<int>& wts, float penetration_thr, float ns_thr=0.5, float density=10.0, float gridMargins=7.0);
void setGrid(const MoleculeGrid* grid) { grid_ = grid; }
void setSurface(const Surface& lowLevel) {
tree.setPointSet(lowLevel);
buildTree();
}
void buildTree();
void buildTree(const std::vector<bool>& as);
//// Penetration checks
float maxPenetration(const RigidTrans3& trans);
bool isPenetrating(const RigidTrans3& trans);
//// fast check, but can return false for penetrating trans
bool fastIsPenetrating(const RigidTrans3& trans);
void getInterface(const RigidTrans3& trans, float low_thr, float high_thr, std::vector<const SurfacePoint*>& interface);
//// Scoring functions
int score(const RigidTrans3& trans);
int score(const RigidTrans3& trans, float& asRatio, int& asScore);
int score(const RigidTrans3& trans, const Surface& surface, float& penetration);
ScoreData fullScore(const RigidTrans3& trans, bool as=false);
int refineTrans(const RigidTrans3& trans, RigidTrans3& newTrans);
void printTree(std::ofstream& outFile);
float computePropensity(const RigidTrans3& trans);
private:
void scoreRanges(const RigidTrans3& trans, std::vector<unsigned int>& pointsInRanges);
void scoreRanges(const RigidTrans3& trans, std::vector<unsigned int>& pointsInRanges,
std::vector<unsigned int>& asInRanges);
void node2interface(const Node* node, std::vector<const SurfacePoint*>& interface);
void countActiveSitePoints(const std::vector<bool>& as);
private:
const MoleculeGrid* grid_;
const RangeParams rangeParams;
float penetrationThr_;
float divNsThr; // 1/nsThr
float density;
MultiResolution<SurfacePoint> tree;
};
#endif
|