X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=468c063cb5c7e74a8d5901a1a38203f47409e2d5;hb=55bbd10379db27def51cec72a8819d775f73e45b;hp=37c0916d4c49e1f8ed8ca979c7ff61b7e1a13ef3;hpb=a9dbc22713bfc056a797361dd757b1a5c98e1c01;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index 37c0916..468c063 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -1183,7 +1183,7 @@ string MothurOut::sortFile(string distFile, string outputDir){ string firstName, secondName; float dist; - while (input) { + while (!input.eof()) { input >> firstName >> secondName >> dist; output << dist << '\t' << firstName << '\t' << secondName << endl; gobble(input); @@ -1199,16 +1199,17 @@ string MothurOut::sortFile(string distFile, string outputDir){ //read in sorted file and put distance at end again ifstream input2; + ofstream output2; openInputFile(tempOutfile, input2); - openOutputFile(outfile, output); + openOutputFile(outfile, output2); - while (input2) { + while (!input2.eof()) { input2 >> dist >> firstName >> secondName; - output << firstName << '\t' << secondName << '\t' << dist << endl; + output2 << firstName << '\t' << secondName << '\t' << dist << endl; gobble(input2); } input2.close(); - output.close(); + output2.close(); //remove temp files mothurRemove(tempDistFile); @@ -1607,8 +1608,17 @@ int MothurOut::readTax(string namefile, map& taxMap) { if (pairDone) { //are there confidence scores, if so remove them if (secondCol.find_first_of('(') != -1) { removeConfidences(secondCol); } - taxMap[firstCol] = secondCol; - if (debug) { mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n"); } + map::iterator itTax = taxMap.find(firstCol); + + if(itTax == taxMap.end()) { + bool ignore = false; + if (secondCol != "") { if (secondCol[secondCol.length()-1] != ';') { mothurOut("[ERROR]: " + firstCol + " is missing the final ';', ignoring.\n"); ignore=true; } + } + if (!ignore) { taxMap[firstCol] = secondCol; } + if (debug) { mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n"); } + }else { + mothurOut("[ERROR]: " + firstCol + " is already in your taxonomy file, names must be unique./n"); control_pressed = true; + } pairDone = false; } } @@ -1625,8 +1635,18 @@ int MothurOut::readTax(string namefile, map& taxMap) { if (pairDone) { //are there confidence scores, if so remove them if (secondCol.find_first_of('(') != -1) { removeConfidences(secondCol); } - taxMap[firstCol] = secondCol; - if (debug) { mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n"); } + map::iterator itTax = taxMap.find(firstCol); + + if(itTax == taxMap.end()) { + bool ignore = false; + if (secondCol != "") { if (secondCol[secondCol.length()-1] != ';') { mothurOut("[ERROR]: " + firstCol + " is missing the final ';', ignoring.\n"); ignore=true; } + } + if (!ignore) { taxMap[firstCol] = secondCol; } + if (debug) { mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n"); } + }else { + mothurOut("[ERROR]: " + firstCol + " is already in your taxonomy file, names must be unique./n"); control_pressed = true; + } + pairDone = false; } } @@ -2470,6 +2490,9 @@ void MothurOut::getNumSeqs(ifstream& file, int& numSeqs){ //This function parses the estimator options and puts them in a vector void MothurOut::splitAtChar(string& estim, vector& container, char symbol) { try { + + if (symbol == '-') { splitAtDash(estim, container); return; } + string individual = ""; int estimLength = estim.size(); for(int i=0;i