X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=removeseqscommand.cpp;h=00b94a9dac842ceeca4a2a0362d87f14ba12ca1b;hb=006601d68abe8d0061f77e8d28323b160750e343;hp=1fb94462ac48fa13ac871c6b9d3cf4f3ae2ceff6;hpb=ea4f373c28543cd1002b0dd7dc6e55c526647d59;p=mothur.git diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index 1fb9446..00b94a9 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -10,6 +10,7 @@ #include "removeseqscommand.h" #include "sequence.hpp" #include "listvector.hpp" +#include "counttable.h" //********************************************************************************************************************** vector RemoveSeqsCommand::setParameters(){ @@ -71,7 +72,7 @@ string RemoveSeqsCommand::getOutputFileNameTag(string type, string inputName="") else if (type == "list") { outputFileName = "pick" + m->getExtension(inputName); } else if (type == "qfile") { outputFileName = "pick" + m->getExtension(inputName); } else if (type == "alignreport") { outputFileName = "pick.align.report"; } - else if (type == "count") { outputFileName = "pick.count.table"; } + else if (type == "count") { outputFileName = "pick.count_table"; } else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } } return outputFileName; @@ -405,6 +406,12 @@ int RemoveSeqsCommand::readFasta(){ if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); + + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(currSeq.getName()); + if (it != uniqueMap.end()) { currSeq.setName(it->second); } + } + name = currSeq.getName(); if (name != "") { @@ -412,7 +419,7 @@ int RemoveSeqsCommand::readFasta(){ if (names.count(name) == 0) { wroteSomething = true; - currSeq.printSequence(out); + currSeq.printSequence(out); }else { removedCount++; } } m->gobble(in); @@ -476,6 +483,11 @@ int RemoveSeqsCommand::readQual(){ m->gobble(in); + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(saveName); + if (it != uniqueMap.end()) { name = ">" + it->second; saveName = it->second; } + } + if (names.count(saveName) == 0) { wroteSomething = true; @@ -538,6 +550,14 @@ int RemoveSeqsCommand::readCount(){ } 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 contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["count"].push_back(outputFileName); outputNames.push_back(outputFileName); @@ -686,6 +706,8 @@ int RemoveSeqsCommand::readName(){ wroteSomething = true; out << validSecond[0] << '\t'; + //we are changing the unique name in the fasta file + uniqueMap[firstCol] = validSecond[0]; //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] << ','; } @@ -779,9 +801,15 @@ int RemoveSeqsCommand::readTax(){ in >> name; //read from first column in >> tax; //read from second column + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(name); + if (it != uniqueMap.end()) { name = it->second; } + } + //if this name is in the accnos file if (names.count(name) == 0) { wroteSomething = true; + out << name << '\t' << tax << endl; }else { removedCount++; } @@ -831,6 +859,11 @@ int RemoveSeqsCommand::readAlign(){ if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column + + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(name); + if (it != uniqueMap.end()) { name = it->second; } + } //if this name is in the accnos file if (names.count(name) == 0) {