+//**********************************************************************************************************************
+int GetSeqsCommand::readCount(){
+ try {
+ string thisOutputDir = outputDir;
+ if (outputDir == "") { thisOutputDir += m->hasPath(countfile); }
+ string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+
+ ofstream out;
+ m->openOutputFile(outputFileName, out);
+
+ ifstream in;
+ m->openInputFile(countfile, in);
+
+ bool wroteSomething = false;
+ int selectedCount = 0;
+
+ string headers = m->getline(in); m->gobble(in);
+ out << headers << endl;
+
+ string name, rest; int thisTotal;
+ while (!in.eof()) {
+
+ if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
+
+ in >> name; m->gobble(in);
+ in >> thisTotal; m->gobble(in);
+ rest = m->getline(in); m->gobble(in);
+ if (m->debug) { m->mothurOut("[DEBUG]: " + name + '\t' + rest + "\n"); }
+
+ if (names.count(name) != 0) {
+ out << name << '\t' << thisTotal << '\t' << rest << endl;
+ wroteSomething = true;
+ selectedCount+= thisTotal;
+ }
+ }
+ in.close();
+ out.close();
+
+ //check for groups that have been eliminated
+ CountTable ct;
+ if (ct.testGroups(outputFileName)) {
+ ct.readTable(outputFileName);
+ ct.printTable(outputFileName);
+ }
+
+ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); }
+ outputTypes["count"].push_back(outputFileName); outputNames.push_back(outputFileName);
+
+ m->mothurOut("Selected " + toString(selectedCount) + " sequences from your count file."); m->mothurOutEndLine();
+
+ return 0;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetSeqsCommand", "readCount");
+ exit(1);
+ }
+}
+