X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=subsamplecommand.cpp;fp=subsamplecommand.cpp;h=aebba6bbc430a6608d5fe8bb0a31ef9ebd58c4f4;hb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;hp=717b1d3231c20368a2d23e9b86d52a6707f03b12;hpb=2c97dd48b8e27ee0a6a86c7a082f4c504c3357c6;p=mothur.git diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 717b1d3..aebba6b 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -639,34 +639,13 @@ int SubSampleCommand::getNames() { int SubSampleCommand::readNames() { try { - ifstream in; - m->openInputFile(namefile, in); - - string thisname, repnames; - map >::iterator it; - - while(!in.eof()){ - - if (m->control_pressed) { in.close(); return 0; } - - in >> thisname; m->gobble(in); //read from first column - in >> repnames; //read from second column - - it = nameMap.find(thisname); - if (it == nameMap.end()) { - - vector splitRepNames; - m->splitAtComma(repnames, splitRepNames); - - nameMap[thisname] = splitRepNames; - for (int i = 0; i < splitRepNames.size(); i++) { names.push_back(splitRepNames[i]); } - - }else{ m->mothurOut(thisname + " is already in namesfile. I will use first definition."); m->mothurOutEndLine(); } - - m->gobble(in); - } - in.close(); - + nameMap.clear(); + m->readNames(namefile, nameMap); + + //save names of all sequences + map >::iterator it; + for (it = nameMap.begin(); it != nameMap.end(); it++) { for (int i = 0; i < (it->second).size(); i++) { names.push_back((it->second)[i]); } } + return 0; }