Skip to content

Instantly share code, notes, and snippets.

@drussel
Created May 7, 2013 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drussel/5530046 to your computer and use it in GitHub Desktop.
Save drussel/5530046 to your computer and use it in GitHub Desktop.
subset filter patch
diff --git a/modules/domino/src/subset_filters.cpp b/modules/domino/src/subset_filters.cpp
index d67b397..220acb9 100644
--- a/modules/domino/src/subset_filters.cpp
+++ b/modules/domino/src/subset_filters.cpp
@@ -81,21 +81,27 @@ MinimumRestraintScoreSubsetFilterTable
std::sort(rs_.begin(), rs_.end());
}
+namespace {
+ RestraintsTemp get_needed(RestraintCache rc, const Subset &s,
+ const Restraints &all) {
+ RestraintsTemp cur = rc->get_restriants(s, Subsets());
+ std::sort(cur.begin(), cur.end());
+ RestraintsTemp ret;
+ std::set_intersection(cur.begin(), cur.end(), all.begin(), all.end(),
+ std::back_inserter(ret));
+ return ret;
+ }
+}
+
RestraintsTemp MinimumRestraintScoreSubsetFilterTable
::get_restraints(const Subset &s,
const Subsets &excluded) const {
- RestraintsTemp all= rc_->get_restraints(s, excluded);
- // if there are no new ones, return nothing
- if (all.empty()) return RestraintsTemp();
- // otherwise, we want them all, not just new
- all= rc_->get_restraints(s, Subsets());
- RestraintsTemp ret;
- for (unsigned int i=0; i< all.size(); ++i) {
- if (std::binary_search(rs_.begin(), rs_.end(), all[i])) {
- ret.push_back(all[i]);
- }
+ RestraintsTemp all= get_needed(rc_, s, rs_);
+ for (unsigned int i=0; i < excluded.size(); ++i) {
+ RestraintsTemp cur= get_needed(rc_, excluded[i], rs_);
+ if (cur.size() == all.size()) return RestraintsTemp();
}
- return ret;
+ return all;
}
SubsetFilter*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment