X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getseqscommand.cpp;h=902cc07c2d6e8768e5aa9d1bacd3d9586e9196d9;hb=df905918ace8537273616b4120d404ebd29dc9cc;hp=d40dcc6a30d20080770ac806855295f98ed83df3;hpb=de67504f85e091a3049ef4c5df8e77f7dcb1d814;p=mothur.git diff --git a/getseqscommand.cpp b/getseqscommand.cpp index d40dcc6..902cc07 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -26,8 +26,7 @@ vector GetSeqsCommand::getValidParameters(){ //********************************************************************************************************************** GetSeqsCommand::GetSeqsCommand(){ try { - abort = true; - //initialize outputTypes + abort = true; calledHelp = true; vector tempOutNames; outputTypes["fasta"] = tempOutNames; outputTypes["taxonomy"] = tempOutNames; @@ -69,10 +68,10 @@ vector GetSeqsCommand::getRequiredFiles(){ //********************************************************************************************************************** GetSeqsCommand::GetSeqsCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -188,8 +187,7 @@ GetSeqsCommand::GetSeqsCommand(string option) { if (accnosfile == "not open") { abort = true; } else if (accnosfile == "not found") { accnosfile = ""; m->mothurOut("You must provide an accnos file."); m->mothurOutEndLine(); abort = true; } - accnosfile2 = validParameter.validFile(parameters, "accnos2", true); - if (accnosfile2 == "not open") { abort = true; } + if (accnosfile2 == "not found") { accnosfile2 = ""; } fastafile = validParameter.validFile(parameters, "fasta", true); if (fastafile == "not open") { abort = true; } @@ -258,7 +256,7 @@ void GetSeqsCommand::help(){ int GetSeqsCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } //get names you want to keep readAccnos(); @@ -779,6 +777,30 @@ int GetSeqsCommand::compareAccnos(){ set namesDups; set namesAccnos = names; + map nameCount; + + if (namefile != "") { + ifstream inName; + m->openInputFile(namefile, inName); + + + while(!inName.eof()){ + + if (m->control_pressed) { inName.close(); return 0; } + + string thisname, repnames; + + inName >> thisname; m->gobble(inName); //read from first column + inName >> repnames; //read from second column + + int num = m->getNumNames(repnames); + nameCount[thisname] = num; + + m->gobble(inName); + } + inName.close(); + } + while(!in.eof()){ in >> name; @@ -797,21 +819,27 @@ int GetSeqsCommand::compareAccnos(){ m->mothurOut("Names in both files : " + toString(namesDups.size())); m->mothurOutEndLine(); for (set::iterator it = namesDups.begin(); it != namesDups.end(); it++) { - out << (*it) << endl; + out << (*it); + if (namefile != "") { out << '\t' << nameCount[(*it)]; } + out << endl; } out << "Names unique to " + accnosfile + " : " + toString(namesAccnos.size()) << endl; m->mothurOut("Names unique to " + accnosfile + " : " + toString(namesAccnos.size())); m->mothurOutEndLine(); for (set::iterator it = namesAccnos.begin(); it != namesAccnos.end(); it++) { - out << (*it) << endl; + out << (*it); + if (namefile != "") { out << '\t' << nameCount[(*it)]; } + out << endl; } out << "Names unique to " + accnosfile2 + " : " + toString(namesAccnos2.size()) << endl; m->mothurOut("Names unique to " + accnosfile2 + " : " + toString(namesAccnos2.size())); m->mothurOutEndLine(); for (set::iterator it = namesAccnos2.begin(); it != namesAccnos2.end(); it++) { - out << (*it) << endl; + out << (*it); + if (namefile != "") { out << '\t' << nameCount[(*it)]; } + out << endl; } out.close();