if(processors == 1) { totalSeqs = driverGroups(outputFileName, newFasta, accnosFileName, alnsFileName, newCountFile, 0, groups.size(), groups);
- //read my own
- if (hasCount && !dups) {
- CountTable newCount; newCount.readTable(nameFile);
-
+ if (hasCount && dups) {
+ CountTable c; c.readTable(nameFile);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
string name, group;
while (!in2.eof()) {
in2 >> name >> group; m->gobble(in2);
- newCount.setAbund(name, group, 0);
+ c.setAbund(name, group, 0);
}
in2.close();
}
m->mothurRemove(newCountFile);
- newCount.printTable(newCountFile);
+ c.printTable(newCountFile);
}
}else { totalSeqs = createProcessesGroups(outputFileName, newFasta, accnosFileName, alnsFileName, newCountFile, groups, nameFile, groupFile, fastaFileNames[s]); }
m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(totalSeqs) + " sequences. " + toString(totalChimeras) + " chimeras were found."); m->mothurOutEndLine();
m->mothurOut("The number of sequences checked may be larger than the number of unique sequences because some sequences are found in several samples."); m->mothurOutEndLine();
}else {
- /*if (hasCount) { //removed empty seqs
- ofstream out2;
- m->openOutputFile(accnosFileName, out2);
-
+
+ if (hasCount) {
+ set<string> doNotRemove;
CountTable c; c.readTable(newCountFile);
- vector<string> nseqs = c.getNamesOfSeqs();
- vector<string> ngroups = c.getNamesOfGroups();
- for (int l = 0; l < nseqs.size(); l++) {
- if (c.getNumSeqs(nseqs[l]) == 0) {
- c.remove(nseqs[l]);
- out2 << nseqs[l] << endl;
- }
+ vector<string> namesInTable = c.getNamesOfSeqs();
+ for (int i = 0; i < namesInTable.size(); i++) {
+ int temp = c.getNumSeqs(namesInTable[i]);
+ if (temp == 0) { c.remove(namesInTable[i]); }
+ else { doNotRemove.insert((namesInTable[i])); }
}
- for (int l = 0; l < ngroups.size(); l++) {
- if (c.getGroupCount(ngroups[l]) == 0) { c.removeGroup(ngroups[l]); }
+ //remove names we want to keep from accnos file.
+ set<string> accnosNames = m->readAccnos(accnosFileName);
+ ofstream out2;
+ m->openOutputFile(accnosFileName, out2);
+ for (set<string>::iterator it = accnosNames.begin(); it != accnosNames.end(); it++) {
+ if (doNotRemove.count(*it) == 0) { out2 << (*it) << endl; }
}
out2.close();
c.printTable(newCountFile);
- }*/
+ }
}
if (hasCount) { delete cparser; }
#endif
-
+
//read my own
if (hasCount && dups) {
if (!m->isBlank(accnos + ".byCount")) {
}
m->mothurRemove(accnos + ".byCount");
}
-
+
//append output files
for(int i=0;i<processIDS.size();i++){
m->appendFiles((outputFName + toString(processIDS[i]) + ".temp"), outputFName);
}
//print new *.pick.count_table
- if (hasCount && dups) { newCount.printTable(newCountFile); }
-
+ if (hasCount && dups) { newCount.printTable(newCountFile); }
+
return num;
}
for (int i = 0; i < groups.size(); i++) { out << groups[i] << '\t'; }
out << endl;
- for (map<string, int>::iterator itNames = indexNameMap.begin(); itNames != indexNameMap.end(); itNames++) {
+ map<int, string> reverse; //use this to preserve order
+ for (map<string, int>::iterator it = indexNameMap.begin(); it !=indexNameMap.end(); it++) { reverse[it->second] = it->first; }
+
+ for (int i = 0; i < totals.size(); i++) {
+ map<int, string>::iterator itR = reverse.find(i);
+
+ if (itR != reverse.end()) { //will equal end if seqs were removed because remove just removes from indexNameMap
+ out << itR->second << '\t' << totals[i] << '\t';
+ if (hasGroups) {
+ for (int j = 0; j < groups.size(); j++) {
+ out << counts[i][j] << '\t';
+ }
+ }
+ out << endl;
+ }
+ }
+ /*for (map<string, int>::iterator itNames = indexNameMap.begin(); itNames != indexNameMap.end(); itNames++) {
out << itNames->first << '\t' << totals[itNames->second] << '\t';
if (hasGroups) {
}
}
out << endl;
- }
+ }*/
out.close();
return 0;
}
if (hasGroups) {
map<string, int>::iterator it = indexGroupMap.find(groupName);
if (it == indexGroupMap.end()) {
- m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
+ m->mothurOut("[ERROR]: group " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
}else {
return totalGroups[it->second];
}
if (hasGroups) {
map<string, int>::iterator it = indexGroupMap.find(groupName);
if (it == indexGroupMap.end()) {
- m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
+ m->mothurOut("[ERROR]: group " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
}else {
map<string, int>::iterator it2 = indexNameMap.find(seqName);
if (it2 == indexNameMap.end()) {
- m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
+ m->mothurOut("[ERROR]: seq " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
}else {
return counts[it2->second][it->second];
}