]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedcommand.cpp
finished get.relabund command
[mothur.git] / sharedcommand.cpp
index 213fd49588bbf8a9278bc04c14d474bd11ccb278..91bb8e19604d3d9446016c4b9eaf82f566172c0a 100644 (file)
@@ -8,7 +8,11 @@
  */
 
 #include "sharedcommand.h"
-
+//********************************************************************************************************************
+//sorts lowest to highest
+inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* right){
+       return (left->getGroup() < right->getGroup());  
+} 
 //**********************************************************************************************************************
 
 SharedCommand::SharedCommand(string o) : outputDir(o) {
@@ -143,6 +147,7 @@ int SharedCommand::execute(){
                        if(globaldata->allLines == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){
                                        
                                        lookup = SharedList->getSharedRAbundVector();
+                                       
                                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                        if (pickedGroups) { //check for otus with no seqs in them
                                                eliminateZeroOTUS(lookup);
@@ -275,6 +280,8 @@ int SharedCommand::execute(){
 void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup) {
        try {
                
+               sort(thislookup.begin(), thislookup.end(), compareSharedRabunds);
+               
                //initialize bin values
                for (int i = 0; i < thislookup.size(); i++) {
 //cout << "in printData " << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() <<  endl;