if (m->control_pressed) { return 0; }
if(allFiles){
- //clear out all old group files
map<string, string> uniqueFastaNames;// so we don't add the same groupfile multiple times
map<string, string>::iterator it;
set<string> namesToRemove;
//output group counts
m->mothurOutEndLine();
int total = 0;
- for (int i = 0; i < barcodeNameVector.size(); i++) {
- if ((barcodeNameVector[i] != "") && (groupCounts[i] != 0)) { total += groupCounts[i]; m->mothurOut("Group " + barcodeNameVector[i] + " contains " + toString(groupCounts[i]) + " sequences."); m->mothurOutEndLine(); }
+ for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
+ total += it->second; m->mothurOut("Group " + it->first + " contains " + toString(it->second) + " sequences."); m->mothurOutEndLine();
}
if (total != 0) { m->mothurOut("Total of all groups is " + toString(total)); m->mothurOutEndLine(); }
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+
+ //set fasta file as new current fastafile
+ string current = "";
+ itTypes = outputTypes.find("fasta");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
+ }
+
+ itTypes = outputTypes.find("qfile");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
+ }
+
+ itTypes = outputTypes.find("group");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
+ }
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
}
if(barcodes.size() != 0){
- outGroupsFile << currSeq.getName() << '\t' << barcodeNameVector[barcodeIndex] << endl;
- groupCounts[barcodeIndex]++;
+ string thisGroup = barcodeNameVector[barcodeIndex];
+ if (primers.size() != 0) { thisGroup += "." + primerNameVector[primerIndex]; }
+
+ outGroupsFile << currSeq.getName() << '\t' << thisGroup << endl;
+
+ map<string, int>::iterator it = groupCounts.find(thisGroup);
+ if (it == groupCounts.end()) { groupCounts[thisGroup] = 1; }
+ else { groupCounts[it->first]++; }
+
}
ofstream out;
string tempFile = filename + toString(getpid()) + ".num.temp";
m->openOutputFile(tempFile, out);
- for(int i = 0; i < groupCounts.size(); i++) {
- out << groupCounts[i] << endl;
+ for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
+ out << it->first << '\t' << it->second << endl;
}
out.close();
ifstream in;
string tempFile = filename + toString(processIDS[i]) + ".num.temp";
m->openInputFile(tempFile, in);
- int count = 0;
int tempNum;
+ string group;
while (!in.eof()) {
- in >> tempNum; m->gobble(in);
- groupCounts[count] += tempNum;
- count++;
+ in >> group >> tempNum; m->gobble(in);
+
+ map<string, int>::iterator it = groupCounts.find(group);
+ if (it == groupCounts.end()) { groupCounts[group] = tempNum; }
+ else { groupCounts[it->first] += tempNum; }
}
in.close(); remove(tempFile.c_str());
}
numFPrimers = primers.size();
numRPrimers = revPrimer.size();
- groupCounts.resize(barcodeNameVector.size(), 0);
}
catch(exception& e) {