Permalink
Browse files

Fixes taxon_unclassified bug

  • Loading branch information...
1 parent 32aafff commit ee7be1e0724f2cfe7f3346c83bda6d5e84263bb0 @mothur-westcott mothur-westcott committed Sep 14, 2016
Showing with 17 additions and 14 deletions.
  1. +11 −11 source/classifier/phylosummary.cpp
  2. +1 −1 source/commands/classifyseqscommand.cpp
  3. +5 −2 source/mothurout.cpp
@@ -177,6 +177,8 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
while (seqTaxonomy != "") {
+ level++;
+
if (m->control_pressed) { return 0; }
//somehow the parent is getting one too many accnos
@@ -287,12 +289,10 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
break;
}
}
-
- level++;
-
- if (level > maxLevel) { maxLevel = level; }
-
}
+
+ if (level > maxLevel) { maxLevel = level; }
+
return 0;
}
catch(exception& e) {
@@ -318,6 +318,8 @@ int PhyloSummary::addSeqToTree(string seqTaxonomy, map<string, bool> containsGro
while (seqTaxonomy != "") {
+ level++;
+
if (m->control_pressed) { return 0; }
//somehow the parent is getting one too many accnos
@@ -343,7 +345,7 @@ int PhyloSummary::addSeqToTree(string seqTaxonomy, map<string, bool> containsGro
int index = tree.size() - 1;
tree[index].parent = currentNode;
- tree[index].level = (level+1);
+ tree[index].level = level;
tree[index].total = 1;
tree[currentNode].children[taxon] = index;
@@ -360,12 +362,10 @@ int PhyloSummary::addSeqToTree(string seqTaxonomy, map<string, bool> containsGro
break;
}
}
-
- level++;
-
- if (level > maxLevel) { maxLevel = level; }
-
}
+
+ if (level > maxLevel) { maxLevel = level; }
+
return 0;
}
catch(exception& e) {
@@ -748,7 +748,7 @@ int ClassifySeqsCommand::execute(){
outTax.close();
m->mothurRemove(newTaxonomyFile);
- rename(unclass.c_str(), newTaxonomyFile.c_str());
+ m->renameFile(unclass, newTaxonomyFile);
if (m->control_pressed) { outputTypes.clear(); if (ct != NULL) { delete ct; } if (groupMap != NULL) { delete groupMap; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete classify; return 0; }
View
@@ -3434,13 +3434,16 @@ bool MothurOut::mothurConvert(string item, intDist& num){
string MothurOut::addUnclassifieds(string tax, int maxlevel, bool probs) {
try{
string newTax, taxon;
- int level = 1;
+ string savedTax = tax;
vector<string> taxons; splitAtChar(tax, taxons, ';'); taxons.pop_back();
vector<int> confidences;
+ if (taxons.size() == maxlevel) { return savedTax; }
+
int index = 0;
int confidence = 0;
+ int level = 1;
for (int i = 0; i < taxons.size(); i++) {
index = i;
string thisTax = taxons[i]+";";
@@ -3450,7 +3453,7 @@ string MothurOut::addUnclassifieds(string tax, int maxlevel, bool probs) {
if (thisTax == "unclassified;"){ index--; break; }
else{ newTax += taxons[i] + ";"; }
}
- level = index+2;
+ level = index+1;
string thisTax = taxons[index]+";";

0 comments on commit ee7be1e

Please sign in to comment.