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(int index, SharedListVector* list) {
22 label = list->getLabel();
24 sharedGroups.clear(); //removes old info.
26 //initalize sharedGroups
27 for (j=0; j<globaldata->gGroupmap->getNumGroups(); j++) {//for each group
28 group = globaldata->gGroupmap->namesOfGroups[j];
29 sharedGroups[group] = new SharedRAbundVector();
30 sharedGroups[group]->setLabel(label);
31 for (i = 0; i<list->size(); i++) { //for each otu
32 sharedGroups[group]->push_back(0, i, group); //initialize to 0.
37 for (i = 0; i<list->size(); i++) {
41 //updates sharedVector
42 sharedRAbund.push_back(sharedGroups);
47 /***********************************************************************/
48 void Shared::parse(int index, SharedListVector* list) {
50 string prefix, suffix, groupsName;
51 suffix = list->get(index);
53 while (suffix.find_first_of(',') != -1) {//while you still have sequences
54 prefix = suffix.substr(0,suffix.find_first_of(','));
55 if ((suffix.find_first_of(',')+1) <= suffix.length()) { //checks to make sure you don't have comma at end of string
56 suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
58 groupsName = globaldata->gGroupmap->getGroup(prefix);
59 if (groupsName != "not found") {
60 sharedGroups[groupsName]->set(index, (sharedGroups[groupsName]->getAbundance(index) + 1), groupsName); //increment shared vector for that group
62 cerr << "Error: Sequence '" << prefix << "' was not found in the group file, please correct\n";
66 //save last name after comma
67 groupsName = globaldata->gGroupmap->getGroup(suffix);
68 if (groupsName != "not found") {
69 sharedGroups[groupsName]->set(index, ((sharedGroups[groupsName]->getAbundance(index)) + 1), groupsName); //increment shared vector for that group
71 cerr << "Error: Sequence '" << suffix << "' was not found in the group file, please correct\n";