// $Id: semphySearchBestTree.cpp 6002 2009-03-20 19:39:03Z privmane $ #include "semphySearchBestTree.h" #include "bestAlpha.h" #include "uniDistribution.h" #include "aaJC.h" #include "nucJC.h" #include "pijAccelerator.h" #include "trivialAccelerator.h" #include "chebyshevAccelerator.h" #include "stochasticProcess.h" #include "nucleotide.h" #include "amino.h" #include "sequenceContainer.h" #include "phylipFormat.h" #include "maseFormat.h" #include "fastaFormat.h" #include "tree.h" #include "likelihoodComputation.h" #include "computePijComponent.h" #include "seqContainerTreeMap.h" #include "gammaDistribution.h" #include "bblEM.h" #include "NNiProp.h" #include "NNiSep.h" #include "jcDistance.h" #include "distanceTable.h" #include "nj.h" #include "semphyStep.h" #include "computeUpAlg.h" #include "computeDownAlg.h" #include "computeMarginalAlg.h" #include "logFile.h" #include "getRandomWeights.h" #include "treeUtil.h" #include "bestTamura92param.h" #include "bestGtrModelParams.h" using namespace std; using namespace likelihoodComputation; //HERE IS THE MAIN CODE FOR THE SEMPHY SEARCH //THINGS TO TAKE INTO ACCOUNT: //(1) Several starting point //(2) Tmp handling for semphy-ratchet and semphy-anneal. semphySearchBestTree::semphySearchBestTree(sequenceContainer& sc, tree& startTree, const tree* constraintTree, stochasticProcess& sp, ostream& out, const int numOfRandomStart, const bool optimizeAlpha, const double epsilonLikelihoodImprovement4alphaOptimiz, const double epsilonLikelihoodImprovement4BBL, const int maxIterationsBBL, const Vdouble * weights) { if (numOfRandomStart == 1) { semphyBasicSearchBestTree(sc,startTree,constraintTree,sp,out, optimizeAlpha, epsilonLikelihoodImprovement4alphaOptimiz,epsilonLikelihoodImprovement4BBL,maxIterationsBBL, weights); } else { semphyBasicSearchBestTreeManyRandomStarts(sc,startTree,constraintTree,sp,out,numOfRandomStart, optimizeAlpha, epsilonLikelihoodImprovement4alphaOptimiz,epsilonLikelihoodImprovement4BBL,maxIterationsBBL, weights); } } MDOUBLE semphySearchBestTree::semphyBasicSearchBestTreeManyRandomStarts( sequenceContainer& sc, tree& et, const tree* ctPtr, stochasticProcess& sp, ostream& out, const int nRanStart, const bool optimizeAlpha, const double epsilonLikelihoodImprovement4alphaOptimiz, const double epsilonLikelihoodImprovement4BBL, const int maxIterationsBBL, const Vdouble * weights) { MDOUBLE bestL = semphyBasicSearchBestTree(sc,et,ctPtr,sp,optimizeAlpha, epsilonLikelihoodImprovement4alphaOptimiz,epsilonLikelihoodImprovement4BBL,maxIterationsBBL, weights); tree bestT = et; const MDOUBLE tmpForStartingTreeSearch = 0.1; // PUT IN THE OPTION FILE IF PROVE TO BE USEFULL... for (int it=0; it < nRanStart; ++it) { LOG(3,<<"\n\n\n================================================================================================================\n\n\n"< vNames; giveDistanceTable(&pd1, sc, disTab, vNames, &startingTreeWeights); NJalg nj1; et = nj1.computeTree(disTab,vNames); LOG(3,<<"starting random tree for this semphy iteration "< bestL) { LOG(3,<<" new best tree: score = "<