X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=countseqscommand.cpp;h=e83c6035731aa5509655dcd25a7a45995c1a0004;hb=2c97dd48b8e27ee0a6a86c7a082f4c504c3357c6;hp=8164e2714db5fc4c1f2c1d59f9593475717386b5;hpb=fe0f86cb70ff3ce31df98ed49e404c7e12e21b3d;p=mothur.git diff --git a/countseqscommand.cpp b/countseqscommand.cpp index 8164e27..e83c603 100644 --- a/countseqscommand.cpp +++ b/countseqscommand.cpp @@ -33,7 +33,7 @@ vector CountSeqsCommand::setParameters(){ string CountSeqsCommand::getHelpString(){ try { string helpString = ""; - helpString += "The count.seqs command reads a name file and outputs a .count.summary file. You may also provide a group file to get the counts broken down by group.\n"; + helpString += "The count.seqs command reads a name file and outputs a .seq.count file. You may also provide a group file to get the counts broken down by group.\n"; helpString += "The groups parameter allows you to indicate which groups you want to include in the counts, by default all groups in your groupfile are used.\n"; helpString += "When you use the groups parameter and a sequence does not represent any sequences from the groups you specify it is not included in the .count.summary file.\n"; helpString += "The count.seqs command should be in the following format: count.seqs(name=yourNameFile).\n"; @@ -117,11 +117,12 @@ CountSeqsCommand::CountSeqsCommand(string option) { namefile = m->getNameFile(); if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current namefile and the name parameter is required."); m->mothurOutEndLine(); abort = true; } - } + }else { m->setNameFile(namefile); } groupfile = validParameter.validFile(parameters, "group", true); if (groupfile == "not open") { abort = true; } else if (groupfile == "not found") { groupfile = ""; } + else { m->setGroupFile(groupfile); } groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = "all"; } @@ -146,9 +147,9 @@ int CountSeqsCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } ofstream out; - string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "count.summary"; + string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "seq.count"; m->openOutputFile(outputFileName, out); outputTypes["summary"].push_back(outputFileName); - out << "Representative Sequence\t total\t"; + out << "Representative_Sequence\ttotal\t"; GroupMap* groupMap; if (groupfile != "") { @@ -156,7 +157,8 @@ int CountSeqsCommand::execute(){ //make sure groups are valid. takes care of user setting groupNames that are invalid or setting groups=all SharedUtil* util = new SharedUtil(); - util->setGroups(Groups, groupMap->namesOfGroups); + vector nameGroups = groupMap->getNamesOfGroups(); + util->setGroups(Groups, nameGroups); delete util; //sort groupNames so that the group title match the counts below, this is needed because the map object automatically sorts @@ -172,7 +174,8 @@ int CountSeqsCommand::execute(){ //open input file ifstream in; m->openInputFile(namefile, in); - + + int total = 0; while (!in.eof()) { if (m->control_pressed) { break; } @@ -215,14 +218,16 @@ int CountSeqsCommand::execute(){ out << firstCol << '\t' << names.size() << endl; } - + total += names.size(); } in.close(); if (groupfile != "") { delete groupMap; } - if (m->control_pressed) { remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; } + m->mothurOutEndLine(); + m->mothurOut("Total number of sequences: " + toString(total)); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine();