X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getseqscommand.cpp;h=287f5a6acdc08a9c40b6e2e12b159a2f83fc9636;hb=c48d91112209b841444923670dca5454da0e2a4d;hp=779ea912ebebbe58ec22e65723899c4ea566b85f;hpb=deba0af0ccdcb6005ed5b2b82649b137c63fbdf7;p=mothur.git diff --git a/getseqscommand.cpp b/getseqscommand.cpp index 779ea91..287f5a6 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -427,6 +427,11 @@ int GetSeqsCommand::readFasta(){ Sequence currSeq(in); name = currSeq.getName(); + + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(name); + if (it != uniqueMap.end()) { name = it->second; } + } if (name != "") { //if this name is in the accnos file @@ -485,13 +490,18 @@ int GetSeqsCommand::readQual(){ string name = ""; string scores = ""; - in >> name; + in >> name; + + if (!dups) {//adjust name if needed + map::iterator it = uniqueMap.find(name); + if (it != uniqueMap.end()) { name = it->second; } + } if (name.length() != 0) { saveName = name.substr(1); while (!in.eof()) { char c = in.get(); - if (c == 10 || c == 13){ break; } + if (c == 10 || c == 13 || c == -1){ break; } else { name += c; } } m->gobble(in); @@ -748,6 +758,8 @@ int GetSeqsCommand::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] << ','; } @@ -805,6 +817,7 @@ int GetSeqsCommand::readGroup(){ in >> name; //read from first column in >> group; //read from second column + //if this name is in the accnos file if (names.count(name) != 0) { @@ -862,6 +875,11 @@ int GetSeqsCommand::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) { @@ -924,6 +942,11 @@ int GetSeqsCommand::readAlign(){ 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) {