X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=treegroupscommand.cpp;h=6633e5160559297c23a542c373ed1b1cc9a3ccdc;hb=5a4ac4f954c4b4445bcee272f1f8220ddcc9c1e4;hp=888f50202e3443855a99d82d71b126cf715ee380;hpb=49d2b7459c5027557564b21e9487dadafbbbdc96;p=mothur.git diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 888f502..6633e51 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -286,7 +286,7 @@ TreeGroupCommand::TreeGroupCommand(string option) { TreeGroupCommand::~TreeGroupCommand(){ if (abort == false) { if (format == "sharedfile") { delete input; } - else { delete readMatrix; delete matrix; delete list; } + else { delete list; } delete tmap; } @@ -418,7 +418,8 @@ int TreeGroupCommand::execute(){ }else{ //read in dist file filename = inputfile; - + + ReadMatrix* readMatrix; if (format == "column") { readMatrix = new ReadColumnMatrix(filename); } else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(filename); } @@ -434,7 +435,7 @@ int TreeGroupCommand::execute(){ readMatrix->read(nameMap); list = readMatrix->getListVector(); - matrix = readMatrix->getMatrix(); + SparseDistanceMatrix* dMatrix = readMatrix->getDMatrix(); //make treemap tmap = new TreeMap(); @@ -457,7 +458,9 @@ int TreeGroupCommand::execute(){ if (m->control_pressed) { return 0; } - vector< vector > matrix = makeSimsDist(); + vector< vector > matrix = makeSimsDist(dMatrix); + delete readMatrix; + delete dMatrix; if (m->control_pressed) { return 0; } @@ -554,7 +557,7 @@ void TreeGroupCommand::printSims(ostream& out, vector< vector >& simMatr } } /***********************************************************/ -vector< vector > TreeGroupCommand::makeSimsDist() { +vector< vector > TreeGroupCommand::makeSimsDist(SparseDistanceMatrix* matrix) { try { numGroups = list->size(); @@ -569,13 +572,17 @@ vector< vector > TreeGroupCommand::makeSimsDist() { //go through sparse matrix and fill sims //go through each cell in the sparsematrix - for(MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++){ - //similairity = -(distance-1) - simMatrix[currentCell->row][currentCell->column] = -(currentCell->dist -1.0); - simMatrix[currentCell->column][currentCell->row] = -(currentCell->dist -1.0); - - if (m->control_pressed) { return simMatrix; } + for (int i = 0; i < matrix->seqVec.size(); i++) { + for (int j = 0; j < matrix->seqVec[i].size(); j++) { + + //already checked everyone else in row + if (i < matrix->seqVec[i][j].index) { + simMatrix[i][matrix->seqVec[i][j].index] = -(matrix->seqVec[i][j].dist -1.0); + simMatrix[matrix->seqVec[i][j].index][i] = -(matrix->seqVec[i][j].dist -1.0); + if (m->control_pressed) { return simMatrix; } + } + } } return simMatrix;