]> git.donarmstrong.com Git - mothur.git/blobdiff - metastatscommand.cpp
added sequence name to error string in fastq.info. Changed np_shannon to npshannon.
[mothur.git] / metastatscommand.cpp
index 2a55ff08178cb0a7da3d99aff4b157017bb3d27e..b7aa7e5fcb3bcc809c89ac3cc82c1ecae9d6272a 100644 (file)
@@ -167,7 +167,7 @@ MetaStatsCommand::MetaStatsCommand(string option) {
                        else { 
                                pickedGroups = true;
                                m->splitAtDash(groups, Groups);
-                               m->Groups = Groups;
+                               m->setGroups(Groups);
                        }
                        
                        sets = validParameter.validFile(parameters, "sets", false);                     
@@ -178,14 +178,14 @@ MetaStatsCommand::MetaStatsCommand(string option) {
 
                        
                        string temp = validParameter.validFile(parameters, "iters", false);                     if (temp == "not found") { temp = "1000"; }
-                       convert(temp, iters); 
+                       m->mothurConvert(temp, iters); 
                        
                        temp = validParameter.validFile(parameters, "threshold", false);                        if (temp == "not found") { temp = "0.05"; }
-                       convert(temp, threshold); 
+                       m->mothurConvert(temp, threshold); 
                        
                        temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
                        m->setProcessors(temp);
-                       convert(temp, processors);
+                       m->mothurConvert(temp, processors);
                }
 
        }
@@ -215,8 +215,9 @@ int MetaStatsCommand::execute(){
                //setup the pairwise comparions of sets for metastats
                //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
                //make sure sets are all in designMap
-               SharedUtil* util = new SharedUtil();  
-               util->setGroups(Sets, designMap->namesOfGroups);  
+               SharedUtil* util = new SharedUtil(); 
+               vector<string> dGroups = designMap->getNamesOfGroups();
+               util->setGroups(Sets, dGroups);  
                delete util;
                
                int numGroups = Sets.size();
@@ -250,7 +251,7 @@ int MetaStatsCommand::execute(){
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
-                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->Groups.clear(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]); } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
        
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
@@ -281,13 +282,13 @@ int MetaStatsCommand::execute(){
                        //prevent memory leak
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
                        
-                       if (m->control_pressed) {  outputTypes.clear(); m->Groups.clear(); delete input;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); m->clearGroups(); delete input;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]); } return 0; }
 
                        //get next line to process
                        lookup = input->getSharedRAbundVectors();                               
                }
                
-               if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  return 0; }
+               if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); }  return 0; }
 
                //output error messages about any remaining user labels
                set<string>::iterator it;
@@ -315,7 +316,7 @@ int MetaStatsCommand::execute(){
                }
        
                //reset groups parameter
-               m->Groups.clear();  
+               m->clearGroups();  
                delete input; 
                delete designMap;
                
@@ -393,17 +394,17 @@ int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& th
                        //get set names
                        string setA = namesOfGroupCombos[c][0]; 
                        string setB = namesOfGroupCombos[c][1];
-                       
+               //cout << setA << '\t' << setB << endl;
                        //get filename
                        string outputFileName = outputDir +  m->getRootName(m->getSimpleName(sharedfile)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + ".metastats";
                        outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
-                       int nameLength = outputFileName.length();
-                       char * output = new char[nameLength];
-                       strcpy(output, outputFileName.c_str());
+                       //int nameLength = outputFileName.length();
+                       //char * output = new char[nameLength];
+                       //strcpy(output, outputFileName.c_str());
        
                        //build matrix from shared rabunds
-                       double** data;
-                       data = new double*[thisLookUp[0]->getNumBins()];
+                       //double** data;
+                       //data = new double*[thisLookUp[0]->getNumBins()];
                        
                        vector< vector<double> > data2; data2.resize(thisLookUp[0]->getNumBins());
                        
@@ -423,36 +424,39 @@ int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& th
                                        setACount++;
                                }
                        }
-                                               
+                       
+                       //for (int i = 0; i < subset.size(); i++) { cout << designMap->getGroup(subset[i]->getGroup()) << endl; }
+                       //cout << setACount << endl;
+                       
                        if ((setACount == 0) || (setBCount == 0))  { 
                                m->mothurOut("Missing shared info for " + setA + " or " + setB + ". Skipping comparison."); m->mothurOutEndLine(); 
                                outputNames.pop_back();
                        }else {
                                //fill data
                                for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                                       data[j] = new double[subset.size()];
+                                       //data[j] = new double[subset.size()];
                                        data2[j].resize(subset.size(), 0.0);
                                        for (int i = 0; i < subset.size(); i++) {
-                                               data[j][i] = (subset[i]->getAbundance(j));
+                                               //data[j][i] = (subset[i]->getAbundance(j));
                                                data2[j][i] = (subset[i]->getAbundance(j));
                                        }
                                }
                                
                                m->mothurOut("Comparing " + setA + " and " + setB + "..."); m->mothurOutEndLine(); 
-                               metastat_main(output, thisLookUp[0]->getNumBins(), subset.size(), threshold, iters, data, setACount);
+                               //metastat_main(output, thisLookUp[0]->getNumBins(), subset.size(), threshold, iters, data, setACount);
                                
                                m->mothurOutEndLine();
                                MothurMetastats mothurMeta(threshold, iters);
-                               mothurMeta.runMetastats(outputFileName+".myVersion" , data2, setACount);
+                               mothurMeta.runMetastats(outputFileName , data2, setACount);
                                m->mothurOutEndLine();
                                
                                m->mothurOutEndLine(); 
                        }
                        
                        //free memory
-                       delete output;
-                       for(int i = 0; i < thisLookUp[0]->getNumBins(); i++)  {  delete[] data[i];  }
-                       delete[] data; 
+                       //delete output;
+                       //for(int i = 0; i < thisLookUp[0]->getNumBins(); i++)  {  delete[] data[i];  }
+                       //delete[] data; 
                }
                
                return 0;