X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=removeseqscommand.cpp;fp=removeseqscommand.cpp;h=00b94a9dac842ceeca4a2a0362d87f14ba12ca1b;hb=cc19310422f125d6628980bd1148e1e816792382;hp=73873f3a4744eb0e9ce59a9b2640bf013f524852;hpb=e8e13c129ba8184ec5932a090773f353f3ae3406;p=mothur.git diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index 73873f3..00b94a9 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -406,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 != "") { @@ -413,7 +419,7 @@ int RemoveSeqsCommand::readFasta(){ if (names.count(name) == 0) { wroteSomething = true; - currSeq.printSequence(out); + currSeq.printSequence(out); }else { removedCount++; } } m->gobble(in); @@ -477,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; @@ -695,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] << ','; } @@ -788,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++; } @@ -840,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) {