X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kruskalwalliscommand.cpp;h=39afca8c8acb0228a60d18b8df4da9a23eb6adef;hb=d71a31a60542608595ce1278cc4a3398479cec7f;hp=9064f49c747081ddde6c23edd82afbed8b83d6fe;hpb=923d4c33e857c00142887f524741c06be537cb7e;p=mothur.git diff --git a/kruskalwalliscommand.cpp b/kruskalwalliscommand.cpp index 9064f49..39afca8 100644 --- a/kruskalwalliscommand.cpp +++ b/kruskalwalliscommand.cpp @@ -4,6 +4,7 @@ * * Created on June 26, 2012, 11:06 AM */ + #include "kruskalwalliscommand.h" //********************************************************************************************************************** @@ -123,9 +124,24 @@ int KruskalWallisCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } + InputData* input = new InputData(sharedfile, "sharedfile"); + vector lookup = input->getSharedRAbundVectors(); + string lastLabel = lookup[0]->getLabel(); + + //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. + set processedLabels; + set userLabels = labels; + + ofstream out; + string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary"); + m->openOutputFile(outputFileName, out); + outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName); + out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); + out << "H\tpvalue\n"; + //math goes here - int N; //= thisLookUp.size(); + int N = lookup.size(); double H; double tmp = 0.0; vector vec; @@ -186,22 +202,26 @@ void KruskalWallisCommand::assignRank(vector &vec) { while ( it != vec.end() ) { j = rank; oldit = it; - if (!equalvalue(*it, *it+1)) { *it->rank = rank; rank=rank+1; it++; } + if (!equalvalue(*it, *(it+1))) { + (*it).rank = rank; + rank = rank+1; + it++; } else { - while(equalrank(*it, *it+1)) { - j = j + (j+1.0); + while(equalrank(*it, *(it+1))) { + j = j + (j+1); rank++; it++; } numRanks = double (distance(oldit, it)); avgRank = j / numRanks; while(oldit != it) { - *oldit->rank = avgRank; + (*oldit).rank = avgRank; oldit++; } } } + } catch(exception& e) {