X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getgroupscommand.cpp;h=0c42b7dad8281b1d9edd49550c3df95ae773c7e8;hb=1b0bddfbf4ac5df7e2dad03c8a5350e71b052f78;hp=5021f4085534cfc84a17d5875e449cf90f9f1d53;hpb=55386dddad84cc1140d736cabaf4dd0ae16f2e01;p=mothur.git diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp index 5021f40..0c42b7d 100644 --- a/getgroupscommand.cpp +++ b/getgroupscommand.cpp @@ -189,6 +189,11 @@ GetGroupsCommand::GetGroupsCommand(string option) { else if (namefile == "not found") { namefile = ""; } else { m->setNameFile(namefile); } + groupfile = validParameter.validFile(parameters, "group", true); + if (groupfile == "not open") { groupfile = ""; abort = true; } + else if (groupfile == "not found") { groupfile = ""; } + else { m->setGroupFile(groupfile); } + listfile = validParameter.validFile(parameters, "list", true); if (listfile == "not open") { abort = true; } else if (listfile == "not found") { listfile = ""; } @@ -375,6 +380,15 @@ int GetGroupsCommand::readFasta(){ currSeq.printSequence(out); selectedCount++; + }else{ + //if you are not in the accnos file check if you are a name that needs to be changed + map::iterator it = uniqueToRedundant.find(name); + if (it != uniqueToRedundant.end()) { + wroteSomething = true; + currSeq.setName(it->second); + currSeq.printSequence(out); + selectedCount++; + } } } m->gobble(in); @@ -490,10 +504,26 @@ int GetGroupsCommand::readList(){ //if that name is in the .accnos file, add it if (names.count(name) != 0) { newNames += name + ","; selectedCount++; } + else{ + //if you are not in the accnos file check if you are a name that needs to be changed + map::iterator it = uniqueToRedundant.find(name); + if (it != uniqueToRedundant.end()) { + newNames += it->second + ","; + selectedCount++; + } + } } //get last name if (names.count(binnames) != 0) { newNames += binnames + ","; selectedCount++; } + else{ + //if you are not in the accnos file check if you are a name that needs to be changed + map::iterator it = uniqueToRedundant.find(binnames); + if (it != uniqueToRedundant.end()) { + newNames += it->second + ","; + selectedCount++; + } + } //if there are names in this bin add to new list if (newNames != "") { @@ -585,6 +615,7 @@ int GetGroupsCommand::readName(){ //you know you have at least one valid second since first column is valid for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; } out << validSecond[validSecond.size()-1] << endl; + uniqueToRedundant[firstCol] = validSecond[0]; } } @@ -678,6 +709,13 @@ int GetGroupsCommand::readTax(){ if (names.count(name) != 0) { wroteSomething = true; out << name << '\t' << tax << endl; + }else{ + //if you are not in the accnos file check if you are a name that needs to be changed + map::iterator it = uniqueToRedundant.find(name); + if (it != uniqueToRedundant.end()) { + wroteSomething = true; + out << it->second << '\t' << tax << endl; + } } m->gobble(in);