]> git.donarmstrong.com Git - mothur.git/blobdiff - kruskalwalliscommand.cpp
Merge branch 'master' of https://github.com/mothur/mothur.git into development
[mothur.git] / kruskalwalliscommand.cpp
index 9064f49c747081ddde6c23edd82afbed8b83d6fe..dd5eb09cbd3b54fb439d277cbd166f01dc726f84 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Created on June 26, 2012, 11:06 AM
  */
+
 #include "kruskalwalliscommand.h"
 
 //**********************************************************************************************************************
@@ -123,17 +124,36 @@ int KruskalWallisCommand::execute(){
        try {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
         
+        InputData* input = new InputData(sharedfile, "sharedfile");
+        vector<SharedRAbundVector*> 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<string> processedLabels;
+               set<string> 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 = m->getNumGroups();
         double H;
         double tmp = 0.0;
         vector<groupRank> vec;
+        vector<string> groups = m->getGroups();
         string group;
         int count;
         double sum;
                 
         //merge all groups into a vector
+        
+        
+        
         //rank function here
         assignRank(vec);
         
@@ -141,7 +161,7 @@ int KruskalWallisCommand::execute(){
         for (int i=0;i<N;i++) {
             count = 0;
             sum = 0;
-            //group = next group
+            group = groups[i];
             for(int j;j<vec.size();j++) {
                 if (vec[j].group == group) {
                     count++;
@@ -186,22 +206,26 @@ void KruskalWallisCommand::assignRank(vector<groupRank> &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) {
@@ -211,7 +235,9 @@ void KruskalWallisCommand::assignRank(vector<groupRank> &vec) {
     
 }
 //**********************************************************************************************************************
-
+void KruskalWallisCommand::assignValue(vector<groupRank> &vec) {
+    
+}
 //**********************************************************************************************************************
 //**********************************************************************************************************************
 //**********************************************************************************************************************
\ No newline at end of file