bool OpConformer::Do(OBBase* pOb, const char* OptionText, OpMap* pmap, OBConversion*) { OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(!pmol) return false; pmol->AddHydrogens(false, false); OpMap::const_iterator iter; bool log = false; bool systematic = false; bool random = false; bool weighted = false; int numConformers = 30; iter = pmap->find("log"); if(iter!=pmap->end()) log=true; iter = pmap->find("nconf"); if(iter!=pmap->end()) getInteger(iter->second, numConformers); iter = pmap->find("systematic"); if(iter!=pmap->end()) systematic = true; iter = pmap->find("random"); if(iter!=pmap->end()) random = true; iter = pmap->find("weighted"); if(iter!=pmap->end()) weighted = true; if (systematic || random || weighted) { std::string ff = "MMFF94"; iter = pmap->find("ff"); if(iter!=pmap->end()) ff = iter->second; OBForceField* pFF = OBForceField::FindForceField(ff); // set some force field variables pFF->SetLogFile(&clog); pFF->SetLogLevel(log ? OBFF_LOGLVL_MEDIUM : OBFF_LOGLVL_NONE); if (!pFF->Setup(*pmol)) { cerr << "Could not setup force field." << endl; return false; } } else { int numChildren = 5; int mutability = 5; int convergence = 25; std::string score = "rmsd"; iter = pmap->find("children"); if(iter!=pmap->end()) getInteger(iter->second, numChildren); iter = pmap->find("mutability"); if(iter!=pmap->end()) getInteger(iter->second, mutability); iter = pmap->find("convergence"); if(iter!=pmap->end()) getInteger(iter->second, convergence); iter = pmap->find("score"); if(iter!=pmap->end()) score = iter->second; OBConformerSearch cs; if (score == "energy") cs.SetScore(new OBEnergyConformerScore); if (cs.Setup(*pmol, numConformers, numChildren, mutability, convergence)) { cs.Search(); cs.GetConformers(*pmol); } } return true; }
bool OpConformer::Do(OBBase* pOb, const char* OptionText, OpMap* pmap, OBConversion*) { OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(!pmol) return false; pmol->AddHydrogens(false, false); OpMap::const_iterator iter; bool log = false; bool systematic = false; bool random = false; bool weighted = false; bool fast = false; int numConformers = 30; iter = pmap->find("log"); if(iter!=pmap->end()) log=true; iter = pmap->find("nconf"); if(iter!=pmap->end()) getInteger(iter->second, numConformers); iter = pmap->find("systematic"); if(iter!=pmap->end()) systematic = true; iter = pmap->find("random"); if(iter!=pmap->end()) random = true; iter = pmap->find("fast"); if(iter!=pmap->end()) fast = true; iter = pmap->find("weighted"); if(iter!=pmap->end()) weighted = true; if (systematic || random || fast || weighted) { std::string ff = "MMFF94"; iter = pmap->find("ff"); if(iter!=pmap->end()) ff = iter->second; OBForceField* pFF = OBForceField::FindForceField(ff); // set some force field variables pFF->SetLogFile(&clog); pFF->SetLogLevel(log ? OBFF_LOGLVL_MEDIUM : OBFF_LOGLVL_NONE); // Add cut-offs for faster conformer searching // Generally people will perform further optimization on a final conformer pFF->EnableCutOff(true); pFF->SetVDWCutOff(10.0); pFF->SetElectrostaticCutOff(20.0); pFF->SetUpdateFrequency(10); // delay updates of non-bonded distances if (!pFF->Setup(*pmol)) { cerr << "Could not setup force field." << endl; return false; } // Perform search if (systematic) { pFF->SystematicRotorSearch(10); // 10 steepest-descent forcfield steps per conformer } else if (fast) { pFF->FastRotorSearch(true); // permute rotors } else if (random) { pFF->RandomRotorSearch(numConformers, 10); } else if (weighted) { pFF->WeightedRotorSearch(numConformers, 10); } pFF->GetConformers(*pmol); } else { // GA-based searching int numChildren = 5; int mutability = 5; int convergence = 5; std::string score = "rmsd"; iter = pmap->find("children"); if(iter!=pmap->end()) getInteger(iter->second, numChildren); iter = pmap->find("mutability"); if(iter!=pmap->end()) getInteger(iter->second, mutability); iter = pmap->find("convergence"); if(iter!=pmap->end()) getInteger(iter->second, convergence); iter = pmap->find("score"); if(iter!=pmap->end()) score = iter->second; OBConformerSearch cs; if (score == "energy") cs.SetScore(new OBEnergyConformerScore); else if (score == "mine" || score == "minenergy") cs.SetScore(new OBMinimizingEnergyConformerScore); else if (score == "minr" || score == "minrmsd") cs.SetScore(new OBMinimizingRMSDConformerScore); if (cs.Setup(*pmol, numConformers, numChildren, mutability, convergence)) { cs.Search(); cs.GetConformers(*pmol); } } return true; }