]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedlistvector.cpp
fixed some bugs found while testing 1.8
[mothur.git] / sharedlistvector.cpp
index ba2ac1f54082a44cc188611994ff4f5c61b65ad3..4303cfde13d3c4250c8f952c7a6eeb4bd9a2553d 100644 (file)
@@ -200,10 +200,14 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){
                                name = names.substr(0,names.find_first_of(','));
                                names = names.substr(names.find_first_of(',')+1, names.length());
                                groupName = groupmap->getGroup(name);
+                               
+                               if(groupName == "not found") {  mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
+                               
                                order->push_back(i, binSize, groupName);  //i represents what bin you are in
                        }
                        //get last name
                        groupName = groupmap->getGroup(names);
+                       if(groupName == "not found") {  mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                        order->push_back(i, binSize, groupName);
                }
 
@@ -229,6 +233,7 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
                                name = names.substr(0,names.find_first_of(','));
                                names = names.substr(names.find_first_of(',')+1, names.length());
                                group = groupmap->getGroup(name);
+                               if(group == "not found") {      mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                                if (group == groupName) { //this name is in the group you want the vector for.
                                        rav.set(i, rav.getAbundance(i) + 1, group);  //i represents what bin you are in
                                }
@@ -236,6 +241,7 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
                        
                        //get last name
                        groupName = groupmap->getGroup(names);
+                       if(groupName == "not found") {  mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                        if (group == groupName) { //this name is in the group you want the vector for.
                                        rav.set(i, rav.getAbundance(i) + 1, group);  //i represents what bin you are in
                        }
@@ -257,23 +263,23 @@ vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
        try {
                SharedUtil* util;
                util = new SharedUtil();
-               vector<SharedRAbundVector*> lookup;
-               map<string, SharedRAbundVector*> finder;
+               vector<SharedRAbundVector*> lookup;  //contains just the groups the user selected
+               map<string, SharedRAbundVector*> finder;  //contains all groups in groupmap
                string group, names, name;
-               
+       
                util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
-               
                delete util;
 
-               for (int i = 0; i < globaldata->Groups.size(); i++) {
+               for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
                        SharedRAbundVector* temp = new SharedRAbundVector(data.size());
-                       finder[globaldata->Groups[i]] = temp;
-                       finder[globaldata->Groups[i]]->setLabel(label);
-                       finder[globaldata->Groups[i]]->setGroup(globaldata->Groups[i]);
-                       //*temp = getSharedRAbundVector(globaldata->Groups[i]);
-                       lookup.push_back(finder[globaldata->Groups[i]]);
+                       finder[globaldata->gGroupmap->namesOfGroups[i]] = temp;
+                       finder[globaldata->gGroupmap->namesOfGroups[i]]->setLabel(label);
+                       finder[globaldata->gGroupmap->namesOfGroups[i]]->setGroup(globaldata->gGroupmap->namesOfGroups[i]);
+                       if (inVector(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups)) {  //if this group is in user groups
+                               lookup.push_back(finder[globaldata->gGroupmap->namesOfGroups[i]]);
+                       }
                }
-               
+       
                //fill vectors
                for(int i=0;i<numBins;i++){
                        names = get(i);  
@@ -281,11 +287,13 @@ vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
                                name = names.substr(0,names.find_first_of(','));
                                names = names.substr(names.find_first_of(',')+1, names.length());
                                group = groupmap->getGroup(name);
+                               if(group == "not found") {      mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                                finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
                        }
                        
                        //get last name
                        group = groupmap->getGroup(names);
+                       if(group == "not found") {      mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine();  exit(1); }
                        finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
                        
                }