X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=makebiomcommand.cpp;h=36bda1580bf55c50aa122e36c023b2d112899953;hb=HEAD;hp=826cf372c7b4ae52f5e230e839a576adb2ec58b5;hpb=fe08eacea5a2d34cd4bd27e8451fd2872102a80a;p=mothur.git diff --git a/makebiomcommand.cpp b/makebiomcommand.cpp index 826cf37..36bda15 100644 --- a/makebiomcommand.cpp +++ b/makebiomcommand.cpp @@ -680,8 +680,17 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector& lookup, ma for (map::iterator it = labelTaxMap.begin(); it != labelTaxMap.end(); it++) { //maps label -> consensus taxonomy if (m->control_pressed) { break; } + string OTUTaxonomy = it->second; + + //remove confidences + m->removeConfidences(OTUTaxonomy); + + //remove unclassifieds to match template + int thisPos = OTUTaxonomy.find("unclassified;"); + if (thisPos != string::npos) { OTUTaxonomy = OTUTaxonomy.substr(0, thisPos); } + //get list of reference ids that map to this taxonomy - vector referenceIds = phylo.getSeqs(it->second); + vector referenceIds = phylo.getSeqs(OTUTaxonomy); if (m->control_pressed) { break; } @@ -724,6 +733,7 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector& lookup, ma map newLabelTaxMap; //loop through ggOTUID list combining mothur otus and adjusting labels //ggOTUIDs = 16097 -> + for (map >::iterator itMap = ggOTUIDs.begin(); itMap != ggOTUIDs.end(); itMap++) { if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } return 0; } @@ -737,14 +747,18 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector& lookup, ma vector abunds; abunds.resize(lookup.size(), 0); string mergeString = ""; vector boots; boots.resize(scores.size(), 0); + bool scoresNULL = false; for (int j = 0; j < itMap->second.size(); j++) { // - //merge bootstrap scores - vector scores; - vector taxonomies = parseTax(it->second, scores); - for (int i = 0; i < boots.size(); i++) { - float tempScore; m->mothurConvert(scores[i], tempScore); - boots[i] += tempScore; - } + + if (scores[0] != "null") { + //merge bootstrap scores + vector scores; + vector taxonomies = parseTax(it->second, scores); + for (int i = 0; i < boots.size(); i++) { + float tempScore; m->mothurConvert(scores[i], tempScore); + boots[i] += tempScore; + } + }else { scoresNULL = true; } //merge abunds mergeString += (itMap->second)[j] + " "; @@ -757,14 +771,21 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector& lookup, ma //average scores //add merged otu to new lookup - for (int j = 0; j < boots.size(); j++) { boots[j] /= (float) itMap->second.size(); } - - //assemble new taxomoy string newTaxString = ""; - for (int j = 0; j < boots.size(); j++) { - newTaxString += taxonomies[j] + "(" + toString(boots[j]) + ");"; + if (!scoresNULL) { + for (int j = 0; j < boots.size(); j++) { boots[j] /= (float) itMap->second.size(); } + + //assemble new taxomoy + for (int j = 0; j < boots.size(); j++) { + newTaxString += taxonomies[j] + "(" + toString(boots[j]) + ");"; + } + }else { + //assemble new taxomoy + for (int j = 0; j < taxonomies.size(); j++) { + newTaxString += taxonomies[j] + ";"; + } } - + //set new gg otu id to taxonomy. OTU01 -> k__Bacteria becomes 16097 -> k__Bacteria //find taxonomy of this otu newLabelTaxMap[itMap->first] = newTaxString; @@ -824,7 +845,7 @@ map MakeBiomCommand::readGGOtuMap(){ vector pieces = m->splitWhiteSpace(line); if (pieces.size() != 0) { - string otuID = pieces[0]; + string otuID = pieces[1]; for (int i = 1; i < pieces.size(); i++) { otuMap[pieces[i]] = otuID; } } }