X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=chimerauchimecommand.cpp;h=422792a68525b495008694360c393e26ba358c09;hp=cb155eb2e53c3b8ba47c4ed36aa495efaef4460a;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=e946299389ed49b4afc4262a4e8070ee3d804769 diff --git a/chimerauchimecommand.cpp b/chimerauchimecommand.cpp index cb155eb..422792a 100644 --- a/chimerauchimecommand.cpp +++ b/chimerauchimecommand.cpp @@ -564,10 +564,7 @@ ChimeraUchimeCommand::ChimeraUchimeCommand(string option) { temp = validParameter.validFile(parameters, "dereplicate", false); - if (temp == "not found") { - if (groupfile != "") { temp = "false"; } - else { temp = "true"; } - } + if (temp == "not found") { temp = "false"; } dups = m->isTrue(temp); @@ -677,7 +674,7 @@ int ChimeraUchimeCommand::execute(){ int error; if (hasCount) { CountTable ct; - ct.readTable(nameFile); + ct.readTable(nameFile, true); for(map::iterator it = seqs.begin(); it != seqs.end(); it++) { int num = ct.getNumSeqs(it->first); if (num == 0) { error = 1; } @@ -728,7 +725,7 @@ int ChimeraUchimeCommand::execute(){ if(processors == 1) { totalSeqs = driverGroups(outputFileName, newFasta, accnosFileName, alnsFileName, newCountFile, 0, groups.size(), groups); if (hasCount && dups) { - CountTable c; c.readTable(nameFile); + CountTable c; c.readTable(nameFile, true); if (!m->isBlank(newCountFile)) { ifstream in2; m->openInputFile(newCountFile, in2); @@ -758,7 +755,7 @@ int ChimeraUchimeCommand::execute(){ if (hasCount) { set doNotRemove; - CountTable c; c.readTable(newCountFile); + CountTable c; c.readTable(newCountFile, true); vector namesInTable = c.getNamesOfSeqs(); for (int i = 0; i < namesInTable.size(); i++) { int temp = c.getNumSeqs(namesInTable[i]); @@ -774,6 +771,7 @@ int ChimeraUchimeCommand::execute(){ } out2.close(); c.printTable(newCountFile); + outputNames.push_back(newCountFile); outputTypes["count"].push_back(newCountFile); } } @@ -819,6 +817,11 @@ int ChimeraUchimeCommand::execute(){ if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } } + + itTypes = outputTypes.find("count"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); } + } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -839,10 +842,6 @@ int ChimeraUchimeCommand::deconvoluteResults(map& uniqueNames, s map::iterator itUnique; int total = 0; - //edit accnos file - ifstream in2; - m->openInputFile(accnosFileName, in2); - ofstream out2; m->openOutputFile(accnosFileName+".temp", out2); @@ -852,27 +851,32 @@ int ChimeraUchimeCommand::deconvoluteResults(map& uniqueNames, s set chimerasInFile; set::iterator itChimeras; - - while (!in2.eof()) { - if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName+".temp")); return 0; } - - in2 >> name; m->gobble(in2); - - //find unique name - itUnique = uniqueNames.find(name); - - if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find " + name + "."); m->mothurOutEndLine(); m->control_pressed = true; } - else { - itChimeras = chimerasInFile.find((itUnique->second)); - - if (itChimeras == chimerasInFile.end()) { - out2 << itUnique->second << endl; - chimerasInFile.insert((itUnique->second)); - total++; - } - } - } - in2.close(); + if (!m->isBlank(accnosFileName)) { + //edit accnos file + ifstream in2; + m->openInputFile(accnosFileName, in2); + + while (!in2.eof()) { + if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName+".temp")); return 0; } + + in2 >> name; m->gobble(in2); + + //find unique name + itUnique = uniqueNames.find(name); + + if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find " + name + "."); m->mothurOutEndLine(); m->control_pressed = true; } + else { + itChimeras = chimerasInFile.find((itUnique->second)); + + if (itChimeras == chimerasInFile.end()) { + out2 << itUnique->second << endl; + chimerasInFile.insert((itUnique->second)); + total++; + } + } + } + in2.close(); + } out2.close(); m->mothurRemove(accnosFileName); @@ -1181,6 +1185,7 @@ int ChimeraUchimeCommand::driverGroups(string outputFName, string filename, stri int totalSeqs = 0; int numChimeras = 0; + ofstream outCountList; if (hasCount && dups) { m->openOutputFile(countlist, outCountList); } @@ -1790,7 +1795,7 @@ int ChimeraUchimeCommand::createProcessesGroups(string outputFName, string filen int num = 0; CountTable newCount; - if (hasCount && dups) { newCount.readTable(nameFile); } + if (hasCount && dups) { newCount.readTable(nameFile, true); } //sanity check if (groups.size() < processors) { processors = groups.size(); }