]> git.donarmstrong.com Git - mothur.git/commitdiff
changed how we do "smart" distancing
authorwestcott <westcott>
Tue, 23 Jun 2009 15:36:46 +0000 (15:36 +0000)
committerwestcott <westcott>
Tue, 23 Jun 2009 15:36:46 +0000 (15:36 +0000)
24 files changed:
binsequencecommand.cpp
bootstrapsharedcommand.cpp
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
getoturepcommand.cpp
getrabundcommand.cpp
getsabundcommand.cpp
getsabundcommand.h
heatmapcommand.cpp
heatmapsimcommand.cpp
inputdata.cpp
inputdata.h
matrixoutputcommand.cpp
rarefactcommand.cpp
rarefactsharedcommand.cpp
sharedcommand.cpp
sharedrabundvector.cpp
sharedrabundvector.h
summarycommand.cpp
summarysharedcommand.cpp
treegroupscommand.cpp
treegroupscommand.h
venncommand.cpp

index 0ae5d9e46f30fb777593223a5618beaf1ea7aad9..a291caae25782de3d9af111fc149011c77d72eea 100644 (file)
@@ -164,7 +164,7 @@ int BinSeqCommand::execute(){
                
                input = globaldata->ginput;
                list = globaldata->gListVector;
-               ListVector* lastList = list;
+               string lastLabel = list->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;
@@ -184,19 +184,21 @@ int BinSeqCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
+                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               delete list;
+                               list = input->getListVector(lastLabel);
                                
-                               error = process(lastList, count);       
+                               error = process(list, count);   
                                if (error == 1) { return 0; }
                                                                                                        
-                               processedLabels.insert(lastList->getLabel());
-                               userLabels.erase(lastList->getLabel());
+                               processedLabels.insert(list->getLabel());
+                               userLabels.erase(list->getLabel());
                                
                        }
                        
-                       if (count != 1) { delete lastList; }
-                       lastList = list;                        
-
+                       lastLabel = list->getLabel();                   
+                       
+                       delete list;
                        list = input->getListVector();
                        count++;
                }
@@ -207,21 +209,25 @@ int BinSeqCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastList->getLabel()) != 1) {
-                               cout << ". I will use " << lastList->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastList->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       error = process(lastList, count);       
-                       if (error == 1) { return 0; }                   
+                       delete list;
+                       list = input->getListVector(lastLabel);
+                               
+                       error = process(list, count);   
+                       if (error == 1) { return 0; }
+                       
+                       delete list;  
                }
                
-               delete lastList;
                return 0;
        }
        catch(exception& e) {
index a94954ae6541e509723dd233ec235b7b384abb4e..68ef54aaafc0281886e364ac9dad335fb6eacd87 100644 (file)
@@ -201,7 +201,7 @@ int BootSharedCommand::execute(){
                read->read(&*globaldata); 
                input = globaldata->ginput;
                order = input->getSharedOrderVector();
-               SharedOrderVector* lastOrder = order;
+               string lastLabel = order->getLabel();
                
                //if the users entered no valid calculators don't execute command
                if (treeCalculators.size() == 0) { return 0; }
@@ -239,19 +239,22 @@ int BootSharedCommand::execute(){
                        }
                        
                        //you have a label the user want that is smaller than this line and the last line has not already been processed
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
-                                                                                       
-                               cout << lastOrder->getLabel() << '\t' << count << endl;
-                               process(lastOrder);
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               
+                               delete order;
+                               order = input->getSharedOrderVector(lastLabel);                                                                                                 
+                               cout << order->getLabel() << '\t' << count << endl;
+                               process(order);
 
-                               processedLabels.insert(lastOrder->getLabel());
-                               userLabels.erase(lastOrder->getLabel());
+                               processedLabels.insert(order->getLabel());
+                               userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
-                       lastOrder = order;                      
+                       
+                       lastLabel = order->getLabel();                  
 
                        //get next line to process
+                       delete order;
                        order = input->getSharedOrderVector();
                        count++;
                }
@@ -261,21 +264,23 @@ int BootSharedCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       process(lastOrder);                     
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                               delete order;
+                               order = input->getSharedOrderVector(lastLabel);                                                                                                 
+                               cout << order->getLabel() << '\t' << count << endl;
+                               process(order);
+                               delete order;
+
                }
-               
-               delete lastOrder;
 
                //reset groups parameter
                globaldata->Groups.clear();  
index c65080fd32022bcd9abb8d3cf10f73de8f181351..dbb2edebb57d76152b570902b4f3b4151bc39d71 100644 (file)
@@ -220,7 +220,7 @@ int CollectCommand::execute(){
                read->read(&*globaldata); 
                
                order = globaldata->gorder;
-               lastOrder = order;
+               string lastLabel = order->getLabel();
                input = globaldata->ginput;
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -244,18 +244,23 @@ int CollectCommand::execute(){
                        //you have a label the user want that is smaller than this line and the last line has not already been processed 
                        }
                        
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
-                               cCurve = new Collect(lastOrder, cDisplays);
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               
+                               delete order;
+                               order = (input->getOrderVector(lastLabel));
+                               
+                               cCurve = new Collect(order, cDisplays);
                                cCurve->getCurve(freq);
                                delete cCurve;
                        
-                               cout << lastOrder->getLabel() << '\t' << count << endl;
-                               processedLabels.insert(lastOrder->getLabel());
-                               userLabels.erase(lastOrder->getLabel());
+                               cout << order->getLabel() << '\t' << count << endl;
+                               processedLabels.insert(order->getLabel());
+                               userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder;  }
-                       lastOrder = order;                      
+                       lastLabel = order->getLabel();  
+                       
+                       delete order;           
                        order = (input->getOrderVector());
                        count++;
                }
@@ -265,24 +270,28 @@ int CollectCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cCurve = new Collect(lastOrder, cDisplays);
+                       delete order;
+                       order = (input->getOrderVector(lastLabel));
+                       
+                       cout << order->getLabel() << '\t' << count << endl;
+                       
+                       cCurve = new Collect(order, cDisplays);
                        cCurve->getCurve(freq);
                        delete cCurve;
-                       
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       delete order;
                }
                
-               delete lastOrder;
+               
                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                return 0;
        }
index 04dcc602628695c5381048dbb67f4bad8be682e3..b099c8a44390ef361019de2e12dff6af71f1dc73 100644 (file)
@@ -46,7 +46,6 @@ private:
        GlobalData* globaldata;
        ReadOTUFile* read;
        OrderVector* order;
-       OrderVector* lastOrder;
        InputData* input;
        Collect* cCurve;
        ValidCalculators* validCalculator;
index 4d0306d9809d802f5c37d06ddeb69991d2dad807..adb2aeab0fb827baa6b411c041630ebe0fe4d292 100644 (file)
@@ -240,7 +240,7 @@ int CollectSharedCommand::execute(){
                        
                input = globaldata->ginput;
                order = input->getSharedOrderVector();
-               SharedOrderVector* lastOrder = order;
+               string lastLabel = order->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;
@@ -268,21 +268,25 @@ int CollectSharedCommand::execute(){
                        //you have a label the user want that is smaller than this line and the last line has not already been processed 
                        }
                        
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               delete order;
+                               order = input->getSharedOrderVector(lastLabel);
+                               
                                //create collectors curve
-                               cCurve = new Collect(lastOrder, cDisplays);
+                               cCurve = new Collect(order, cDisplays);
                                cCurve->getSharedCurve(freq);
                                delete cCurve;
                        
-                               cout << lastOrder->getLabel() << '\t' << count << endl;
-                               processedLabels.insert(lastOrder->getLabel());
-                               userLabels.erase(lastOrder->getLabel());
+                               cout << order->getLabel() << '\t' << count << endl;
+                               processedLabels.insert(order->getLabel());
+                               userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
-                       lastOrder = order;                      
+                       
+                       lastLabel = order->getLabel();                  
                        
                        //get next line to process
+                       delete order;
                        order = input->getSharedOrderVector();
                        count++;
                }
@@ -292,24 +296,27 @@ int CollectSharedCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cCurve = new Collect(lastOrder, cDisplays);
+                       delete order;
+                       order = input->getSharedOrderVector(lastLabel);
+
+                       cCurve = new Collect(order, cDisplays);
                        cCurve->getCurve(freq);
                        delete cCurve;
                        
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       cout << order->getLabel() << '\t' << count << endl;
+                       delete order;
                }
                
-               delete lastOrder;
                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }       
                
                //reset groups parameter
index 8008079b3d2c84681d1e0c81cce7f617e66ee52e..1f5c02beab1630a2d5e8d39547fb967838ae0e29 100644 (file)
@@ -195,7 +195,7 @@ int GetOTURepCommand::execute(){
                
                input = globaldata->ginput;
                list = globaldata->gListVector;
-               ListVector* lastList = list;
+               string lastLabel = list->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;
@@ -215,18 +215,22 @@ int GetOTURepCommand::execute(){
                                        userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
-                                       cout << lastList->getLabel() << '\t' << count << endl;
-                                       error = process(lastList);
+                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete list;
+                                       list = input->getListVector(lastLabel);
+                                       
+                                       cout << list->getLabel() << '\t' << count << endl;
+                                       error = process(list);
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
-                                       processedLabels.insert(lastList->getLabel());
-                                       userLabels.erase(lastList->getLabel());
+                                       processedLabels.insert(list->getLabel());
+                                       userLabels.erase(list->getLabel());
                        }
                        
-                       if (count != 1) { delete lastList; }
-                       lastList = list;                        
                        
+                       lastLabel = list->getLabel();                   
+                       
+                       delete list;
                        list = input->getListVector();
                        count++;
                }
@@ -235,25 +239,27 @@ int GetOTURepCommand::execute(){
                bool needToRun = false;
                for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastList->getLabel()) != 1) {
-                               cout << ". I will use " << lastList->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastList->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastList->getLabel() << '\t' << count << endl;
-                       error = process(lastList);
+                       delete list;
+                       list = input->getListVector(lastLabel);
+
+                       cout << list->getLabel() << '\t' << count << endl;
+                       error = process(list);
                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
+                       delete list;
                }
-               delete lastList;
                
                delete matrix;
                globaldata->gSparseMatrix = NULL;
-               delete list;
                globaldata->gListVector = NULL;
 
                return 0;
index 0dfaa63129e8269b7446bad82ae38290760643a0..b8c692bf7f64b4566311a3f9232f933aec100800 100644 (file)
@@ -126,7 +126,7 @@ int GetRAbundCommand::execute(){
                        
                input = globaldata->ginput;
                list = globaldata->gListVector;
-               ListVector* lastList = list;
+               string lastLabel = list->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;
@@ -148,20 +148,23 @@ int GetRAbundCommand::execute(){
                                        userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
-                                       cout << lastList->getLabel() << '\t' << count << endl;
+                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete list;
+                                       list = input->getListVector(lastLabel);
+                                       
+                                       cout << list->getLabel() << '\t' << count << endl;
                                        rabund = new RAbundVector();
-                                       *rabund = (lastList->getRAbundVector());
+                                       *rabund = (list->getRAbundVector());
                                        rabund->print(out);
                                        delete rabund;
 
-                                       processedLabels.insert(lastList->getLabel());
-                                       userLabels.erase(lastList->getLabel());
+                                       processedLabels.insert(list->getLabel());
+                                       userLabels.erase(list->getLabel());
                        }
                        
-                       if (count != 1) { delete lastList; }
-                       lastList = list;                        
+                       lastLabel = list->getLabel();           
                        
+                       delete list;
                        list = input->getListVector();
                        count++;
                }
@@ -171,23 +174,26 @@ int GetRAbundCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastList->getLabel()) != 1) {
-                               cout << ". I will use " << lastList->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastList->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastList->getLabel() << '\t' << count << endl;
+                       delete list;
+                       list = input->getListVector(lastLabel);
+                       
+                       cout << list->getLabel() << '\t' << count << endl;
                        rabund = new RAbundVector();
-                       *rabund = (lastList->getRAbundVector());
+                       *rabund = (list->getRAbundVector());
                        rabund->print(out);
                        delete rabund;
+                       delete list;
                }
-               delete lastList;
 
                out.close(); 
                return 0;               
index 1e10736f281b76f59c0e74374ba1b8afd4d36646..f5beb32b6a8296411dcd66afa18efc6b3be24577 100644 (file)
@@ -124,7 +124,7 @@ int GetSAbundCommand::execute(){
                read->read(&*globaldata); 
                
                order = globaldata->gorder;
-               lastOrder = order;
+               string lastLabel = order->getLabel();
                input = globaldata->ginput;
                                                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -147,20 +147,24 @@ int GetSAbundCommand::execute(){
                                        userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
-                                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete order;           
+                                       order = (input->getOrderVector(lastLabel));
+                                       
+                                       cout << order->getLabel() << '\t' << count << endl;
                                        sabund = new SAbundVector();
-                                       *sabund = (lastOrder->getSAbundVector());
+                                       *sabund = (order->getSAbundVector());
                                        sabund->print(out);
                                        delete sabund;
 
-                                       processedLabels.insert(lastOrder->getLabel());
-                                       userLabels.erase(lastOrder->getLabel());
+                                       processedLabels.insert(order->getLabel());
+                                       userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
-                       lastOrder = order;      
-                                       
+                       
+                       lastLabel = order->getLabel();  
+                       
+                       delete order;           
                        order = (input->getOrderVector());
                        count++;
                }
@@ -170,23 +174,27 @@ int GetSAbundCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       delete order;           
+                       order = (input->getOrderVector(lastLabel));
+                       
+                       cout << order->getLabel() << '\t' << count << endl;
                        sabund = new SAbundVector();
-                       *sabund = (lastOrder->getSAbundVector());
+                       *sabund = (order->getSAbundVector());
                        sabund->print(out);
                        delete sabund;
+                       delete order;
                }
-               delete lastOrder;  globaldata->gorder = NULL;
+               globaldata->gorder = NULL;
 
                out.close();
                return 0;               
index dcda3aafd7ff5a6c53cd2534a342aabba4a42215..2612b7daa6c178f8ae0468893c49c2c9c613a38c 100644 (file)
@@ -31,7 +31,6 @@ private:
        ofstream out;
        ReadOTUFile* read;
        OrderVector* order;
-       OrderVector* lastOrder;
        InputData* input;
        SAbundVector* sabund;
 
index 7a729c68b1fa1574d3f99d04f832d9e1a8c9aecf..413889ea1f1a1028420f4181cf17485266cb73b7 100644 (file)
@@ -142,8 +142,7 @@ int HeatMapCommand::execute(){
                if (abort == true) { return 0; }
        
                int count = 1;  
-               RAbundVector* lastRAbund;
-               vector<SharedRAbundVector*> lastLookup;
+               string lastLabel;
        
                if (format == "sharedfile") {
                        //you have groups
@@ -152,14 +151,14 @@ int HeatMapCommand::execute(){
                        
                        input = globaldata->ginput;
                        lookup = input->getSharedRAbundVectors();
-                       lastLookup = lookup;
+                       lastLabel = lookup[0]->getLabel();
                }else if (format == "list") {
                        //you are using just a list file and have only one group
                        read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        rabund = globaldata->rabund;
-                       lastRAbund = globaldata->rabund;
+                       lastLabel = rabund->getLabel();
                        input = globaldata->ginput;             
                }
                
@@ -183,18 +182,21 @@ int HeatMapCommand::execute(){
                                        userLines.erase(count);
                                }
                                
-                               if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                                       heatmap->getPic(lastLookup);
+                               if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       cout << lastLabel << '\t' << count << endl;
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
+                                       lookup = input->getSharedRAbundVectors(lastLabel);
                                        
-                                       processedLabels.insert(lastLookup[0]->getLabel());
-                                       userLabels.erase(lastLookup[0]->getLabel());
+                                       heatmap->getPic(lookup);
+                                       
+                                       processedLabels.insert(lookup[0]->getLabel());
+                                       userLabels.erase(lookup[0]->getLabel());
                                }
                                
+                               lastLabel = lookup[0]->getLabel();
                                //prevent memory leak
-                               if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                               lastLookup = lookup;                    
-
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
+                                                       
                                //get next line to process
                                lookup = input->getSharedRAbundVectors();                               
                                count++;
@@ -205,21 +207,25 @@ int HeatMapCommand::execute(){
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                                cout << "Your file does not include the label "<< *it; 
-                               if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                                       cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                               if (processedLabels.count(lastLabel) != 1) {
+                                       cout << ". I will use " << lastLabel << "." << endl;
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                                       cout << ". Please refer to " << lastLabel << "." << endl;
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               heatmap->getPic(lastLookup);
+                               cout << lastLabel << '\t' << count << endl;
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
+                               lookup = input->getSharedRAbundVectors(lastLabel);
+
+                               heatmap->getPic(lookup);
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                        }
                
-                       for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
+                       
                        
                        //reset groups parameter
                        globaldata->Groups.clear();  
@@ -238,18 +244,22 @@ int HeatMapCommand::execute(){
                                        userLines.erase(count);
                                }
                                
-                               if ((anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastRAbund->getLabel()) != 1)) {
+                               if ((anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
 
-                                       cout << lastRAbund->getLabel() << '\t' << count << endl;
-                                       heatmap->getPic(lastRAbund);
+                                       cout << lastLabel << '\t' << count << endl;
+                                       delete rabund;
+                                       rabund = input->getRAbundVector(lastLabel);
                                        
-                                       processedLabels.insert(lastRAbund->getLabel());
-                                       userLabels.erase(lastRAbund->getLabel());
+                                       heatmap->getPic(rabund);
+                                       
+                                       processedLabels.insert(rabund->getLabel());
+                                       userLabels.erase(rabund->getLabel());
                                }               
                                
-                               if (count != 1) { delete lastRAbund; }
-                               lastRAbund = rabund;                    
-
+                                                               
+                                                               
+                               lastLabel = rabund->getLabel();                 
+                               delete rabund;
                                rabund = input->getRAbundVector();
                                count++;
                        }
@@ -259,22 +269,24 @@ int HeatMapCommand::execute(){
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                                cout << "Your file does not include the label "<< *it; 
-                               if (processedLabels.count(lastRAbund->getLabel()) != 1) {
-                                       cout << ". I will use " << lastRAbund->getLabel() << "." << endl;
+                               if (processedLabels.count(lastLabel) != 1) {
+                                       cout << ". I will use " << lastLabel << "." << endl;
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastRAbund->getLabel() << "." << endl;
+                                       cout << ". Please refer to " << lastLabel << "." << endl;
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastRAbund->getLabel() << '\t' << count << endl;
-                               heatmap->getPic(lastRAbund);
+                               cout << lastLabel << '\t' << count << endl;
+                               delete rabund;
+                               rabund = input->getRAbundVector(lastLabel);
+                                       
+                               heatmap->getPic(rabund);
+                               delete rabund; globaldata->rabund = NULL;
                        }
                
-                       delete lastRAbund; globaldata->rabund = NULL;
-
                }
                
                delete input; globaldata->ginput = NULL;
index f3329945e0fa3fb6b24c77960717ff51e7cb0de0..331ff7963460ef9d952a71382615bdf54e195677 100644 (file)
@@ -197,7 +197,7 @@ int HeatMapSimCommand::execute(){
                        
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
-               vector<SharedRAbundVector*> lastLookup = lookup;
+               string lastLabel = lookup[0]->getLabel();
                
                if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0;}
                                
@@ -220,19 +220,24 @@ int HeatMapSimCommand::execute(){
                                userLines.erase(count);
                        }
                                
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               heatmap->getPic(lastLookup, heatCalculators);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                               lookup = input->getSharedRAbundVectors(lastLabel);                              
+
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               heatmap->getPic(lookup, heatCalculators);
                                        
-                               processedLabels.insert(lastLookup[0]->getLabel());
-                               userLabels.erase(lastLookup[0]->getLabel());
+                               processedLabels.insert(lookup[0]->getLabel());
+                               userLabels.erase(lookup[0]->getLabel());
                        }
                                
                        //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;                    
+                        
+                       lastLabel = lookup[0]->getLabel();                      
 
                        //get next line to process
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();                               
                        count++;
                }
@@ -242,21 +247,24 @@ int HeatMapSimCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel<< "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       heatmap->getPic(lastLookup, heatCalculators);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                       lookup = input->getSharedRAbundVectors(lastLabel);                              
+
+                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       heatmap->getPic(lookup, heatCalculators);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
                
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
                        
                //reset groups parameter
                globaldata->Groups.clear();  
index b4373c9ea057636634929f4b8e1e3d63398fdeec..c2f4e4e63347ce62b818617fd4e05da629a84972 100644 (file)
@@ -17,6 +17,7 @@
 InputData::InputData(string fName, string f) : format(f){
        
        openInputFile(fName, fileHandle);
+       filename = fName;
        
 }
 
@@ -76,15 +77,58 @@ ListVector* InputData::getListVector(){
                }
        }
        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";
+               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
                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";
+               cout << "An unknown error has occurred in the InputData class function getListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
+
+ListVector* InputData::getListVector(string label){
+       try {
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+
+                       if (format == "list") {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       list = new ListVector(in);
+                                       thisLabel = list->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete list;    }
+                                       gobble(in);
+                               }
+                       }
+                       
+                       in.close();
+                       return list;
+               }
+               else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
        }       
 }
 
+
 /***********************************************************************/
 
 SharedListVector* InputData::getSharedListVector(){
@@ -110,6 +154,50 @@ SharedListVector* InputData::getSharedListVector(){
                exit(1);
        }       
 }
+/***********************************************************************/
+
+SharedListVector* InputData::getSharedListVector(string label){
+       try {
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+
+                       if (format == "shared")  {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       SharedList = new SharedListVector(in);
+                                       thisLabel = SharedList->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete SharedList;      }
+                                       gobble(in);
+                               }
+
+                       }
+                               
+                       in.close();
+                       return SharedList;
+                       
+               }else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
+       }       
+}
+
+
 
 /***********************************************************************/
 
@@ -137,6 +225,49 @@ SharedOrderVector* InputData::getSharedOrderVector(){
        }       
 }
 
+/***********************************************************************/
+
+SharedOrderVector* InputData::getSharedOrderVector(string label){
+       try {
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+
+                       if (format == "sharedfile")  {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       SharedOrder = new SharedOrderVector(in);
+                                       thisLabel = SharedOrder->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete SharedOrder;     }
+                                       gobble(in);
+                               }
+
+                       }
+                               
+                       in.close();
+                       return SharedOrder;
+                       
+               }else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
+       }       
+}
+
 
 
 /***********************************************************************/
@@ -144,7 +275,7 @@ SharedOrderVector* InputData::getSharedOrderVector(){
 OrderVector* InputData::getOrderVector(){
        try {
                if(fileHandle){
-                       if(format == "list") {
+                       if((format == "list") || (format == "listorder")) {
                                input = new ListVector(fileHandle);
                        }
                        else if (format == "shared")  {
@@ -159,10 +290,7 @@ OrderVector* InputData::getOrderVector(){
                        else if(format == "sabund"){
                                input = new SAbundVector(fileHandle);
                        }
-                       else if(format == "listorder"){                                 
-                               input = new ListVector(fileHandle); 
-                       }
-               
+                                       
                        gobble(fileHandle);
                        output = new OrderVector();
                        *output = (input->getOrderVector());
@@ -182,6 +310,114 @@ OrderVector* InputData::getOrderVector(){
                exit(1);
        }       
 }
+
+/***********************************************************************/
+OrderVector* InputData::getOrderVector(string label){
+       try {
+       
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+                       if((format == "list") || (format == "listorder")) {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       input = new ListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+                       }
+                       else if (format == "shared")  {
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SharedListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "rabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new RAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "order"){                     
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new OrderVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "sabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                                       
+                               }
+
+                       }
+                       
+                       in.close();             
+
+                       output = new OrderVector();
+                       *output = (input->getOrderVector());
+                       
+                       return output;
+
+               }
+               else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
+       }       
+}
+
 /***********************************************************************/
 //this is used when you don't need the order vector
 vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
@@ -215,6 +451,68 @@ vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
                exit(1);
        }       
 }
+/***********************************************************************/
+vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
+       try {
+               ifstream in;
+               string  thisLabel;
+               
+               openInputFile(filename, in);
+               
+               if(in){
+                       if (format == "sharedfile")  {
+                               while (in.eof() != true) {
+                                       
+                                       SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
+                                       if (SharedRAbund != NULL) {
+                                               thisLabel = SharedRAbund->getLabel();
+                                               //if you are at the last label
+                                               if (thisLabel == label) {  in.close(); return SharedRAbund->getSharedRAbundVectors();  }
+                                               else {
+                                                       //so you don't loose this memory
+                                                       vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
+                                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
+                                                       delete SharedRAbund;
+                                               }
+                                       }else{  break;  }
+                                       gobble(in);
+                                       
+                               }
+                       }else if (format == "shared") {
+                               while (in.eof() != true) {
+                                       
+                                       SharedList = new SharedListVector(in);
+                                       if (SharedList != NULL) {
+                                               thisLabel = SharedList->getLabel();
+                                               //if you are at the last label
+                                               if (thisLabel == label) {  in.close(); return SharedList->getSharedRAbundVector();  }
+                                               else {
+                                                       //so you don't loose this memory
+                                                       delete SharedList;
+                                               }
+                                       }else{  break;  }
+                                       gobble(in);
+                                       
+                               }
+                       
+                       }
+               }
+                               
+               //this is created to signal to calling function that the input file is at eof
+               vector<SharedRAbundVector*> null;  null.push_back(NULL);
+               in.close();
+               return null;
+       
+       }
+       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";
+               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);
+       }       
+}
 
 
 /***********************************************************************/
@@ -258,6 +556,112 @@ SAbundVector* InputData::getSAbundVector(){
                exit(1);
        }       
 }
+/***********************************************************************/
+SAbundVector* InputData::getSAbundVector(string label){
+       try {
+       
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+                       if (format == "list") {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       input = new ListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+                       }
+                       else if (format == "shared")  {
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SharedListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "rabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new RAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "order"){                     
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new OrderVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "sabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                                       
+                               }
+
+                       }
+                       
+                       in.close();             
+
+                       sabund = new SAbundVector();
+                       *sabund = (input->getSAbundVector());
+
+                       return sabund;
+
+               }
+               else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
+       }       
+}
 
 /***********************************************************************/
 RAbundVector* InputData::getRAbundVector(){
@@ -300,6 +704,112 @@ RAbundVector* InputData::getRAbundVector(){
        }       
 }
 /***********************************************************************/
+RAbundVector* InputData::getRAbundVector(string label){
+       try {
+       
+               ifstream in;
+               string  thisLabel;
+               openInputFile(filename, in);
+               
+               if(in){
+                       if (format == "list") {
+                       
+                               while (in.eof() != true) {
+                                       
+                                       input = new ListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+                       }
+                       else if (format == "shared")  {
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SharedListVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "rabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new RAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "order"){                     
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new OrderVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                               }
+
+                       }
+                       else if(format == "sabund"){
+                               
+                               while (in.eof() != true) {
+                                       
+                                       input = new SAbundVector(in);
+                                       thisLabel = input->getLabel();
+                                       
+                                       //if you are at the last label
+                                       if (thisLabel == label) {  break;  }
+                                       //so you don't loose this memory
+                                       else {  delete input;   }
+                                       gobble(in);
+                                       
+                               }
+
+                       }
+                       
+                       in.close();             
+
+                       rabund = new RAbundVector();
+                       *rabund = (input->getRAbundVector());
+
+                       return rabund;
+               }
+               else{
+                       return NULL;
+               }
+       }
+       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";
+               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);
+       }       
+}
+
+/***********************************************************************/
 
 
 
index e9deb9d202c1935c222e4f392f85f3f2781d81ca..6d2d004911b663c63c1b5b582411bb38b70e3c00 100644 (file)
@@ -15,12 +15,19 @@ public:
        InputData(string, string, string);
        ~InputData();
        ListVector* getListVector();
+       ListVector* getListVector(string);  //pass the label you want
        SharedListVector* getSharedListVector();
-       OrderVector* getOrderVector();
+       SharedListVector* getSharedListVector(string);  //pass the label you want
+       OrderVector* getOrderVector(); 
+       OrderVector* getOrderVector(string); //pass the label you want
        SharedOrderVector* getSharedOrderVector();
+       SharedOrderVector* getSharedOrderVector(string);  //pass the label you want
        SAbundVector* getSAbundVector();
+       SAbundVector* getSAbundVector(string);  //pass the label you want
        RAbundVector* getRAbundVector();
+       RAbundVector* getRAbundVector(string);  //pass the label you want
        vector<SharedRAbundVector*> getSharedRAbundVectors();
+       vector<SharedRAbundVector*> getSharedRAbundVectors(string);  //pass the label you want
        
 private:
        string format;
@@ -33,6 +40,7 @@ private:
        SAbundVector* sabund;
        RAbundVector* rabund;
        map<string,int> orderMap;
+       string filename;
 };
 
 
index 4ae8e244031a5ea194724fcb4581bbd677e4bc9c..e8fb553e42a3ca655b2e8b063c359d7cad4968f9 100644 (file)
@@ -195,7 +195,7 @@ int MatrixOutputCommand::execute(){
                        
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
-               vector<SharedRAbundVector*> lastLookup = lookup;
+               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;
@@ -218,19 +218,23 @@ int MatrixOutputCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               process(lastLookup);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                               lookup = input->getSharedRAbundVectors(lastLabel);
+
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               process(lookup);
                                
-                               processedLabels.insert(lastLookup[0]->getLabel());
-                               userLabels.erase(lastLookup[0]->getLabel());
+                               processedLabels.insert(lookup[0]->getLabel());
+                               userLabels.erase(lookup[0]->getLabel());
                        }
 
-                       //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;                    
+                        
+                       lastLabel = lookup[0]->getLabel();                      
                        
                        //get next line to process
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();
                        count++;
                }
@@ -240,23 +244,25 @@ int MatrixOutputCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       process(lastLookup);            
-               }
-               
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                       lookup = input->getSharedRAbundVectors(lastLabel);
 
+                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       process(lookup);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+               }
                
+                               
                //reset groups parameter
                globaldata->Groups.clear();  
 
index 8820328461fcc2b403bbb9f01b8e44776d0a5750..9bb3daa7462368c4fbf9f889847cc4ae1e44c399 100644 (file)
@@ -195,7 +195,7 @@ int RareFactCommand::execute(){
                read->read(&*globaldata); 
 
                order = globaldata->gorder;
-               OrderVector* lastOrder = order;
+               string lastLabel = order->getLabel();
                input = globaldata->ginput;
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -218,19 +218,22 @@ int RareFactCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
-                               rCurve = new Rarefact(lastOrder, rDisplays);
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               delete order;
+                               order = (input->getOrderVector(lastLabel));
+                               
+                               rCurve = new Rarefact(order, rDisplays);
                                rCurve->getCurve(freq, nIters);
                                delete rCurve;
                        
-                               cout << lastOrder->getLabel() << '\t' << count << endl;
-                               processedLabels.insert(lastOrder->getLabel());
-                               userLabels.erase(lastOrder->getLabel());
+                               cout << order->getLabel() << '\t' << count << endl;
+                               processedLabels.insert(order->getLabel());
+                               userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
-                       lastOrder = order;                      
-
+                       lastLabel = order->getLabel();          
+                       
+                       delete order;
                        order = (input->getOrderVector());
                        count++;
                }
@@ -240,24 +243,27 @@ int RareFactCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       rCurve = new Rarefact(lastOrder, rDisplays);
+                       delete order;
+                       order = (input->getOrderVector(lastLabel));
+                               
+                       rCurve = new Rarefact(order, rDisplays);
                        rCurve->getCurve(freq, nIters);
                        delete rCurve;
                        
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       cout << order->getLabel() << '\t' << count << endl;
+                       delete order;
                }
                
-               delete lastOrder;
 
                for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
                return 0;
index 6461b3bc22922af68cba684893eb00f76e35a598..d527f8b87af8ab1b29537af212d7229d2e70a75b 100644 (file)
@@ -178,7 +178,7 @@ int RareFactSharedCommand::execute(){
                        
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
-               vector<SharedRAbundVector*> lastLookup = lookup;
+               string lastLabel = lookup[0]->getLabel();
 
                if (lookup.size() < 2) { 
                        cout << "I cannot run the command without at least 2 valid groups."; 
@@ -206,21 +206,24 @@ int RareFactSharedCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                                       rCurve = new Rarefact(lastLookup, rDisplays);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       rCurve = new Rarefact(lookup, rDisplays);
                                        rCurve->getSharedCurve(freq, nIters);
                                        delete rCurve;
 
-                                       processedLabels.insert(lastLookup[0]->getLabel());
-                                       userLabels.erase(lastLookup[0]->getLabel());
+                                       processedLabels.insert(lookup[0]->getLabel());
+                                       userLabels.erase(lookup[0]->getLabel());
                        }
                                
-                       //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;
+                       
+                       lastLabel = lookup[0]->getLabel();
                        
                        //get next line to process
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();
                        count++;
                }
@@ -230,24 +233,26 @@ int RareFactSharedCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       rCurve = new Rarefact(lastLookup, rDisplays);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       rCurve = new Rarefact(lookup, rDisplays);
                        rCurve->getSharedCurve(freq, nIters);
                        delete rCurve;
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
                
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
-
                for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
                
                //reset groups parameter
index 439cdf13101b183aebd2cb6e112e1b92ace9ee74..6ca1ed63585463d92ac8dc7aa65f921ca1070308 100644 (file)
@@ -47,7 +47,7 @@ int SharedCommand::execute(){
 
                input = globaldata->ginput;
                SharedList = globaldata->gSharedList;
-               SharedListVector* lastList = SharedList;
+               string lastLabel = SharedList->getLabel();
                vector<SharedRAbundVector*> lookup; 
                                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -69,18 +69,22 @@ int SharedCommand::execute(){
                                        userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
-                                       lookup = lastList->getSharedRAbundVector();
+                       if ((anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete SharedList;
+                                       SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
+                                       
+                                       lookup = SharedList->getSharedRAbundVector();
                                        printSharedData(lookup); //prints info to the .shared file
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                                        
-                                       processedLabels.insert(lastList->getLabel());
-                                       userLabels.erase(lastList->getLabel());
+                                       processedLabels.insert(SharedList->getLabel());
+                                       userLabels.erase(SharedList->getLabel());
                        }
                        
-                       if (count != 1) { delete lastList; }
-                       lastList = SharedList;  
-                                                               
+               
+                       lastLabel = SharedList->getLabel();
+                               
+                       delete SharedList;
                        SharedList = input->getSharedListVector(); //get new list vector to process
                        
                        count++;                
@@ -91,7 +95,7 @@ int SharedCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        //cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastList->getLabel()) != 1) {
+                       if (processedLabels.count(lastLabel) != 1) {
                                //cout << ". I will use " << lastList->getLabel() << "." << endl;
                                needToRun = true;
                        }else {
@@ -101,13 +105,16 @@ int SharedCommand::execute(){
                
                //run last line if you need to
                if (needToRun == true)  {
-                       lookup = lastList->getSharedRAbundVector();
+                       delete SharedList;
+                       SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
+                                       
+                       lookup = SharedList->getSharedRAbundVector();
                        printSharedData(lookup); //prints info to the .shared file
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-
+                       delete SharedList;
                }
                
-               delete lastList; globaldata->gSharedList = NULL;
+               globaldata->gSharedList = NULL;
                delete read;
                
                out.close();
index 6bf4916ea2ceb2a412a7833faa1386eb9d43d06f..246712824907240690d86c07632ed1cc58966182 100644 (file)
 /***********************************************************************/
 
 SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {globaldata = GlobalData::getInstance();}
+/***********************************************************************/
+
+SharedRAbundVector::~SharedRAbundVector() {
+       //for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
+
+}
 
 /***********************************************************************/
 
index 8944a26b871b22ddc01ade5837770773dd62ee36..0c71394689e8aad4d522e5f1ba6948466b218f56 100644 (file)
@@ -32,7 +32,7 @@ public:
        //SharedRAbundVector(string, vector<int>);
        SharedRAbundVector(const SharedRAbundVector& bv) : DataVector(bv), data(bv.data), maxRank(bv.maxRank), numBins(bv.numBins), numSeqs(bv.numSeqs){};
     SharedRAbundVector(ifstream&);
-       ~SharedRAbundVector(){};
+       ~SharedRAbundVector();
 
        int getNumBins();               
        int getNumSeqs();                                                       
index ee4ba9f760c656f84cbe13da9ed6da0cccb73e60..e228dbe7bcdef90bc829098091a8e1794c1d5114 100644 (file)
@@ -222,7 +222,7 @@ int SummaryCommand::execute(){
                read->read(&*globaldata); 
                
                sabund = globaldata->sabund;
-               SAbundVector* lastSAbund = sabund;
+               string lastLabel = sabund->getLabel();
                input = globaldata->ginput;
                
                for(int i=0;i<sumCalculators.size();i++){
@@ -259,24 +259,26 @@ int SummaryCommand::execute(){
                                outputFileHandle << endl;
                        }
                        
-                       if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastSAbund->getLabel()) != 1)) {
-
-                               cout << lastSAbund->getLabel() << '\t' << count << endl;
-                               processedLabels.insert(lastSAbund->getLabel());
-                               userLabels.erase(lastSAbund->getLabel());
+                       if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               delete sabund;
+                               sabund = input->getSAbundVector(lastLabel);
+                               
+                               cout << sabund->getLabel() << '\t' << count << endl;
+                               processedLabels.insert(sabund->getLabel());
+                               userLabels.erase(sabund->getLabel());
                                
-                               outputFileHandle << lastSAbund->getLabel();
+                               outputFileHandle << sabund->getLabel();
                                for(int i=0;i<sumCalculators.size();i++){
-                                       vector<double> data = sumCalculators[i]->getValues(lastSAbund);
+                                       vector<double> data = sumCalculators[i]->getValues(sabund);
                                        outputFileHandle << '\t';
                                        sumCalculators[i]->print(outputFileHandle);
                                }
                                outputFileHandle << endl;
                        }               
 
-                       if (count != 1) { delete lastSAbund;  }
-                       lastSAbund = sabund;                    
-
+                       lastLabel = sabund->getLabel();                 
+                       
+                       delete sabund;
                        sabund = input->getSAbundVector();
                        count++;
                }
@@ -286,29 +288,32 @@ int SummaryCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastSAbund->getLabel()) != 1) {
-                               cout << ". I will use " << lastSAbund->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastSAbund->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastSAbund->getLabel() << '\t' << count << endl;
-                       outputFileHandle << lastSAbund->getLabel();
+                       delete sabund;
+                       sabund = input->getSAbundVector(lastLabel);
+                       
+                       cout << sabund->getLabel() << '\t' << count << endl;
+                       outputFileHandle << sabund->getLabel();
                        for(int i=0;i<sumCalculators.size();i++){
-                               vector<double> data = sumCalculators[i]->getValues(lastSAbund);
+                               vector<double> data = sumCalculators[i]->getValues(sabund);
                                outputFileHandle << '\t';
                                sumCalculators[i]->print(outputFileHandle);
                        }
                        outputFileHandle << endl;
+                       delete sabund;
                }
                
                outputFileHandle.close();
                
-               delete lastSAbund;
                return 0;
        }
        catch(exception& e) {
index 1a3ecf058c898529b17f2d7c67209949722ccb0b..9f815cdebea9b9bf839dee9a5f885972d3caf992 100644 (file)
@@ -234,7 +234,7 @@ int SummarySharedCommand::execute(){
                        
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
-               vector<SharedRAbundVector*> lastLookup = lookup;
+               string lastLabel = lookup[0]->getLabel();
                
                //output estimator names as column headers
                outputFileHandle << "label" <<'\t' << "comparison" << '\t'; 
@@ -289,20 +289,24 @@ int SummarySharedCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                                       process(lastLookup);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       process(lookup);
                                        
-                                       processedLabels.insert(lastLookup[0]->getLabel());
-                                       userLabels.erase(lastLookup[0]->getLabel());
+                                       processedLabels.insert(lookup[0]->getLabel());
+                                       userLabels.erase(lookup[0]->getLabel());
                        }
 
                
-                       //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;                    
+                       
+                       lastLabel = lookup[0]->getLabel();                      
                                
                        //get next line to process
+                       //prevent memory leak
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();
                        count++;
                }
@@ -312,21 +316,24 @@ int SummarySharedCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       process(lastLookup);
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                               lookup = input->getSharedRAbundVectors(lastLabel);
+
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               process(lookup);
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
                
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
 
                //reset groups parameter
                globaldata->Groups.clear();  
index 83443d021d13f7ff74b69242bbd05608cb2b1967..cb80ca82d49a68b640476691d30d695c6599d44d 100644 (file)
@@ -232,7 +232,7 @@ int TreeGroupCommand::execute(){
                        
                        input = globaldata->ginput;
                        lookup = input->getSharedRAbundVectors();
-                       lastLookup = lookup;
+                       lastLabel = lookup[0]->getLabel();
                        
                        if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0; }
                
@@ -478,19 +478,21 @@ void TreeGroupCommand::makeSimsShared() {
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               process(lastLookup);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                               lookup = input->getSharedRAbundVectors(lastLabel);
+
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               process(lookup);
                                        
-                               processedLabels.insert(lastLookup[0]->getLabel());
-                               userLabels.erase(lastLookup[0]->getLabel());
+                               processedLabels.insert(lookup[0]->getLabel());
+                               userLabels.erase(lookup[0]->getLabel());
                        }
 
-                       //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;                    
+                       lastLabel = lookup[0]->getLabel();                      
                        
                        //get next line to process
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();
                        count++;
                }
@@ -500,21 +502,24 @@ void TreeGroupCommand::makeSimsShared() {
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       process(lastLookup);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       process(lookup);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }         
                }
                
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
                for(int i = 0 ; i < treeCalculators.size(); i++) {  delete treeCalculators[i]; }
        }
        catch(exception& e) {
index 1e1f28480082903227d77b4b92666c0bec021fc3..08389f8b798077e72b06e6a847a2c3f4d094214e 100644 (file)
@@ -59,7 +59,7 @@ private:
        InputData* input;
        ValidCalculators* validCalculator;
        vector<SharedRAbundVector*> lookup;
-       vector<SharedRAbundVector*> lastLookup;
+       string lastLabel;
        string format, outputFile, groupNames, filename;
        int numGroups;
        ofstream out;
index 6821e1d29ed94e559f586c00e8cc621e66431e59..fda33339bfc4a75a940f4c5cc0039c88edafcc30 100644 (file)
@@ -198,9 +198,8 @@ int VennCommand::execute(){
                if (abort == true) { return 0; }
                
                int count = 1;
-               SAbundVector* lastSAbund;
-               vector<SharedRAbundVector*> lastLookup; 
-
+               string lastLabel;
+               
                //if the users entered no valid calculators don't execute command
                if (vennCalculators.size() == 0) { return 0; }
                
@@ -211,14 +210,14 @@ int VennCommand::execute(){
                        
                        input = globaldata->ginput;
                        lookup = input->getSharedRAbundVectors();
-                       lastLookup = lookup;
+                       lastLabel = lookup[0]->getLabel();
                }else if (format == "list") {
                        //you are using just a list file and have only one group
                        read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        sabund = globaldata->sabund;
-                       lastSAbund = globaldata->sabund;
+                       lastLabel = sabund->getLabel();
                        input = globaldata->ginput;
                }
                
@@ -245,23 +244,26 @@ int VennCommand::execute(){
                                        venn->getPic(lookup, vennCalculators);
                                }
                                
-                               if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                                       processedLabels.insert(lastLookup[0]->getLabel());
-                                       userLabels.erase(lastLookup[0]->getLabel());
+                               if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       processedLabels.insert(lookup[0]->getLabel());
+                                       userLabels.erase(lookup[0]->getLabel());
 
-                                       if (lastLookup.size() > 4) {
+                                       if (lookup.size() > 4) {
                                                cout << "Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile." << endl;
-                                               for (int i = lastLookup.size(); i > 4; i--) { lastLookup.pop_back(); } //no memmory leak because pop_back calls destructor
+                                               for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        }                               
-                                       venn->getPic(lastLookup, vennCalculators);
+                                       venn->getPic(lookup, vennCalculators);
                                }
                                
-                               //prevent memory leak
-                               if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                               lastLookup = lookup;    
+                               
+                               lastLabel = lookup[0]->getLabel();      
                                                
                                //get next line to process
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                lookup = input->getSharedRAbundVectors();
                                count++;
                        }
@@ -271,25 +273,31 @@ int VennCommand::execute(){
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                                cout << "Your file does not include the label "<< *it; 
-                               if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                                       cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                               if (processedLabels.count(lastLabel) != 1) {
+                                       cout << ". I will use " << lastLabel << "." << endl;
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                                       cout << ". Please refer to " << lastLabel << "." << endl;
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               if (lastLookup.size() > 4) {
-                                       cout << "Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile." << endl;
-                                       for (int i = lastLookup.size(); i > 3; i--) { delete lastLookup[i]; lastLookup.pop_back(); }
-                               }                               
-                               venn->getPic(lastLookup, vennCalculators);
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                                       lookup = input->getSharedRAbundVectors(lastLabel);
+
+                                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                                       processedLabels.insert(lookup[0]->getLabel());
+                                       userLabels.erase(lookup[0]->getLabel());
+
+                                       if (lookup.size() > 4) {
+                                               cout << "Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile." << endl;
+                                               for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
+                                       }                               
+                                       venn->getPic(lookup, vennCalculators);
+                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        }
                
-                       for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
 
                        //reset groups parameter
                        globaldata->Groups.clear();  
@@ -308,18 +316,20 @@ int VennCommand::execute(){
                                        userLines.erase(count);
                                }
                                
-                               if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastSAbund->getLabel()) != 1)) {
-
-                                       cout << lastSAbund->getLabel() << '\t' << count << endl;
-                                       venn->getPic(lastSAbund, vennCalculators);
+                               if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete sabund;
+                                       sabund = input->getSAbundVector(lastLabel);
+                                       
+                                       cout << sabund->getLabel() << '\t' << count << endl;
+                                       venn->getPic(sabund, vennCalculators);
                                        
-                                       processedLabels.insert(lastSAbund->getLabel());
-                                       userLabels.erase(lastSAbund->getLabel());
+                                       processedLabels.insert(sabund->getLabel());
+                                       userLabels.erase(sabund->getLabel());
                                }               
                                
-                               if (count != 1) { delete lastSAbund; }
-                               lastSAbund = sabund;                    
-
+                               lastLabel = sabund->getLabel();         
+                               
+                               delete sabund;
                                sabund = input->getSAbundVector();
                                count++;
                        }
@@ -329,20 +339,25 @@ int VennCommand::execute(){
                        bool needToRun = false;
                        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                                cout << "Your file does not include the label "<< *it; 
-                               if (processedLabels.count(lastSAbund->getLabel()) != 1) {
-                                       cout << ". I will use " << lastSAbund->getLabel() << "." << endl;
+                               if (processedLabels.count(lastLabel) != 1) {
+                                       cout << ". I will use " << lastLabel << "." << endl;
                                        needToRun = true;
                                }else {
-                                       cout << ". Please refer to " << lastSAbund->getLabel() << "." << endl;
+                                       cout << ". Please refer to " << lastLabel << "." << endl;
                                }
                        }
                
                        //run last line if you need to
                        if (needToRun == true)  {
-                               cout << lastSAbund->getLabel() << '\t' << count << endl;
-                               venn->getPic(lastSAbund, vennCalculators);
+                               delete sabund;
+                               sabund = input->getSAbundVector(lastLabel);
+                                       
+                               cout << sabund->getLabel() << '\t' << count << endl;
+                               venn->getPic(sabund, vennCalculators);
+                               delete sabund;
+                                       
                        }
-                       delete lastSAbund;
+                       
                }
                
                for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }