]> git.donarmstrong.com Git - mothur.git/commitdiff
changes to read.otu(list/shared) - took out substr calls
authorpschloss <pschloss>
Thu, 26 Aug 2010 13:04:35 +0000 (13:04 +0000)
committerpschloss <pschloss>
Thu, 26 Aug 2010 13:04:35 +0000 (13:04 +0000)
groupmap.cpp
sharedlistvector.cpp

index 47fbc36ee55ec4e2ff3fd9b934621eeef9a79a64..0e0be0e8cf2799527e2664bb79b1cdded09e215c 100644 (file)
@@ -61,26 +61,28 @@ string GroupMap::getGroup(string sequenceName) {
 }
 
 /************************************************************/
+
 void GroupMap::setGroup(string sequenceName, string groupN) {
        groupmap[sequenceName] = groupN;
 }
+
 /************************************************************/
 void GroupMap::setNamesOfGroups(string seqGroup) {
-                       int i, count;
-                       count = 0;
-                       for (i=0; i<namesOfGroups.size(); i++) {
-                               if (namesOfGroups[i] != seqGroup) {
-                                       count++; //you have not found this group
-                               }else {
-                                       break; //you already have it
-                               }
-                       }
-                       if (count == namesOfGroups.size()) {
-                               namesOfGroups.push_back(seqGroup); //new group
-                               seqsPerGroup[seqGroup] = 0;
-                               groupIndex[seqGroup] = index;
-                               index++;
-                       }
+       int i, count;
+       count = 0;
+       for (i=0; i<namesOfGroups.size(); i++) {
+               if (namesOfGroups[i] != seqGroup) {
+                       count++; //you have not found this group
+               }else {
+                       break; //you already have it
+               }
+       }
+       if (count == namesOfGroups.size()) {
+               namesOfGroups.push_back(seqGroup); //new group
+               seqsPerGroup[seqGroup] = 0;
+               groupIndex[seqGroup] = index;
+               index++;
+       }
 }
 /************************************************************/
 bool GroupMap::isValidGroup(string groupname) {
index 49780314bca4d40be6a96a9593831b39317faaca..f2d8e07f81320d58b500287dc66df8e068246ee5 100644 (file)
@@ -283,21 +283,42 @@ vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
                //fill vectors
                for(int i=0;i<numBins;i++){
                        names = get(i);  
-                       while (names.find_first_of(',') != -1) { 
-                               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") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                               finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
+                       int nameLength = names.size();
+                       string seqName = "";
+                       
+                       for(int j=0;j<nameLength;j++){
+                               if(names[j] == ','){
+                                       group = groupmap->getGroup(seqName);
+                                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
+                                       finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
+                                       
+                                       seqName = "";
+                               }
+                               else{
+                                       seqName += names[j];
+                               }
                        }
+                       group = groupmap->getGroup(seqName);
+                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
+                       finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
+                       
+                       
+                       
+//                     while (names.find_first_of(',') != -1) { 
+//                             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") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->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") {      m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                       finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
+//                     group = groupmap->getGroup(names);
+//                     if(group == "not found") {      m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
+//                     finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
                        
                }
-               
+
                return lookup;
        }
        catch(exception& e) {