Permalink
Browse files

Adds tax spaces to merge.taxsummary

  • Loading branch information...
1 parent 189fc44 commit 8fe1e55fe77faa7d12626e8221d5664d54f7c291 @mothur-westcott mothur-westcott committed Aug 25, 2016
Showing with 25 additions and 10 deletions.
  1. +25 −10 source/commands/mergetaxsummarycommand.cpp
@@ -186,34 +186,49 @@ int MergeTaxSummaryCommand::execute(){
int level, daugterLevels, total;
float totalFloat;
- string rankId, tax;
+ string rankId, tax; tax = "";
map<int, int> levelToCurrentNode;
levelToCurrentNode[0] = 0;
while (!in.eof()) {
if (m->control_pressed) { return 0; }
- in >> level >> rankId >> tax >> daugterLevels >> totalFloat; m->gobble(in);
+ in >> level >> rankId; m->gobble(in);
+ string rest = m->getline(in); m->gobble(in);
+ vector<string> pieces = m->splitWhiteSpaceWithQuotes(rest);
+
+ map<string, int> groupCounts;
+ int pcount = pieces.size()-1;
+ if (thisFilesGroups.size() != 0) {
+ for (int j = thisFilesGroups.size()-1; j >= 0; j--) {
+ int tempNum;
+ m->mothurConvert(pieces[pcount], tempNum);
+ groupCounts[thisFilesGroups[j]] = tempNum;
+ pcount--;
+ }
+ }
+
+ //column 5
+ m->mothurConvert(pieces[pcount], totalFloat); pcount--;
if ((totalFloat < 1) && (totalFloat > 0)) {
m->mothurOut("[ERROR]: cannot merge tax.summary files with relative abundances.\n"); m->control_pressed = true; in.close(); return 0;
}else {
total = int(totalFloat);
}
- map<string, int> groupCounts;
- if (thisFilesGroups.size() != 0) {
- for (int j = 0; j < thisFilesGroups.size(); j++) {
- int tempNum; in >> tempNum; m->gobble(in);
- groupCounts[thisFilesGroups[j]] = tempNum;
- }
- }
+ //column 4
+ m->mothurConvert(pieces[pcount], daugterLevels);
+
+ //assemble tax - this is done in case taxonomy contains spaces
+ tax = "";
+ for (int k = 0; k < pcount; k++) { tax += pieces[k] + " "; }
if (level == 0) {}
else {
map<int, int>::iterator itParent = levelToCurrentNode.find(level-1);
int parent = 0;
- if (itParent == levelToCurrentNode.end()) { m->mothurOut("[ERROR]: situation I didnt expect.\n"); }
+ if (itParent == levelToCurrentNode.end()) { m->mothurOut("[ERROR]: situation I didn't expect.\n"); }
else { parent = itParent->second; }
levelToCurrentNode[level] = addTaxToTree(tree, level, parent, tax, total, groupCounts);

0 comments on commit 8fe1e55

Please sign in to comment.