5 * Created by Sarah Westcott on 12/5/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
12 /**************************************************************************************************/
15 globaldata = GlobalData::getInstance();
18 /**************************************************************************************************/
19 void Shared::getSharedVectors(SharedListVector* list) {
22 label = list->getLabel();
24 for (it = sharedGroups.begin(); it != sharedGroups.end(); it++) { delete it->second; }
25 sharedGroups.clear(); //removes old info.
27 //initalize sharedGroups
28 for (j=0; j<globaldata->gGroupmap->getNumGroups(); j++) {//for each group
29 group = globaldata->gGroupmap->namesOfGroups[j];
30 sharedGroups[group] = new SharedRAbundVector();
31 sharedGroups[group]->setLabel(label);
32 for (i = 0; i<list->size(); i++) { //for each otu
33 sharedGroups[group]->push_back(0, i, group); //initialize to 0.
38 for (i = 0; i<list->size(); i++) {
42 //updates sharedVector
43 //sharedRAbund.push_back(sharedGroups);
48 /***********************************************************************/
49 void Shared::parse(int index, SharedListVector* list) {
51 string prefix, suffix, groupsName;
52 suffix = list->get(index);
54 while (suffix.find_first_of(',') != -1) {//while you still have sequences
55 prefix = suffix.substr(0,suffix.find_first_of(','));
56 if ((suffix.find_first_of(',')+1) <= suffix.length()) { //checks to make sure you don't have comma at end of string
57 suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
59 groupsName = globaldata->gGroupmap->getGroup(prefix);
60 if (groupsName != "not found") {
61 sharedGroups[groupsName]->set(index, (sharedGroups[groupsName]->getAbundance(index) + 1), groupsName); //increment shared vector for that group
63 cerr << "Error: Sequence '" << prefix << "' was not found in the group file, please correct\n";
67 //save last name after comma
68 groupsName = globaldata->gGroupmap->getGroup(suffix);
69 if (groupsName != "not found") {
70 sharedGroups[groupsName]->set(index, ((sharedGroups[groupsName]->getAbundance(index)) + 1), groupsName); //increment shared vector for that group
72 cerr << "Error: Sequence '" << suffix << "' was not found in the group file, please correct\n";