X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=inline;f=treemap.cpp;h=00ae0e664ff5fb7d289893b445be08b5fd20c89a;hb=cdcf99b7760701e6869ca8e4e6e91c8e8c4ae186;hp=6314eb04d04006ba5c57808f6927bddec89d6a00;hpb=b2dca66a02f8f82aa5528e531eace60fbbd2967b;p=mothur.git diff --git a/treemap.cpp b/treemap.cpp index 6314eb0..00ae0e6 100644 --- a/treemap.cpp +++ b/treemap.cpp @@ -47,7 +47,7 @@ void TreeMap::readMap() { int TreeMap::getNumGroups() { - return seqsPerGroup.size(); + return namesOfGroups.size(); } /************************************************************/ @@ -72,7 +72,13 @@ string TreeMap::getGroup(string sequenceName) { } /************************************************************/ void TreeMap::setIndex(string seq, int index) { - treemap[seq].vectorIndex = index; + it = treemap.find(seq); + if (it != treemap.end()) { //sequence name was in group file + treemap[seq].vectorIndex = index; + }else { + treemap[seq].vectorIndex = index; + treemap[seq].groupname = "not found"; + } } /************************************************************/ int TreeMap::getIndex(string seq) { @@ -138,3 +144,31 @@ void TreeMap::print(ostream& output){ } /************************************************************/ +void TreeMap::makeSim(GroupMap* groupmap) { + try { + //set names of groups + namesOfGroups = groupmap->namesOfGroups; + + //set names of seqs to names of groups + namesOfSeqs = groupmap->namesOfGroups; + + // make map where key and value are both the group name since that what the tree.shared command wants + for (int i = 0; i < namesOfGroups.size(); i++) { + treemap[namesOfGroups[i]].groupname = namesOfGroups[i]; + seqsPerGroup[namesOfGroups[i]] = 1; + } + + numGroups = namesOfGroups.size(); + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeMap class function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/************************************************************/ +