]> git.donarmstrong.com Git - mothur.git/blobdiff - chao1.cpp
changed random forest output filename
[mothur.git] / chao1.cpp
index c05bdef2b7179a01f722cf497ab67f5b72ed7e3c..ad1faa242b81c1520d29fb6395fa5f5825d179ec 100644 (file)
--- a/chao1.cpp
+++ b/chao1.cpp
@@ -15,11 +15,21 @@ EstOutput Chao1::getValues(SAbundVector* rank){
                data.resize(3,0);
        
                double sobs = (double)rank->getNumBins();
-       
-               double singles = (double)rank->get(1);
-               double doubles = (double)rank->get(2);
+               
+               //this is a modification do to a vector fill error that occurs when an empty sharedRabund creates a sabund
+               //in that case there is no 1 0r 2.
+               double singles;
+               if (rank->size() > 1) {
+                       singles = (double)rank->get(1);
+               }else{ singles = 0.0;  }
+
+               double doubles;
+               if (rank->size() > 2) {
+                        doubles = (double)rank->get(2);
+               }else{ doubles = 0.0;  }
+
                double chaovar = 0.0000;
-       
+//cout << "singles = " << singles << " doubles = " << doubles << " sobs = " << sobs << endl;   
                double chao = sobs + singles*(singles-1)/(2*(doubles+1));
        
                if(singles > 0 && doubles > 0){
@@ -60,13 +70,9 @@ EstOutput Chao1::getValues(SAbundVector* rank){
                return data;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Chao1 class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "Chao1", "getValues");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Chao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-};
+}
 
 /***********************************************************************/