X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=removeseqscommand.cpp;h=02cb5d94c2f286f3456f073ccd30db753f4743d3;hp=1990e9c364d6bdedb257f2801abe55f566de8e29;hb=36a867cbd85d9c276d3c8d13f25a150bbbe2466b;hpb=01b7dae5525a480d31a1de5bc273692726da8570 diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index 1990e9c..02cb5d9 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -513,24 +513,17 @@ int RemoveSeqsCommand::readName(){ string name, firstCol, secondCol; bool wroteSomething = false; + while(!in.eof()){ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } - + in >> firstCol; m->gobble(in); in >> secondCol; - + vector parsedNames; - //parse second column saving each name - while (secondCol.find_first_of(',') != -1) { - name = secondCol.substr(0,secondCol.find_first_of(',')); - secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length()); - parsedNames.push_back(name); - } + m->splitAtComma(secondCol, parsedNames); - //get name after last , - parsedNames.push_back(secondCol); - vector validSecond; validSecond.clear(); for (int i = 0; i < parsedNames.size(); i++) { if (names.count(parsedNames[i]) == 0) { @@ -541,7 +534,7 @@ int RemoveSeqsCommand::readName(){ if ((dups) && (validSecond.size() != parsedNames.size())) { //if dups is true and we want to get rid of anyone, get rid of everyone for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); } }else { - //if the name in the first column is in the set then print it and any other names in second column also in set + //if the name in the first column is in the set then print it and any other names in second column also in set if (names.count(firstCol) == 0) { wroteSomething = true; @@ -572,10 +565,10 @@ int RemoveSeqsCommand::readName(){ } in.close(); out.close(); - + if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName); - + return 0; } catch(exception& e) {