+ ofstream out;
+ string thisGroupName = thisOutputDir + m->getRootName(m->getSimpleName(it->first));
+ if (!makeCount) { thisGroupName += getOutputFileName("group",variables); outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName);
+ m->openOutputFile(thisGroupName, out);
+
+ while (!in.eof()){
+ if (m->control_pressed) { break; }
+
+ Sequence currSeq(in); m->gobble(in);
+ out << currSeq.getName() << '\t' << it->second << endl;
+ }
+ out.close();
+ }
+ else {
+ thisGroupName += getOutputFileName("count",variables); outputNames.push_back(thisGroupName); outputTypes["count"].push_back(thisGroupName);
+ CountTable ct;
+ ct.addGroup(it->second);
+ while (!in.eof()){
+ if (m->control_pressed) { break; }
+
+ Sequence currSeq(in); m->gobble(in);
+ vector<int> tempGroupCount; tempGroupCount.push_back(1);
+ ct.push_back(currSeq.getName(), tempGroupCount);
+ }
+ ct.printTable(thisGroupName);
+ }
+ in.close();
+ }
+ }
+
+ if (createFileGroup || createOligosGroup) {
+ if (makeCount) {
+ if ((allFiles) || (filesToProcess.size() == 1)) {
+ CountTable ct;
+ for (map<string, int>::iterator itGroups = groupCounts.begin(); itGroups != groupCounts.end(); itGroups++) {
+ ct.addGroup(itGroups->first);
+ }
+ vector<string> groups = ct.getNamesOfGroups();
+ for (map<string, string>::iterator itGroup = groupMap.begin(); itGroup != groupMap.end(); itGroup++) {
+ vector<int> tempGroupCounts; tempGroupCounts.resize(groups.size(), 0);
+ ct.push_back(itGroup->first, tempGroupCounts);
+ ct.setAbund(itGroup->first, itGroup->second, 1);
+ }
+ ct.printTable(outputGroupFileName);
+ }
+ }else {
+ ofstream outGroup;
+ m->openOutputFile(outputGroupFileName, outGroup);
+ for (map<string, string>::iterator itGroup = groupMap.begin(); itGroup != groupMap.end(); itGroup++) {
+ outGroup << itGroup->first << '\t' << itGroup->second << endl;
+ }
+ outGroup.close();
+ }
+ }
+
+ if (filesToProcess.size() > 1) { //merge into large combo files
+ if (createFileGroup || createOligosGroup) {
+ if (makeCount) {
+ for (map<string, string>::iterator itGroup = groupMap.begin(); itGroup != groupMap.end(); itGroup++) {
+ vector<string> groups = compositeCt.getNamesOfGroups();
+ if (m->inUsersGroups(itGroup->second, groups)) {
+ vector<int> tempGroupCounts; tempGroupCounts.resize(groups.size(), 0);
+ compositeCt.push_back(itGroup->first, tempGroupCounts);
+ compositeCt.setAbund(itGroup->first, itGroup->second, 1);
+ }else{
+ compositeCt.addGroup(itGroup->second);
+ vector<int> tempGroupCounts; tempGroupCounts.resize(groups.size()+1, 0);
+ compositeCt.push_back(itGroup->first, tempGroupCounts);
+ compositeCt.setAbund(itGroup->first, itGroup->second, 1);
+ }
+ }
+ }else {
+ if (l == 0) {
+ ofstream outCGroup;
+ m->openOutputFile(compositeGroupFile, outCGroup); outCGroup.close();
+ outputNames.push_back(compositeGroupFile); outputTypes["group"].push_back(compositeGroupFile);
+ }
+ m->appendFiles(outputGroupFileName, compositeGroupFile);
+ if (!allFiles) { m->mothurRemove(outputGroupFileName); }
+ else { outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName); }
+ }
+ for (map<string, int>::iterator itGroups = groupCounts.begin(); itGroups != groupCounts.end(); itGroups++) {
+ map<string, int>::iterator itTemp = totalGroupCounts.find(itGroups->first);
+ if (itTemp == totalGroupCounts.end()) { totalGroupCounts[itGroups->first] = itGroups->second; } //new group create it in totalGroups
+ else { itTemp->second += itGroups->second; } //existing group, update total
+ }
+ }
+ if (l == 0) { m->appendFiles(outMisMatchFile, compositeMisMatchFile); }
+ else { m->appendFilesWithoutHeaders(outMisMatchFile, compositeMisMatchFile); }
+ m->appendFiles(outFastaFile, compositeFastaFile);
+ m->appendFiles(outScrapFastaFile, compositeScrapFastaFile);
+ if (!allFiles) {
+ m->mothurRemove(outMisMatchFile);
+ m->mothurRemove(outFastaFile);
+ m->mothurRemove(outScrapFastaFile);
+ }else {
+ outputNames.push_back(outFastaFile); outputTypes["fasta"].push_back(outFastaFile);
+ outputNames.push_back(outScrapFastaFile); outputTypes["fasta"].push_back(outScrapFastaFile);
+ outputNames.push_back(outMisMatchFile); outputTypes["report"].push_back(outMisMatchFile);
+ }
+ }else {
+ totalGroupCounts = groupCounts;
+ outputNames.push_back(outFastaFile); outputTypes["fasta"].push_back(outFastaFile);
+ outputNames.push_back(outScrapFastaFile); outputTypes["fasta"].push_back(outScrapFastaFile);
+ outputNames.push_back(outMisMatchFile); outputTypes["report"].push_back(outMisMatchFile);
+ if (createFileGroup || createOligosGroup) {
+ if (makeCount) { outputNames.push_back(outputGroupFileName); outputTypes["count"].push_back(outputGroupFileName); }
+ else { outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName); }