]> git.donarmstrong.com Git - mothur.git/blobdiff - cooccurrencecommand.cpp
Revert to previous commit
[mothur.git] / cooccurrencecommand.cpp
index 45bc0f58dd9cbf5fbcb32a7038fde29fb749551d..75b87fae4303f161a1f75fb632e831672a80e29d 100644 (file)
@@ -385,7 +385,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
                 }
             }
         }
-        else if (matrix == "sim9") { }
+        else if (matrix == "sim9" || matrix == "sim2") { }
         else {
             m->mothurOut("[ERROR]: No model selected! \n");
             m->control_pressed = true;
@@ -408,11 +408,11 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
 
         //burn-in for sim9    
         if(matrix == "sim9") {
-            for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, rowtotal, columntotal, ncols, nrows);
+            for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, ncols, nrows);
         }
 
         //populate null matrix from probability matrix, do this a lot.
-        for(int h=0;h<runs;h++){
+        for(int k=0;k<runs;k++){
             nullmatrix.clear();
             //zero-fill the null matrix
             nullmatrix.assign(nrows, vector<int>(ncols, 0));
@@ -451,7 +451,6 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             
             else if(matrix == "sim4") {
                 for(int i=0;i<nrows;i++) {
-                    previous = 0.0;
                     count = 0;
                     while(count < rowtotal[i]) {
                         previous = 0.0;
@@ -459,7 +458,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
                         randnum = rand() / double(RAND_MAX);
                         for(int j=0;j<ncols;j++) {
                             current = probabilityMatrix[ncols * i + j];
-                            if((randnum <= current && randnum > previous && nullmatrix[i][j] != 1) || (previous==current)){
+                            if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
                                 nullmatrix[i][j] = 1;
                                 count++;
                                 previous = 0.0;
@@ -494,7 +493,8 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             
             //swap_checkerboards takes the original matrix and swaps checkerboards
             else if(matrix == "sim9") {
-                trial.swap_checkerboards (co_matrix, rowtotal, columntotal, ncols, nrows);
+                trial.swap_checkerboards (co_matrix, ncols, nrows);
+                nullmatrix = co_matrix;
             }
             else {
                 m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true;