--- trunk/src/UseTheForce/ForceField.cpp 2008/07/01 13:28:23 1269 +++ trunk/src/UseTheForce/ForceField.cpp 2008/07/14 12:35:58 1277 @@ -124,6 +124,7 @@ namespace oopse { myKeys.push_back((*i)->getName()); myKeys.push_back((*j)->getName()); + std::cerr << "looking for " << myKeys[0] << " " << myKeys[1] << "\n"; BondType* bondType = bondTypeCont_.find(myKeys); if (bondType) { foundBonds.push_back(std::make_pair(bondTypeScore, myKeys)); @@ -133,20 +134,21 @@ namespace oopse { ii++; } - // sort the foundBonds by the score: - std::sort(foundBonds.begin(), foundBonds.end()); - - int bestScore = foundBonds[0].first; - std::vector theKeys = foundBonds[0].second; - - std::cout << "best matching bond = " << theKeys[0] << "\t" << theKeys[1] << "\t(score = "<< bestScore << ")\n"; - BondType* bestType = bondTypeCont_.find(theKeys); - if (bestType) - return bestType; - else { - //if no exact match found, try wild card match - return bondTypeCont_.find(keys, wildCardAtomTypeName_); + if (foundBonds.size() > 0) { + // sort the foundBonds by the score: + std::sort(foundBonds.begin(), foundBonds.end()); + + int bestScore = foundBonds[0].first; + std::vector theKeys = foundBonds[0].second; + + std::cout << "best matching bond = " << theKeys[0] << "\t" << theKeys[1] << "\t(score = "<< bestScore << ")\n"; + BondType* bestType = bondTypeCont_.find(theKeys); + + return bestType; + } else { + //if no exact match found, try wild card match + return bondTypeCont_.find(keys, wildCardAtomTypeName_); } } } @@ -220,26 +222,23 @@ namespace oopse { jj++; } - std::sort(foundBends.begin(), foundBends.end()); - - int jscore = foundBends[0].first; - int ikscore = foundBends[0].second; - std::vector theKeys = foundBends[0].third; - - std::cout << "best matching bend = " << theKeys[0] << "\t" < 0) { + std::sort(foundBends.begin(), foundBends.end()); + int jscore = foundBends[0].first; + int ikscore = foundBends[0].second; + std::vector theKeys = foundBends[0].third; + + std::cout << "best matching bend = " << theKeys[0] << "\t" < 0) { + std::sort(foundTorsions.begin(), foundTorsions.end()); + int jkscore = foundTorsions[0].first; + int ilscore = foundTorsions[0].second; + std::vector theKeys = foundTorsions[0].third; + + std::cout << "best matching torsion = " << theKeys[0] << "\t" < theKeys = foundTorsions[0].third; + InversionType* ForceField::getInversionType(const std::string &at1, + const std::string &at2, + const std::string &at3, + const std::string &at4) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + keys.push_back(at4); - std::cout << "best matching torsion = " << theKeys[0] << "\t" < at1key; + at1key.push_back(at1); + atype1 = atomTypeCont_.find(at1key); + + std::vector at2key; + at2key.push_back(at2); + atype2 = atomTypeCont_.find(at2key); + + std::vector at3key; + at3key.push_back(at3); + atype3 = atomTypeCont_.find(at3key); + + std::vector at4key; + at4key.push_back(at4); + atype4 = atomTypeCont_.find(at4key); + // query atom types for their chains of responsibility + std::vector at1Chain = atype1->allYourBase(); + std::vector at2Chain = atype2->allYourBase(); + std::vector at3Chain = atype3->allYourBase(); + std::vector at4Chain = atype4->allYourBase(); + + std::vector::iterator i; + std::vector::iterator j; + std::vector::iterator k; + std::vector::iterator l; + + int ii = 0; + int jj = 0; + int kk = 0; + int ll = 0; + int Iscore; + int JKLscore; - TorsionType* bestType = torsionTypeCont_.find(theKeys); - if (bestType) { - return bestType; + std::vector > > foundInversions; + + for (j = at2Chain.begin(); j != at2Chain.end(); j++) { + kk = 0; + for (k = at3Chain.begin(); k != at3Chain.end(); k++) { + ii = 0; + for (i = at1Chain.begin(); i != at1Chain.end(); i++) { + ll = 0; + for (l = at4Chain.begin(); l != at4Chain.end(); l++) { + + Iscore = ii; + JKLscore = jj + kk + ll; + + std::vector myKeys; + myKeys.push_back((*i)->getName()); + myKeys.push_back((*j)->getName()); + myKeys.push_back((*k)->getName()); + myKeys.push_back((*l)->getName()); + + InversionType* inversionType = inversionTypeCont_.find(myKeys); + if (inversionType) { + foundInversions.push_back( make_tuple3(Iscore, JKLscore, myKeys) ); + } + ll++; + } + ii++; + } + kk++; + } + jj++; + } + + if (foundInversions.size() > 0) { + std::sort(foundInversions.begin(), foundInversions.end()); + int iscore = foundInversions[0].first; + int jklscore = foundInversions[0].second; + std::vector theKeys = foundInversions[0].third; + + std::cout << "best matching inversion = " << theKeys[0] << "\t" < keys; keys.push_back(at1); @@ -390,15 +490,27 @@ namespace oopse { keys.push_back(at4); return torsionTypeCont_.find(keys); } - + + InversionType* ForceField::getExactInversionType(const std::string &at1, + const std::string &at2, + const std::string &at3, + const std::string &at4){ + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + keys.push_back(at4); + return inversionTypeCont_.find(keys); + } + NonBondedInteractionType* ForceField::getExactNonBondedInteractionType(const std::string &at1, const std::string &at2){ std::vector keys; keys.push_back(at1); keys.push_back(at2); return nonBondedInteractionTypeCont_.find(keys); } + - bool ForceField::addAtomType(const std::string &at, AtomType* atomType) { std::vector keys; keys.push_back(at); @@ -435,6 +547,19 @@ namespace oopse { return torsionTypeCont_.add(keys, torsionType); } + bool ForceField::addInversionType(const std::string &at1, + const std::string &at2, + const std::string &at3, + const std::string &at4, + InversionType* inversionType) { + std::vector keys; + keys.push_back(at1); + keys.push_back(at2); + keys.push_back(at3); + keys.push_back(at4); + return inversionTypeCont_.add(keys, inversionType); + } + bool ForceField::addNonBondedInteractionType(const std::string &at1, const std::string &at2, NonBondedInteractionType* nbiType) {