Пример #1
0
void generateReactantCombinations(const VectVectMatchVectType &matchesByReactant,
                                  VectVectMatchVectType &matchesPerProduct) {
    matchesPerProduct.clear();
    VectMatchVectType tmp;
    tmp.clear();
    tmp.resize(matchesByReactant.size());
    recurseOverReactantCombinations(matchesByReactant,matchesPerProduct,0,tmp);
} // end of generateReactantCombinations()
Пример #2
0
void generateReactantCombinations(
    const VectVectMatchVectType &matchesByReactant,
    VectVectMatchVectType &matchesPerProduct, unsigned int maxProducts) {
  matchesPerProduct.clear();
  VectMatchVectType tmp;
  tmp.clear();
  tmp.resize(matchesByReactant.size());
  if (!recurseOverReactantCombinations(matchesByReactant, matchesPerProduct, 0,
                                       tmp, maxProducts)) {
    BOOST_LOG(rdWarningLog) << "Maximum product count hit " << maxProducts
                            << ", stopping reaction early...\n";
  }
}  // end of generateReactantCombinations()
Пример #3
0
void recurseOverReactantCombinations(const VectVectMatchVectType &matchesByReactant,
                                     VectVectMatchVectType &matchesPerProduct,
                                     unsigned int level,VectMatchVectType combination) {
    unsigned int nReactants=matchesByReactant.size();
    RANGE_CHECK(0,level,nReactants-1);
    PRECONDITION(combination.size()==nReactants,"bad combination size");
    for(VectMatchVectType::const_iterator reactIt=matchesByReactant[level].begin();
            reactIt != matchesByReactant[level].end(); ++reactIt) {
        VectMatchVectType prod=combination;
        prod[level] = *reactIt;
        if(level==nReactants-1) {
            // this is the bottom of the recursion:
            matchesPerProduct.push_back(prod);
        } else {
            recurseOverReactantCombinations(matchesByReactant,matchesPerProduct,level+1,prod);
        }
    }
} //end of recurseOverReactantCombinations