-/*****************************************************************/
-int TreeReader::readNamesFile() {
- try {
- nameMap.clear();
- names.clear();
- int numUniquesInName = 0;
-
- ifstream in;
- m->openInputFile(namefile, in);
-
- string first, second;
- map<string, string>::iterator itNames;
-
- while(!in.eof()) {
- in >> first >> second; m->gobble(in);
-
- numUniquesInName++;
-
- itNames = nameMap.find(first);
- if (itNames == nameMap.end()) {
- names[first] = second;
-
- //we need a list of names in your namefile to use above when removing extra seqs above so we don't remove them
- vector<string> dupNames;
- m->splitAtComma(second, dupNames);
-
- for (int i = 0; i < dupNames.size(); i++) {
- nameMap[dupNames[i]] = first;
- if ((groupfile == "") && (i != 0)) { tmap->addSeq(dupNames[i], "Group1"); }
- }
- }else { m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); nameMap.clear(); names.clear(); namefile = ""; return 1; }
- }
- in.close();
-
- return numUniquesInName;
- }
- catch(exception& e) {
- m->errorOut(e, "TreeReader", "readNamesFile");
- exit(1);
- }
-}