5 // Created by Sarah Westcott on 4/16/12.
6 // Copyright (c) 2012 Schloss Lab. All rights reserved.
9 #include "makebiomcommand.h"
10 #include "sharedrabundvector.h"
11 #include "inputdata.h"
12 #include "sharedutilities.h"
14 //taken from http://biom-format.org/documentation/biom_format.html
18 "format": "Biological Observation Matrix 0.9.1",
19 "format_url": "http://biom-format.org",
21 "generated_by": "QIIME revision 1.4.0-dev",
22 "date": "2011-12-19T19:00:00",
24 {"id":"GG_OTU_1", "metadata":null},
25 {"id":"GG_OTU_2", "metadata":null},
26 {"id":"GG_OTU_3", "metadata":null},
27 {"id":"GG_OTU_4", "metadata":null},
28 {"id":"GG_OTU_5", "metadata":null}
31 {"id":"Sample1", "metadata":null},
32 {"id":"Sample2", "metadata":null},
33 {"id":"Sample3", "metadata":null},
34 {"id":"Sample4", "metadata":null},
35 {"id":"Sample5", "metadata":null},
36 {"id":"Sample6", "metadata":null}
38 "matrix_type": "sparse",
39 "matrix_element_type": "int",
62 "format": "Biological Observation Matrix 0.9.1",
63 "format_url": "http://biom-format.org",
65 "generated_by": "QIIME revision 1.4.0-dev",
66 "date": "2011-12-19T19:00:00",
68 {"id":"GG_OTU_1", "metadata":null},
69 {"id":"GG_OTU_2", "metadata":null},
70 {"id":"GG_OTU_3", "metadata":null},
71 {"id":"GG_OTU_4", "metadata":null},
72 {"id":"GG_OTU_5", "metadata":null}
75 {"id":"Sample1", "metadata":null},
76 {"id":"Sample2", "metadata":null},
77 {"id":"Sample3", "metadata":null},
78 {"id":"Sample4", "metadata":null},
79 {"id":"Sample5", "metadata":null},
80 {"id":"Sample6", "metadata":null}
82 "matrix_type": "dense",
83 "matrix_element_type": "int",
85 "data": [[0,0,1,0,0,0],
92 //**********************************************************************************************************************
93 vector<string> MakeBiomCommand::setParameters(){
95 CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","biom",false,true,true); parameters.push_back(pshared);
96 CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pcontaxonomy);
97 CommandParameter pmetadata("metadata", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pmetadata);
98 CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
99 CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
100 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
101 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
102 CommandParameter pmatrixtype("matrixtype", "Multiple", "sparse-dense", "sparse", "", "", "","",false,false); parameters.push_back(pmatrixtype);
104 vector<string> myArray;
105 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
108 catch(exception& e) {
109 m->errorOut(e, "MakeBiomCommand", "setParameters");
113 //**********************************************************************************************************************
114 string MakeBiomCommand::getHelpString(){
116 string helpString = "";
117 helpString += "The make.biom command parameters are shared, contaxonomy, metadata, groups, matrixtype and label. shared is required, unless you have a valid current file.\n";
118 helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
119 helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
120 helpString += "The matrixtype parameter allows you to select what type you would like to make. Choices are sparse and dense, default is sparse.\n";
121 helpString += "The contaxonomy file is the taxonomy file outputted by classify.otu(list=yourListfile, taxonomy=yourTaxonomyFile). Be SURE that the you are the constaxonomy file distance matches the shared file distance. ie, for *.0.03.cons.taxonomy set label=0.03. Mothur is smart enough to handle shared files that have been subsampled. It is used to assign taxonomy information to the metadata of rows.\n";
122 helpString += "The metadata parameter is used to provide experimental parameters to the columns. Things like 'sample1 gut human_gut'. \n";
123 helpString += "The make.biom command should be in the following format: make.biom(shared=yourShared, groups=yourGroups, label=yourLabels).\n";
124 helpString += "Example make.biom(shared=abrecovery.an.shared, groups=A-B-C).\n";
125 helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
126 helpString += "The make.biom command outputs a .biom file.\n";
127 helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
130 catch(exception& e) {
131 m->errorOut(e, "MakeBiomCommand", "getHelpString");
135 //**********************************************************************************************************************
136 string MakeBiomCommand::getOutputPattern(string type) {
140 if (type == "biom") { pattern = "[filename],[distance],biom"; }
141 else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
145 catch(exception& e) {
146 m->errorOut(e, "MakeBiomCommand", "getOutputPattern");
151 //**********************************************************************************************************************
152 MakeBiomCommand::MakeBiomCommand(){
154 abort = true; calledHelp = true;
156 vector<string> tempOutNames;
157 outputTypes["biom"] = tempOutNames;
159 catch(exception& e) {
160 m->errorOut(e, "MakeBiomCommand", "MakeBiomCommand");
164 //**********************************************************************************************************************
165 MakeBiomCommand::MakeBiomCommand(string option) {
167 abort = false; calledHelp = false;
170 //allow user to run help
171 if(option == "help") { help(); abort = true; calledHelp = true; }
172 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
175 vector<string> myArray = setParameters();
177 OptionParser parser(option);
178 map<string,string> parameters = parser.getParameters();
179 map<string,string>::iterator it;
181 ValidParameters validParameter;
183 //check to make sure all parameters are valid for command
184 for (it = parameters.begin(); it != parameters.end(); it++) {
185 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
188 //initialize outputTypes
189 vector<string> tempOutNames;
190 outputTypes["biom"] = tempOutNames;
192 //if the user changes the input directory command factory will send this info to us in the output parameter
193 string inputDir = validParameter.validFile(parameters, "inputdir", false);
194 if (inputDir == "not found"){ inputDir = ""; }
197 it = parameters.find("shared");
198 //user has given a template file
199 if(it != parameters.end()){
200 path = m->hasPath(it->second);
201 //if the user has not given a path then, add inputdir. else leave path alone.
202 if (path == "") { parameters["shared"] = inputDir + it->second; }
205 it = parameters.find("contaxonomy");
206 //user has given a template file
207 if(it != parameters.end()){
208 path = m->hasPath(it->second);
209 //if the user has not given a path then, add inputdir. else leave path alone.
210 if (path == "") { parameters["contaxonomy"] = inputDir + it->second; }
213 it = parameters.find("metadata");
214 //user has given a template file
215 if(it != parameters.end()){
216 path = m->hasPath(it->second);
217 //if the user has not given a path then, add inputdir. else leave path alone.
218 if (path == "") { parameters["metadata"] = inputDir + it->second; }
223 sharedfile = validParameter.validFile(parameters, "shared", true);
224 if (sharedfile == "not open") { sharedfile = ""; abort = true; }
225 else if (sharedfile == "not found") {
226 //if there is a current shared file, use it
227 sharedfile = m->getSharedFile();
228 if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
229 else { m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
230 }else { m->setSharedFile(sharedfile); }
233 //if the user changes the output directory command factory will send this info to us in the output parameter
234 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(sharedfile); }
236 contaxonomyfile = validParameter.validFile(parameters, "contaxonomy", true);
237 if (contaxonomyfile == "not found") { contaxonomyfile = ""; }
238 else if (contaxonomyfile == "not open") { contaxonomyfile = ""; abort = true; }
240 metadatafile = validParameter.validFile(parameters, "metadata", true);
241 if (metadatafile == "not found") { metadatafile = ""; }
242 else if (metadatafile == "not open") { metadatafile = ""; abort = true; }
244 //check for optional parameter and set defaults
245 // ...at some point should added some additional type checking...
246 label = validParameter.validFile(parameters, "label", false);
247 if (label == "not found") { label = ""; }
249 if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
250 else { allLines = 1; }
253 groups = validParameter.validFile(parameters, "groups", false);
254 if (groups == "not found") { groups = ""; }
256 m->splitAtDash(groups, Groups);
257 m->setGroups(Groups);
260 if ((contaxonomyfile != "") && (labels.size() > 1)) { m->mothurOut("[ERROR]: the contaxonomy parameter cannot be used with multiple labels."); m->mothurOutEndLine(); abort = true; }
262 format = validParameter.validFile(parameters, "matrixtype", false); if (format == "not found") { format = "sparse"; }
264 if ((format != "sparse") && (format != "dense")) {
265 m->mothurOut(format + " is not a valid option for the matrixtype parameter. Options are sparse and dense."); m->mothurOutEndLine(); abort = true;
270 catch(exception& e) {
271 m->errorOut(e, "MakeBiomCommand", "MakeBiomCommand");
275 //**********************************************************************************************************************
277 int MakeBiomCommand::execute(){
280 if (abort == true) { if (calledHelp) { return 0; } return 2; }
282 InputData input(sharedfile, "sharedfile");
283 vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
284 string lastLabel = lookup[0]->getLabel();
286 //if user did not specify a label, then use first one
287 if ((contaxonomyfile != "") && (labels.size() == 0)) {
289 labels.insert(lastLabel);
292 getSampleMetaData(lookup);
294 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
295 set<string> processedLabels;
296 set<string> userLabels = labels;
298 //as long as you are not at the end of the file or done wih the lines you want
299 while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
301 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
303 if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
305 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
308 processedLabels.insert(lookup[0]->getLabel());
309 userLabels.erase(lookup[0]->getLabel());
312 if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
313 string saveLabel = lookup[0]->getLabel();
315 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
316 lookup = input.getSharedRAbundVectors(lastLabel);
317 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
321 processedLabels.insert(lookup[0]->getLabel());
322 userLabels.erase(lookup[0]->getLabel());
324 //restore real lastlabel to save below
325 lookup[0]->setLabel(saveLabel);
328 lastLabel = lookup[0]->getLabel();
330 //prevent memory leak and get next set
331 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
332 lookup = input.getSharedRAbundVectors();
335 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
337 //output error messages about any remaining user labels
338 set<string>::iterator it;
339 bool needToRun = false;
340 for (it = userLabels.begin(); it != userLabels.end(); it++) {
341 m->mothurOut("Your file does not include the label " + *it);
342 if (processedLabels.count(lastLabel) != 1) {
343 m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
346 m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
350 //run last label if you need to
351 if (needToRun == true) {
352 for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
353 lookup = input.getSharedRAbundVectors(lastLabel);
355 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
358 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
361 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
363 //set sabund file as new current sabundfile
365 itTypes = outputTypes.find("biom");
366 if (itTypes != outputTypes.end()) {
367 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setBiomFile(current); }
371 m->mothurOutEndLine();
372 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
373 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
374 m->mothurOutEndLine();
378 catch(exception& e) {
379 m->errorOut(e, "MakeBiomCommand", "execute");
383 //**********************************************************************************************************************
384 int MakeBiomCommand::getBiom(vector<SharedRAbundVector*>& lookup){
386 map<string, string> variables;
387 variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
388 variables["[distance]"] = lookup[0]->getLabel();
389 string outputFileName = getOutputFileName("biom",variables);
391 m->openOutputFile(outputFileName, out);
392 outputNames.push_back(outputFileName); outputTypes["biom"].push_back(outputFileName);
394 string mothurString = "mothur" + toString(m->getVersion());
396 struct tm * timeinfo;
398 timeinfo = localtime ( &rawtime );
399 string dateString = asctime (timeinfo);
400 int pos = dateString.find('\n');
401 if (pos != string::npos) { dateString = dateString.substr(0, pos);}
405 out << "{\n" + spaces + "\"id\":\"" + sharedfile + "-" + lookup[0]->getLabel() + "\",\n" + spaces + "\"format\": \"Biological Observation Matrix 0.9.1\",\n" + spaces + "\"format_url\": \"http://biom-format.org\",\n";
406 out << spaces + "\"type\": \"OTU table\",\n" + spaces + "\"generated_by\": \"" << mothurString << "\",\n" + spaces + "\"date\": \"" << dateString << "\",\n";
408 vector<string> metadata = getMetaData(lookup);
410 if (m->control_pressed) { out.close(); return 0; }
414 {"id":"GG_OTU_1", "metadata":null},
415 {"id":"GG_OTU_2", "metadata":null},
416 {"id":"GG_OTU_3", "metadata":null},
417 {"id":"GG_OTU_4", "metadata":null},
418 {"id":"GG_OTU_5", "metadata":null}
420 out << spaces + "\"rows\":[\n";
421 string rowFront = spaces + spaces + "{\"id\":\"";
422 string rowBack = "\", \"metadata\":";
423 for (int i = 0; i < m->currentBinLabels.size()-1; i++) {
424 if (m->control_pressed) { out.close(); return 0; }
425 out << rowFront << m->currentBinLabels[i] << rowBack << metadata[i] << "},\n";
427 out << rowFront << m->currentBinLabels[(m->currentBinLabels.size()-1)] << rowBack << metadata[(m->currentBinLabels.size()-1)] << "}\n" + spaces + "],\n";
431 {"id":"Sample1", "metadata":null},
432 {"id":"Sample2", "metadata":null},
433 {"id":"Sample3", "metadata":null},
434 {"id":"Sample4", "metadata":null},
435 {"id":"Sample5", "metadata":null},
436 {"id":"Sample6", "metadata":null}
439 string colBack = "\", \"metadata\":";
440 out << spaces + "\"columns\":[\n";
441 for (int i = 0; i < lookup.size()-1; i++) {
442 if (m->control_pressed) { out.close(); return 0; }
443 out << rowFront << lookup[i]->getGroup() << colBack << sampleMetadata[i] << "},\n";
445 out << rowFront << lookup[(lookup.size()-1)]->getGroup() << colBack << sampleMetadata[lookup.size()-1] << "}\n" + spaces + "],\n";
447 out << spaces + "\"matrix_type\": \"" << format << "\",\n" + spaces + "\"matrix_element_type\": \"int\",\n";
448 out << spaces + "\"shape\": [" << m->currentBinLabels.size() << "," << lookup.size() << "],\n";
449 out << spaces + "\"data\": [";
451 vector<string> dataRows;
452 if (format == "sparse") {
470 for (int i = 0; i < lookup[0]->getNumBins(); i++) {
472 if (m->control_pressed) { out.close(); return 0; }
474 for (int j = 0; j < lookup.size(); j++) {
475 string binInfo = "[" + toString(i) + "," + toString(j) + "," + toString(lookup[j]->getAbundance(i)) + "]";
476 //only print non zero values
477 if (lookup[j]->getAbundance(i) != 0) { dataRows.push_back(binInfo); }
482 /* "matrix_type": "dense",
483 "matrix_element_type": "int",
485 "data": [[0,0,1,0,0,0],
491 for (int i = 0; i < lookup[0]->getNumBins(); i++) {
493 if (m->control_pressed) { out.close(); return 0; }
495 string binInfo = "[";
496 for (int j = 0; j < lookup.size()-1; j++) {
497 binInfo += toString(lookup[j]->getAbundance(i)) + ",";
499 binInfo += toString(lookup[lookup.size()-1]->getAbundance(i)) + "]";
500 dataRows.push_back(binInfo);
504 for (int i = 0; i < dataRows.size()-1; i++) {
505 out << dataRows[i] << ",\n" + spaces + spaces;
507 out << dataRows[dataRows.size()-1] << "]\n";
514 catch(exception& e) {
515 m->errorOut(e, "MakeBiomCommand", "getBiom");
519 //**********************************************************************************************************************
520 vector<string> MakeBiomCommand::getMetaData(vector<SharedRAbundVector*>& lookup){
522 vector<string> metadata;
524 if (contaxonomyfile == "") { for (int i = 0; i < lookup[0]->getNumBins(); i++) { metadata.push_back("null"); } }
527 //read constaxonomy file storing in a map, otulabel -> taxonomy
528 //constaxonomy file will most likely contain more labels than the shared file, because sharedfile could have been subsampled.
530 m->openInputFile(contaxonomyfile, in);
533 m->getline(in); m->gobble(in);
535 string otuLabel, tax;
537 vector<string> otuLabels;
541 if (m->control_pressed) { in.close(); return metadata; }
543 in >> otuLabel >> size >> tax; m->gobble(in);
545 otuLabels.push_back(otuLabel);
550 //should the labels be Otu001 or PhyloType001
551 string firstBin = m->currentBinLabels[0];
552 string binTag = "Otu";
553 if ((firstBin.find("Otu")) == string::npos) { binTag = "PhyloType"; }
555 //convert list file bin labels to shared file bin labels
558 map<string, string> labelTaxMap;
559 string snumBins = toString(otuLabels.size());
560 for (int i = 0; i < otuLabels.size(); i++) {
562 if (m->control_pressed) { return metadata; }
564 //if there is a bin label use it otherwise make one
565 if (m->isContainingOnlyDigits(otuLabels[i])) {
566 string binLabel = binTag;
567 string sbinNumber = otuLabels[i];
568 if (sbinNumber.length() < snumBins.length()) {
569 int diff = snumBins.length() - sbinNumber.length();
570 for (int h = 0; h < diff; h++) { binLabel += "0"; }
572 binLabel += sbinNumber;
573 labelTaxMap[binLabel] = taxs[i];
574 }else { labelTaxMap[otuLabels[i]] = taxs[i]; }
578 //{"taxonomy":["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}
580 //traverse the binLabels forming the metadata strings and saving them
581 //make sure to sanity check
582 map<string, string>::iterator it;
583 for (int i = 0; i < m->currentBinLabels.size(); i++) {
585 if (m->control_pressed) { return metadata; }
587 it = labelTaxMap.find(m->currentBinLabels[i]);
589 if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentBinLabels[i] + ".\n"); m->control_pressed = true; }
591 vector<string> bootstrapValues;
592 string data = "{\"taxonomy\":[";
594 vector<string> scores;
595 vector<string> taxonomies = parseTax(it->second, scores);
597 for (int j = 0; j < taxonomies.size()-1; j ++) { data += "\"" + taxonomies[j] + "\", "; }
598 data += "\"" + taxonomies[taxonomies.size()-1] + "\"]";
600 //add bootstrap values if available
601 if (scores[0] != "null") {
602 data += ", \"bootstrap\":[";
604 for (int j = 0; j < scores.size()-1; j ++) { data += scores[j] + ", "; }
605 data += scores[scores.size()-1] + "]";
610 metadata.push_back(data);
618 catch(exception& e) {
619 m->errorOut(e, "MakeBiomCommand", "getMetadata");
624 //**********************************************************************************************************************
625 int MakeBiomCommand::getSampleMetaData(vector<SharedRAbundVector*>& lookup){
628 if (metadatafile == "") { for (int i = 0; i < lookup.size(); i++) { sampleMetadata.push_back("null"); } }
631 m->openInputFile(metadatafile, in);
633 vector<string> groupNames, metadataLabels;
634 map<string, vector<string> > lines;
636 string headerLine = m->getline(in); m->gobble(in);
637 vector<string> pieces = m->splitWhiteSpace(headerLine);
639 //save names of columns you are reading
640 for (int i = 1; i < pieces.size(); i++) {
641 metadataLabels.push_back(pieces[i]);
643 int count = metadataLabels.size();
645 vector<string> groups = m->getGroups();
650 if (m->control_pressed) { in.close(); return 0; }
653 in >> group; m->gobble(in);
654 groupNames.push_back(group);
656 string line = m->getline(in); m->gobble(in);
657 vector<string> thisPieces = m->splitWhiteSpaceWithQuotes(line);
659 if (thisPieces.size() != count) { m->mothurOut("[ERROR]: expected " + toString(count) + " items of data for sample " + group + " read " + toString(thisPieces.size()) + ", quitting.\n"); }
660 else { if (m->inUsersGroups(group, groups)) { lines[group] = thisPieces; } }
666 map<string, vector<string> >::iterator it;
667 for (int i = 0; i < lookup.size(); i++) {
669 if (m->control_pressed) { return 0; }
671 it = lines.find(lookup[i]->getGroup());
673 if (it == lines.end()) { m->mothurOut("[ERROR]: can't find metadata information for " + lookup[i]->getGroup() + ", quitting.\n"); m->control_pressed = true; }
675 vector<string> values = it->second;
678 for (int j = 0; j < metadataLabels.size()-1; j++) {
679 values[j] = m->removeQuotes(values[j]);
680 data += "\"" + metadataLabels[j] + "\":\"" + values[j] + "\", ";
682 values[metadataLabels.size()-1] = m->removeQuotes(values[metadataLabels.size()-1]);
683 data += "\"" + metadataLabels[metadataLabels.size()-1] + "\":\"" + values[metadataLabels.size()-1] + "\"}";
684 sampleMetadata.push_back(data);
692 catch(exception& e) {
693 m->errorOut(e, "MakeBiomCommand", "getSampleMetaData");
699 /**************************************************************************************************/
700 //returns {Bacteria, Bacteroidetes, ..} and scores is filled with {100, 98, ...} or {null, null, null}
701 vector<string> MakeBiomCommand::parseTax(string tax, vector<string>& scores) {
707 while (tax.find_first_of(';') != -1) {
709 if (m->control_pressed) { return taxs; }
712 taxon = tax.substr(0,tax.find_first_of(';'));
714 int pos = taxon.find_last_of('(');
717 int pos2 = taxon.find_last_of(')');
719 string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1)));
720 if (m->isNumeric1(confidenceScore)) {
721 taxon = taxon.substr(0, pos); //rip off confidence
722 scores.push_back(confidenceScore);
723 }else{ scores.push_back("null"); }
725 }else{ scores.push_back("null"); }
727 //strip "" if they are there
728 pos = taxon.find("\"");
729 if (pos != string::npos) {
731 for (int k = 0; k < taxon.length(); k++) {
732 if (taxon[k] != '\"') { newTax += taxon[k]; }
737 //look for bootstrap value
738 taxs.push_back(taxon);
739 tax = tax.substr(tax.find_first_of(';')+1, tax.length());
744 catch(exception& e) {
745 m->errorOut(e, "MakeBiomCommand", "parseTax");
750 //**********************************************************************************************************************