345 |
|
} |
346 |
|
} |
347 |
|
} |
348 |
+ |
|
349 |
+ |
InversionType* ForceField::getInversionType(const std::string &at1, |
350 |
+ |
const std::string &at2, |
351 |
+ |
const std::string &at3, |
352 |
+ |
const std::string &at4) { |
353 |
+ |
std::vector<std::string> keys; |
354 |
+ |
keys.push_back(at1); |
355 |
+ |
keys.push_back(at2); |
356 |
+ |
keys.push_back(at3); |
357 |
+ |
keys.push_back(at4); |
358 |
|
|
359 |
+ |
//try exact match first |
360 |
+ |
InversionType* inversionType = inversionTypeCont_.find(keys); |
361 |
+ |
if (inversionType) { |
362 |
+ |
return inversionType; |
363 |
+ |
} else { |
364 |
+ |
|
365 |
+ |
AtomType* atype1; |
366 |
+ |
AtomType* atype2; |
367 |
+ |
AtomType* atype3; |
368 |
+ |
AtomType* atype4; |
369 |
+ |
std::vector<std::string> at1key; |
370 |
+ |
at1key.push_back(at1); |
371 |
+ |
atype1 = atomTypeCont_.find(at1key); |
372 |
+ |
|
373 |
+ |
std::vector<std::string> at2key; |
374 |
+ |
at2key.push_back(at2); |
375 |
+ |
atype2 = atomTypeCont_.find(at2key); |
376 |
+ |
|
377 |
+ |
std::vector<std::string> at3key; |
378 |
+ |
at3key.push_back(at3); |
379 |
+ |
atype3 = atomTypeCont_.find(at3key); |
380 |
+ |
|
381 |
+ |
std::vector<std::string> at4key; |
382 |
+ |
at4key.push_back(at4); |
383 |
+ |
atype4 = atomTypeCont_.find(at4key); |
384 |
+ |
|
385 |
+ |
// query atom types for their chains of responsibility |
386 |
+ |
std::vector<AtomType*> at1Chain = atype1->allYourBase(); |
387 |
+ |
std::vector<AtomType*> at2Chain = atype2->allYourBase(); |
388 |
+ |
std::vector<AtomType*> at3Chain = atype3->allYourBase(); |
389 |
+ |
std::vector<AtomType*> at4Chain = atype4->allYourBase(); |
390 |
+ |
|
391 |
+ |
std::vector<AtomType*>::iterator i; |
392 |
+ |
std::vector<AtomType*>::iterator j; |
393 |
+ |
std::vector<AtomType*>::iterator k; |
394 |
+ |
std::vector<AtomType*>::iterator l; |
395 |
+ |
|
396 |
+ |
int ii = 0; |
397 |
+ |
int jj = 0; |
398 |
+ |
int kk = 0; |
399 |
+ |
int ll = 0; |
400 |
+ |
int Iscore; |
401 |
+ |
int JKLscore; |
402 |
+ |
|
403 |
+ |
std::vector<tuple3<int, int, std::vector<std::string> > > foundInversions; |
404 |
+ |
|
405 |
+ |
for (j = at2Chain.begin(); j != at2Chain.end(); j++) { |
406 |
+ |
kk = 0; |
407 |
+ |
for (k = at3Chain.begin(); k != at3Chain.end(); k++) { |
408 |
+ |
ii = 0; |
409 |
+ |
for (i = at1Chain.begin(); i != at1Chain.end(); i++) { |
410 |
+ |
ll = 0; |
411 |
+ |
for (l = at4Chain.begin(); l != at4Chain.end(); l++) { |
412 |
+ |
|
413 |
+ |
Iscore = ii; |
414 |
+ |
JKLscore = jj + kk + ll; |
415 |
+ |
|
416 |
+ |
std::vector<std::string> myKeys; |
417 |
+ |
myKeys.push_back((*i)->getName()); |
418 |
+ |
myKeys.push_back((*j)->getName()); |
419 |
+ |
myKeys.push_back((*k)->getName()); |
420 |
+ |
myKeys.push_back((*l)->getName()); |
421 |
+ |
|
422 |
+ |
InversionType* inversionType = inversionTypeCont_.find(myKeys); |
423 |
+ |
if (inversionType) { |
424 |
+ |
foundInversions.push_back( make_tuple3(Iscore, JKLscore, myKeys) ); |
425 |
+ |
} |
426 |
+ |
ll++; |
427 |
+ |
} |
428 |
+ |
ii++; |
429 |
+ |
} |
430 |
+ |
kk++; |
431 |
+ |
} |
432 |
+ |
jj++; |
433 |
+ |
} |
434 |
+ |
|
435 |
+ |
std::sort(foundInversions.begin(), foundInversions.end()); |
436 |
+ |
|
437 |
+ |
int iscore = foundInversions[0].first; |
438 |
+ |
int jklscore = foundInversions[0].second; |
439 |
+ |
std::vector<std::string> theKeys = foundInversions[0].third; |
440 |
+ |
|
441 |
+ |
std::cout << "best matching inversion = " << theKeys[0] << "\t" <<theKeys[1] << "\t" << theKeys[2] << "\t" << theKeys[3] << "\t(scores = "<< iscore << "\t" << jklscore << ")\n"; |
442 |
+ |
|
443 |
+ |
|
444 |
+ |
InversionType* bestType = inversionTypeCont_.find(theKeys); |
445 |
+ |
if (bestType) { |
446 |
+ |
return bestType; |
447 |
+ |
} else { |
448 |
+ |
//if no exact match found, try wild card match |
449 |
+ |
return inversionTypeCont_.find(keys, wildCardAtomTypeName_); |
450 |
+ |
} |
451 |
+ |
} |
452 |
+ |
} |
453 |
+ |
|
454 |
|
NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) { |
455 |
|
std::vector<std::string> keys; |
456 |
|
keys.push_back(at1); |
495 |
|
keys.push_back(at4); |
496 |
|
return torsionTypeCont_.find(keys); |
497 |
|
} |
498 |
< |
|
498 |
> |
|
499 |
> |
InversionType* ForceField::getExactInversionType(const std::string &at1, |
500 |
> |
const std::string &at2, |
501 |
> |
const std::string &at3, |
502 |
> |
const std::string &at4){ |
503 |
> |
std::vector<std::string> keys; |
504 |
> |
keys.push_back(at1); |
505 |
> |
keys.push_back(at2); |
506 |
> |
keys.push_back(at3); |
507 |
> |
keys.push_back(at4); |
508 |
> |
return inversionTypeCont_.find(keys); |
509 |
> |
} |
510 |
> |
|
511 |
|
NonBondedInteractionType* ForceField::getExactNonBondedInteractionType(const std::string &at1, const std::string &at2){ |
512 |
|
std::vector<std::string> keys; |
513 |
|
keys.push_back(at1); |
514 |
|
keys.push_back(at2); |
515 |
|
return nonBondedInteractionTypeCont_.find(keys); |
516 |
|
} |
517 |
+ |
|
518 |
|
|
401 |
– |
|
519 |
|
bool ForceField::addAtomType(const std::string &at, AtomType* atomType) { |
520 |
|
std::vector<std::string> keys; |
521 |
|
keys.push_back(at); |
552 |
|
return torsionTypeCont_.add(keys, torsionType); |
553 |
|
} |
554 |
|
|
555 |
+ |
bool ForceField::addInversionType(const std::string &at1, |
556 |
+ |
const std::string &at2, |
557 |
+ |
const std::string &at3, |
558 |
+ |
const std::string &at4, |
559 |
+ |
InversionType* inversionType) { |
560 |
+ |
std::vector<std::string> keys; |
561 |
+ |
keys.push_back(at1); |
562 |
+ |
keys.push_back(at2); |
563 |
+ |
keys.push_back(at3); |
564 |
+ |
keys.push_back(at4); |
565 |
+ |
return inversionTypeCont_.add(keys, inversionType); |
566 |
+ |
} |
567 |
+ |
|
568 |
|
bool ForceField::addNonBondedInteractionType(const std::string &at1, |
569 |
|
const std::string &at2, |
570 |
|
NonBondedInteractionType* nbiType) { |