]> git.donarmstrong.com Git - mothur.git/blobdiff - collect.cpp
addition of trim.flows
[mothur.git] / collect.cpp
index 62ed9f24a929bab17a0733c98b5771105a395c3f..ec5366b627d8e8f776ffd00c0bb63f98a748f4bc 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-int Collect::getCurve(int increment = 1){
+int Collect::getCurve(float percentFreq = 0.01){
         try {
                 RAbundVector* lookup = new RAbundVector(order->getNumBins());
                 SAbundVector* rank        = new SAbundVector(order->getMaxRank()+1);
@@ -21,7 +21,13 @@ int Collect::getCurve(int increment = 1){
                 for(int i=0;i<displays.size();i++){
                         ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
                         displays[i]->init(label);                   //sets displays label
-                }                                                                           
+                }   
+                               
+                               //convert freq percentage to number
+                               int increment = 1;
+                               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
+                               else { increment = percentFreq;  }
+                                                                                                                                                                                                                                                       
                 for(int i=0;i<numSeqs;i++){
                                                
                                                if (m->control_pressed) { delete lookup; delete rank; delete ccd;  return 1;  }
@@ -62,9 +68,9 @@ int Collect::getCurve(int increment = 1){
 }
 
 /***********************************************************************/
-int Collect::getSharedCurve(int increment = 1){
+int Collect::getSharedCurve(float percentFreq = 0.01){
 try {
-                globaldata = GlobalData::getInstance();
+                               globaldata = GlobalData::getInstance();
                 vector<SharedRAbundVector*> lookup; 
                                vector<SharedRAbundVector*> subset;
 
@@ -82,20 +88,26 @@ try {
                 //initialize labels for output
                 //makes  'uniqueAB         uniqueAC  uniqueBC' if your groups are A, B, C
                 getGroupComb();
-                groupLabel = ""; 
-                for (int s = 0; s < groupComb.size(); s++) {
-                        groupLabel = groupLabel + label + groupComb[s] + "\t";
-                }
-                               
-                               //for multi displays
-                               string groupLabelAll = groupLabel + label + "all\t";
                                
                 for(int i=0;i<displays.size();i++){
                         ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
+                                               bool hasLciHci = displays[i]->hasLciHci();
+                                               groupLabel = "";
+                                               for (int s = 0; s < groupComb.size(); s++) {
+                                                       if (hasLciHci) {  groupLabel = groupLabel + label + groupComb[s] + "\t" + label + groupComb[s] + "lci\t" + label + groupComb[s] + "hci\t"; }
+                                                       else{  groupLabel = groupLabel + label + groupComb[s] + "\t";  }
+                                               }
+
+                                               string groupLabelAll = groupLabel + label + "all\t"; 
                                                if ((displays[i]->isCalcMultiple() == true) && (displays[i]->getAll() == true)) {   displays[i]->init(groupLabelAll); }
                                                else {  displays[i]->init(groupLabel);  }           
                 }
                 
+                               //convert freq percentage to number
+                               int increment = 1;
+                               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
+                               else { increment = percentFreq;  }
+                               
                 //sample all the members
                 for(int i=0;i<numSeqs;i++){
                                
@@ -120,17 +132,25 @@ try {
                                                                //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
 
                                 int n = 1;
+                                                               bool pair = true;
                                 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                         for (int l = n; l < lookup.size(); l++) {
                                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                                //add new pair of sharedrabund vectors
                                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
+                                                                                       
+                                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                                               }
+                                                                                       
+                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size(), pair);
                                         }
                                         n++;
                                 }
                                                                //if this is a calculator that can do multiples then do them
-                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size()); 
+                                                               pair = false;
+                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size(), pair); 
                         }
                         totalNumSeq = i+1;
                 }
@@ -139,17 +159,25 @@ try {
                 if(numSeqs % increment != 0){
                         //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
                         int n = 1;
+                                               bool pair = true;
                         for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                 for (int l = n; l < lookup.size(); l++) {
                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                //add new pair of sharedrabund vectors
                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
+                                                                       
+                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                               }
+                                                                       
+                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size(), pair);
                                 }
                                 n++;
                         }
                                                //if this is a calculator that can do multiples then do them
-                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size()); 
+                                               pair = false;
+                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size(), pair); 
                 }
                 
                 //resets output files