12 #ifndef _RD_O3AALIGNMOLECULES_H_
13 #define _RD_O3AALIGNMOLECULES_H_
25 #include <boost/shared_ptr.hpp>
26 #include <boost/multi_array.hpp>
27 #include <boost/dynamic_bitset.hpp>
41 return ((x < 1.0e-10) && (x > -1.0e-10));
44 class O3AConstraintVect;
60 unsigned int d_prbIdx;
61 unsigned int d_refIdx;
74 void append(
unsigned int prbIdx,
unsigned int refIdx,
double weight) {
76 o3aConstraint->d_idx = d_count;
77 o3aConstraint->d_prbIdx = prbIdx;
78 o3aConstraint->d_refIdx = refIdx;
79 o3aConstraint->d_weight = weight;
80 d_o3aConstraintVect.push_back(
81 boost::shared_ptr<O3AConstraint>(o3aConstraint));
82 std::sort(d_o3aConstraintVect.begin(), d_o3aConstraintVect.end(),
83 d_compareO3AConstraint);
86 std::vector<boost::shared_ptr<O3AConstraint>>::size_type
size() {
87 return d_o3aConstraintVect.size();
90 return d_o3aConstraintVect[i].get();
95 std::vector<boost::shared_ptr<O3AConstraint>> d_o3aConstraintVect;
96 static bool d_compareO3AConstraint(boost::shared_ptr<O3AConstraint> a,
97 boost::shared_ptr<O3AConstraint> b) {
99 (a->d_prbIdx != b->d_prbIdx)
100 ? (a->d_prbIdx < b->d_prbIdx)
101 : ((a->d_refIdx != b->d_refIdx)
102 ? (a->d_refIdx < b->d_refIdx)
103 : ((a->d_weight != b->d_weight) ? (a->d_weight > b->d_weight)
104 : (a->d_idx < b->d_idx))));
137 inline int get(
const unsigned int y,
const unsigned int x)
const {
138 PRECONDITION(y < d_h.shape()[0],
"Invalid index on MolHistogram");
139 PRECONDITION(x < d_h.shape()[1],
"Invalid index on MolHistogram");
144 boost::multi_array<int, 2> d_h;
158 d_cost(
boost::extents[dim][dim]){};
160 int getCost(
const unsigned int i,
const unsigned int j) {
161 PRECONDITION(i < d_cost.shape()[0],
"Invalid index on LAP.cost");
162 PRECONDITION(j < d_cost.shape()[1],
"Invalid index on LAP.cost");
166 PRECONDITION(i < d_rowSol.size(),
"Invalid index on LAP.rowSol");
169 void computeMinCostPath(
const int dim);
173 int (*costFunc)(
const unsigned int,
const unsigned int,
178 std::vector<int> d_rowSol;
179 std::vector<int> d_colSol;
180 std::vector<int> d_free;
181 std::vector<int> d_colList;
182 std::vector<int> d_matches;
183 std::vector<int> d_d;
184 std::vector<int> d_v;
185 std::vector<int> d_pred;
186 boost::multi_array<int, 2> d_cost;
194 : d_prbConf(prbConf),
196 d_o3aConstraintVect(o3aConstraintVect){};
199 : d_prbConf(other.d_prbConf),
200 d_refConf(other.d_refConf),
201 d_o3aConstraintVect(other.d_o3aConstraintVect),
202 d_SDMPtrVect(other.d_SDMPtrVect.size()) {
203 for (
unsigned int i = 0; i < d_SDMPtrVect.size(); ++i) {
204 d_SDMPtrVect[i] = boost::shared_ptr<SDMElement>(
new SDMElement());
205 memcpy(d_SDMPtrVect[i].get(), other.d_SDMPtrVect[i].get(),
211 d_prbConf = other.d_prbConf;
212 d_refConf = other.d_refConf;
213 d_o3aConstraintVect = other.d_o3aConstraintVect;
214 d_SDMPtrVect.resize(other.d_SDMPtrVect.size());
215 for (
unsigned int i = 0; i < d_SDMPtrVect.size(); ++i) {
216 d_SDMPtrVect[i] = boost::shared_ptr<SDMElement>(
new SDMElement());
217 memcpy(d_SDMPtrVect[i].get(), other.d_SDMPtrVect[i].get(),
225 void fillFromDist(
double threshold,
226 const boost::dynamic_bitset<> &refHvyAtoms,
227 const boost::dynamic_bitset<> &prbHvyAtoms);
228 void fillFromLAP(
LAP &lap);
229 double scoreAlignment(
double (*scoringFunc)(
const unsigned int,
230 const unsigned int,
void *),
234 double (*weightFunc)(
const unsigned int,
235 const unsigned int,
void *),
237 unsigned int size() {
return d_SDMPtrVect.size(); }
240 typedef struct SDMElement {
249 O3AConstraintVect *d_o3aConstraintVect;
250 std::vector<boost::shared_ptr<SDMElement>> d_SDMPtrVect;
251 static bool compareSDMScore(boost::shared_ptr<SDMElement> a,
252 boost::shared_ptr<SDMElement> b) {
253 return ((a->score != b->score)
254 ? (a->score < b->score)
255 : ((a->cost != b->cost)
256 ? (a->cost < b->cost)
257 : ((a->idx[0] != b->idx[0]) ? (a->idx[0] < b->idx[0])
258 : (a->idx[1] < b->idx[1]))));
260 static bool compareSDMDist(boost::shared_ptr<SDMElement> a,
261 boost::shared_ptr<SDMElement> b) {
262 double aWeight = (a->o3aConstraint ? a->o3aConstraint->getWeight() : 0.0);
263 double bWeight = (b->o3aConstraint ? b->o3aConstraint->getWeight() : 0.0);
264 return ((aWeight != bWeight)
265 ? (aWeight > bWeight)
266 : ((a->sqDist != b->sqDist)
267 ? (a->sqDist < b->sqDist)
268 : ((a->idx[0] != b->idx[0]) ? (a->idx[0] < b->idx[0])
269 : (a->idx[1] < b->idx[1]))));
276 typedef enum { MMFF94 = 0, CRIPPEN } AtomTypeScheme;
277 O3A(
ROMol &prbMol,
const ROMol &refMol,
void *prbProp,
void *refProp,
278 AtomTypeScheme atomTypes = MMFF94,
const int prbCid = -1,
279 const int refCid = -1,
const bool reflect =
false,
280 const unsigned int maxIters = 50,
unsigned int options = 0,
285 O3A(
int (*costFunc)(
const unsigned int,
const unsigned int,
double,
void *),
286 double (*weightFunc)(
const unsigned int,
const unsigned int,
void *),
287 double (*scoringFunc)(
const unsigned int,
const unsigned int,
void *),
288 void *data,
ROMol &prbMol,
const ROMol &refMol,
const int prbCid,
289 const int refCid, boost::dynamic_bitset<> *prbHvyAtoms = NULL,
290 boost::dynamic_bitset<> *refHvyAtoms = NULL,
const bool reflect =
false,
291 const unsigned int maxIters = 50,
unsigned int options = 0,
296 if (d_o3aMatchVect) {
297 delete d_o3aMatchVect;
305 double score() {
return d_o3aScore; };
311 const ROMol *d_refMol;
315 unsigned int d_maxIters;
322 const int seed = -1);
326 const unsigned int refIdx,
327 double hSum,
void *data);
329 const unsigned int refIdx,
332 const unsigned int refIdx,
335 const unsigned int refIdx,
336 double hSum,
void *data);
338 const unsigned int refIdx,
341 const unsigned int refIdx,
345 ROMol &prbMol,
const ROMol &refMol,
void *prbProp,
void *refProp,
346 std::vector<boost::shared_ptr<O3A>> &res,
int numThreads = 1,
348 const bool reflect =
false,
const unsigned int maxIters = 50,
349 unsigned int options = 0,
const MatchVectType *constraintMap = NULL,