]> git.donarmstrong.com Git - mothur.git/blobdiff - cooccurrencecommand.cpp
fixed segfault in unifrac with subsample. in progress of implementing a version of...
[mothur.git] / cooccurrencecommand.cpp
index f0a46aaf9dfc0a729df15549a7d8fecc4c02d52a..75b87fae4303f161a1f75fb632e831672a80e29d 100644 (file)
@@ -318,7 +318,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             }
         }
         //don't need a prob matrix because we just shuffle the rows, may use this in the future
-//        else if (matrix == "sim2") {
+        else if (matrix == "sim2") { }
 //            for(int i=0;i<nrows;i++) {
 //                start = 0.0;
 //                for(int j=0;j<ncols;j++) {
@@ -420,6 +420,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             if(matrix == "sim1" || matrix == "sim6" || matrix == "sim8" || matrix == "sim7") {
                 count = 0;
                 while(count < n) {
+                    if (m->control_pressed) { return 0; }
                 nextnum2:
                     previous = 0.0;
                     randnum = rand() / double(RAND_MAX);
@@ -453,6 +454,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
                     count = 0;
                     while(count < rowtotal[i]) {
                         previous = 0.0;
+                        if (m->control_pressed) { return 0; }
                         randnum = rand() / double(RAND_MAX);
                         for(int j=0;j<ncols;j++) {
                             current = probabilityMatrix[ncols * i + j];
@@ -473,6 +475,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
                 for(int j=0;j<ncols;j++) {
                     count = 0;
                     while(count < columntotal[j]) {
+                        if (m->control_pressed) { return 0; }
                         randnum = rand() / double(RAND_MAX);
                         for(int i=0;i<nrows;i++) {
                             current = probabilityMatrix[ncols * i + j];
@@ -491,6 +494,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             //swap_checkerboards takes the original matrix and swaps checkerboards
             else if(matrix == "sim9") {
                 trial.swap_checkerboards (co_matrix, ncols, nrows);
+                nullmatrix = co_matrix;
             }
             else {
                 m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true;