X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=indicatorcommand.cpp;h=8d1d7f7a6864b261a0a31611a1e02270730cfd32;hb=2c97dd48b8e27ee0a6a86c7a082f4c504c3357c6;hp=01d8c2e8634d65c31f11515f89ecfa950b81a1ae;hpb=43ed0accfbc2852849e104ff7eccdd2c42acd4ec;p=mothur.git diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index 01d8c2e..8d1d7f7 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -99,7 +99,6 @@ IndicatorCommand::IndicatorCommand(string option) { m->clearGroups(); m->clearAllGroups(); m->Treenames.clear(); - m->names.clear(); vector tempOutNames; outputTypes["tree"] = tempOutNames; @@ -236,13 +235,11 @@ int IndicatorCommand::execute(){ designMap->readDesignMap(); //fill Groups - checks for "all" and for any typo groups - SharedUtil* util = new SharedUtil(); + SharedUtil util; vector nameGroups = designMap->getNamesOfGroups(); - util->setGroups(Groups, nameGroups); + util.setGroups(Groups, nameGroups); designMap->setNamesOfGroups(nameGroups); - delete util; - //loop through the Groups and fill Globaldata's Groups with the design file info vector namesSeqs = designMap->getNamesSeqs(Groups); m->setGroups(namesSeqs); } @@ -320,8 +317,9 @@ int IndicatorCommand::execute(){ else { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } } for (int i = 0; i < T.size(); i++) { delete T[i]; } delete treeMap; return 0; } - - T[0]->assembleTree(); + + map nameMap; + T[0]->assembleTree(nameMap); /***************************************************/ // create ouptut tree - respecting pickedGroups // @@ -329,12 +327,11 @@ int IndicatorCommand::execute(){ Tree* outputTree = new Tree(m->getNumGroups(), treeMap); outputTree->getSubTree(T[0], m->getGroups()); - outputTree->assembleTree(); + outputTree->assembleTree(nameMap); //no longer need original tree, we have output tree to use and label for (int i = 0; i < T.size(); i++) { delete T[i]; } - if (m->control_pressed) { if (designfile != "") { delete designMap; } if (sharedfile != "") { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } @@ -470,17 +467,17 @@ int IndicatorCommand::GetIndicatorSpecies(){ if (m->control_pressed) { out.close(); return 0; } - out << (j+1) << '\t' << indicatorValues[j] << '\t'; + out << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; if (pValues[j] > (1/(float)iters)) { out << pValues[j] << endl; } else { out << "<" << (1/(float)iters) << endl; } if (pValues[j] <= 0.05) { - cout << "OTU" << j+1 << '\t' << indicatorValues[j] << '\t'; + cout << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; string pValueString = "<" + toString((1/(float)iters)); if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} else { cout << "<" << (1/(float)iters); } - m->mothurOutJustToLog("OTU" + toString(j+1) + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); + m->mothurOutJustToLog(m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); m->mothurOutEndLine(); } } @@ -516,7 +513,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ //print headings out << "TreeNode\t"; - for (int i = 0; i < numBins; i++) { out << "OTU" << (i+1) << "_IndValue" << '\t' << "pValue" << '\t'; } + for (int i = 0; i < numBins; i++) { out << m->currentBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; } out << endl; m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicatorValue\tpValue\n"); @@ -673,11 +670,11 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ } if (pValues[j] <= 0.05) { - cout << i+1 << "\tOTU" << j+1 << '\t' << indicatorValues[j] << '\t'; + cout << i+1 << '\t' << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; string pValueString = "<" + toString((1/(float)iters)); if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} else { cout << "<" << (1/(float)iters); } - m->mothurOutJustToLog(toString(i) + "\tOTU" + toString(j+1) + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); + m->mothurOutJustToLog(toString(i) + "\t" + m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); m->mothurOutEndLine(); } }