File size: 1,865 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 | #ifndef BESTK_H
#define BESTK_H
#include "SuperBB.h"
#include <mutex>
static float scoreSuperBB(const std::shared_ptr<SuperBB> &sbb) {
// return sbb->getRestraintsRatio();
// return sbb->weightedTransScore_;
// Note: if you change this, you also needs to change in HierarchicalFold::tryToConnect which optimizes by
// summing and comparing trans scores before trying to connect
// return sbb->transScore_;
return sbb->transScore_ * sbb->getRestraintsRatio();
}
struct comp {
bool operator()(const std::shared_ptr<SuperBB> &lhs, const std::shared_ptr<SuperBB> &rhs) const {
return scoreSuperBB(lhs) < scoreSuperBB(rhs);
}
};
/**
This class stores the best k permutations of a specific size
implemented as inheriting from a multiset with shapred_ptr and
the comp struct
*/
class BestK : public std::multiset<std::shared_ptr<SuperBB>, comp> {
public:
BestK(unsigned int k, bool toDel = true) : k_(k), curMinScore(-1) {}
float score(const std::shared_ptr<SuperBB> &sbb) const { return scoreSuperBB(sbb); }
float minScore() const { return curMinScore; }
float maxScore() const {
if (size() == 0)
return 0;
return score(*rbegin());
}
void setK(int k) { k_ = k; }
bool push(std::shared_ptr<SuperBB> in);
bool push_cluster(std::shared_ptr<SuperBB> in, double rmsd, std::vector<std::vector<unsigned int>> &identGroups);
void cluster(BestK &clusteredBest, double rmsd, std::vector<std::vector<unsigned int>> &identGroups) const;
virtual ~BestK() {}
private:
float internalMinScore() {
if (size() < k_)
return -1;
return score(*begin());
}
private:
std::mutex _mu;
unsigned int k_;
float curMinScore;
};
#endif /* BESTK_H */
|