1 /** 2 * Author: Mark Larkin 3 * 4 * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson. 5 */ 6 /** 7 * Changes: 8 * Mark 10-5-2007: Bug fix # 42. Added getWeightsForQtLowScore function. 9 * 10 * 11 */ 12 #ifndef TREEINTERFACE_H 13 #define TREEINTERFACE_H 14 15 #include <vector> 16 #include <string> 17 #include <memory> 18 #include "AlignmentSteps.h" 19 #include "../alignment/Alignment.h" 20 #include "../general/clustalw.h" 21 22 namespace clustalw 23 { 24 25 using namespace std; 26 class Tree; 27 class RootedGuideTree; 28 29 class TreeInterface 30 { 31 public: 32 /** 33 * This function will be used to generate the phylogenetic tree from the distMat using 34 * either UPGMA or NJ. It will then calculate the seqWeights and the steps. 35 * Note the Distmat 36 * will be in similarity form after this. It will no longer be distances!!!!! 37 */ 38 auto_ptr<AlignmentSteps> getWeightsAndStepsFromDistMat(vector<int>* seqWeights, 39 DistMatrix* distMat, 40 Alignment *alignPtr, 41 int seq1, int nSeqs, 42 string* phylipName, bool* success); 43 /** 44 * This will be called by sequencesAlignToProfile and QTcalcWeightsForLowScoreSeg 45 */ 46 void getWeightsFromDistMat(vector<int>* seqWeights, DistMatrix* distMat, 47 Alignment *alignPtr, int seq1, int nSeqs, 48 string* phylipName, bool* success); 49 50 void getWeightsForQtLowScore(vector<int>* seqWeights, DistMatrix* distMat, 51 Alignment *alignPtr, int seq1, int nSeqs, 52 string* phylipName, bool* success); 53 54 /** 55 * This function will be called from doAlignUseOldTree 56 */ 57 auto_ptr<AlignmentSteps> getWeightsAndStepsFromTree(Alignment* alignPtr, 58 DistMatrix* distMat, string* treeName, 59 vector<int>* seqWeights, int fSeq, 60 int numSeqs, bool* success); 61 62 /** 63 * This function will be called from sequencesAlignToProfile, it doesnt calc the 64 * steps. 65 */ 66 int getWeightsFromGuideTree(Alignment* alignPtr, DistMatrix* distMat, 67 string* treeName, vector<int>* seqWeights, int fSeq, 68 int nSeqs, bool* success); 69 /** 70 * This function is used to generate 2 guide trees for the profile align part. 71 * IT must be done on its own. It calls calcPairwiseForProfileAlign in MSA. 72 * It is called by profileAlign and removeFirstIterate. 73 */ 74 void getWeightsForProfileAlign(Alignment* alignPtr, DistMatrix* distMat, 75 string* p1TreeName, vector<int>* p1Weights, string* p2TreeName, 76 vector<int>* p2Weights, int numSeqs, int profile1NumSeqs, bool useTree1, 77 bool useTree2, bool* success); 78 /** 79 * This function is used to generate the guide tree from the distance matrix. 80 * It doesnt return 81 * any seqWeights or AlignmentSteps. It will be used by doGuideTreeOnly 82 */ 83 void generateTreeFromDistMat(DistMatrix* distMat, Alignment *alignPtr, 84 int seq1, int nSeqs, 85 string* phylipName, bool* success); 86 87 /** 88 * This function is to simply to call either the UPGMA or NJ version of 89 * this function, and print out all the trees. It will be called 90 * from phylogeneticTree in the clustal class. 91 */ 92 void treeFromAlignment(TreeNames* treeNames, Alignment *alignPtr); 93 94 /** 95 * This function will be used to bootstrap the tree and output the results. 96 * It will use either 97 * UPGMA or NJ for the bootstrapping, depending on what is selected. 98 */ 99 void bootstrapTree(TreeNames* treeNames, Alignment *alignPtr); 100 101 private: 102 auto_ptr<AlignmentSteps> getWeightsAndStepsFromDistMatNJ(vector<int>* seqWeights, 103 DistMatrix* distMat, 104 Alignment *alignPtr, 105 int seq1, int nSeqs, 106 string* phylipName, bool* success); 107 108 auto_ptr<AlignmentSteps> getWeightsAndStepsUseOldGuideTreeNJ(DistMatrix* distMat, 109 Alignment *alignPtr, string* treeName, 110 vector<int>* seqWeights, 111 int fSeq, int nSeqs, bool* success); 112 113 int readTreeAndCalcWeightsNJ(Tree* groupTree, Alignment* alignPtr, 114 DistMatrix* distMat, string* treeName, vector<int>* seqWeights, 115 int fSeq, int nSeqs); 116 117 int getWeightsFromGuideTreeNJ(Alignment* alignPtr, DistMatrix* distMat, 118 string* treeName, vector<int>* seqWeights, int fSeq, 119 int nSeqs, bool* success); 120 121 void getWeightsFromDistMatNJ(vector<int>* seqWeights, DistMatrix* distMat, 122 Alignment *alignPtr, int seq1, int nSeqs, 123 string* phylipName, bool* success); 124 125 void getWeightsForProfileAlignNJ(Alignment* alignPtr, DistMatrix* distMat, 126 string* p1TreeName, vector<int>* p1Weights, string* p2TreeName, 127 vector<int>* p2Weights, int numSeqs, int profile1NumSeqs, bool useTree1, 128 bool useTree2, bool* success); 129 130 void generateTreeFromDistMatNJ(DistMatrix* distMat, Alignment *alignPtr, 131 int seq1, int nSeqs, string* phylipName, bool* success); 132 133 auto_ptr<AlignmentSteps> getWeightsAndStepsFromTreeNJ(Alignment* alignPtr, 134 DistMatrix* distMat, string* treeName, 135 vector<int>* seqWeights, int fSeq, int numSeqs, bool* success); 136 137 /** UPGMA functions */ 138 auto_ptr<AlignmentSteps> getWeightsAndStepsFromDistMatUPGMA(vector<int>* seqWeights, 139 DistMatrix* distMat, Alignment *alignPtr, 140 int seq1, int nSeqs, string* phylipName, bool* success); 141 142 auto_ptr<AlignmentSteps> generateTreeFromDistMatUPGMA(RootedGuideTree* guideTree, 143 DistMatrix* distMat, Alignment *alignPtr, int seq1, int nSeqs, 144 string* phylipName, bool* success); 145 146 void getWeightsFromDistMatUPGMA(vector<int>* seqWeights, DistMatrix* distMat, 147 Alignment *alignPtr, int seq1, int nSeqs, 148 string* phylipName, bool* success); 149 150 void getWeightsForProfileAlignUPGMA(Alignment* alignPtr, DistMatrix* distMat, 151 string* p1TreeName, vector<int>* p1Weights, string* p2TreeName, 152 vector<int>* p2Weights, int numSeqs, int profile1NumSeqs, bool useTree1, 153 bool useTree2, bool* success); 154 }; 155 } 156 #endif 157