]> git.donarmstrong.com Git - mothur.git/blobdiff - inputdata.cpp
created mothurOut class to handle logfiles
[mothur.git] / inputdata.cpp
index c2f4e4e63347ce62b818617fd4e05da629a84972..8e54ab787c683535dd132caf0881aab3399945b9 100644 (file)
@@ -15,7 +15,7 @@
 /***********************************************************************/
 
 InputData::InputData(string fName, string f) : format(f){
-       
+       m = MothurOut::getInstance();
        openInputFile(fName, fileHandle);
        filename = fName;
        
@@ -34,7 +34,7 @@ InputData::~InputData(){
 
 InputData::InputData(string fName, string orderFileName, string f) : format(f){
        try {
-               
+               m = MothurOut::getInstance();
                ifstream ofHandle;
                openInputFile(orderFileName, ofHandle);
                string name;
@@ -52,13 +52,9 @@ InputData::InputData(string fName, string orderFileName, string f) : format(f){
                openInputFile(fName, fileHandle);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "InputData");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function InputData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -67,7 +63,7 @@ ListVector* InputData::getListVector(){
                if(fileHandle){
                        if(format == "list") {
                                list = new ListVector(fileHandle);
-                       }
+                       }else{ list = NULL;  }
                                        
                        gobble(fileHandle);
                        return list;
@@ -77,13 +73,9 @@ ListVector* InputData::getListVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -109,7 +101,7 @@ ListVector* InputData::getListVector(string label){
                                        else {  delete list;    }
                                        gobble(in);
                                }
-                       }
+                       }else{ list = NULL;  }
                        
                        in.close();
                        return list;
@@ -119,13 +111,9 @@ ListVector* InputData::getListVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -136,7 +124,7 @@ SharedListVector* InputData::getSharedListVector(){
                if(fileHandle){
                        if (format == "shared")  {
                                SharedList = new SharedListVector(fileHandle);
-                       }
+                       }else{ SharedList = NULL;  }
                                        
                        gobble(fileHandle);
                        return SharedList;
@@ -146,13 +134,9 @@ SharedListVector* InputData::getSharedListVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -178,7 +162,7 @@ SharedListVector* InputData::getSharedListVector(string label){
                                        gobble(in);
                                }
 
-                       }
+                       }else{ SharedList = NULL;  }
                                
                        in.close();
                        return SharedList;
@@ -188,13 +172,9 @@ SharedListVector* InputData::getSharedListVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedListVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -206,7 +186,7 @@ SharedOrderVector* InputData::getSharedOrderVector(){
                if(fileHandle){
                        if (format == "sharedfile")  {
                                SharedOrder = new SharedOrderVector(fileHandle);
-                       }
+                       }else{ SharedOrder = NULL;  }
                                
                        gobble(fileHandle);
                        return SharedOrder;
@@ -216,13 +196,9 @@ SharedOrderVector* InputData::getSharedOrderVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -249,7 +225,7 @@ SharedOrderVector* InputData::getSharedOrderVector(string label){
                                        gobble(in);
                                }
 
-                       }
+                       }else{ SharedOrder = NULL;  }
                                
                        in.close();
                        return SharedOrder;
@@ -259,13 +235,9 @@ SharedOrderVector* InputData::getSharedOrderVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -290,11 +262,12 @@ OrderVector* InputData::getOrderVector(){
                        else if(format == "sabund"){
                                input = new SAbundVector(fileHandle);
                        }
-                                       
+                       
                        gobble(fileHandle);
-                       output = new OrderVector();
-                       *output = (input->getOrderVector());
                        
+                       output = new OrderVector();     
+                       *output = (input->getOrderVector());
+               
                        return output;
                }
                else{
@@ -302,13 +275,9 @@ OrderVector* InputData::getOrderVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -409,13 +378,9 @@ OrderVector* InputData::getOrderVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -443,13 +408,9 @@ vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedRAbundVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
@@ -505,13 +466,9 @@ vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSharedRAbundVectors");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -548,13 +505,9 @@ SAbundVector* InputData::getSAbundVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 SAbundVector* InputData::getSAbundVector(string label){
@@ -654,13 +607,9 @@ SAbundVector* InputData::getSAbundVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -695,13 +644,9 @@ RAbundVector* InputData::getRAbundVector(){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 RAbundVector* InputData::getRAbundVector(string label){
@@ -800,13 +745,9 @@ RAbundVector* InputData::getRAbundVector(string label){
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "InputData", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/