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 int numBins = lookup[0]->getNumBins();
409 vector<string> metadata = getMetaData(lookup);
411 if (m->control_pressed) { out.close(); return 0; }
415 {"id":"GG_OTU_1", "metadata":null},
416 {"id":"GG_OTU_2", "metadata":null},
417 {"id":"GG_OTU_3", "metadata":null},
418 {"id":"GG_OTU_4", "metadata":null},
419 {"id":"GG_OTU_5", "metadata":null}
421 out << spaces + "\"rows\":[\n";
422 string rowFront = spaces + spaces + "{\"id\":\"";
423 string rowBack = "\", \"metadata\":";
424 for (int i = 0; i < numBins-1; i++) {
425 if (m->control_pressed) { out.close(); return 0; }
426 out << rowFront << m->currentBinLabels[i] << rowBack << metadata[i] << "},\n";
428 out << rowFront << m->currentBinLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n";
432 {"id":"Sample1", "metadata":null},
433 {"id":"Sample2", "metadata":null},
434 {"id":"Sample3", "metadata":null},
435 {"id":"Sample4", "metadata":null},
436 {"id":"Sample5", "metadata":null},
437 {"id":"Sample6", "metadata":null}
440 string colBack = "\", \"metadata\":";
441 out << spaces + "\"columns\":[\n";
442 for (int i = 0; i < lookup.size()-1; i++) {
443 if (m->control_pressed) { out.close(); return 0; }
444 out << rowFront << lookup[i]->getGroup() << colBack << sampleMetadata[i] << "},\n";
446 out << rowFront << lookup[(lookup.size()-1)]->getGroup() << colBack << sampleMetadata[lookup.size()-1] << "}\n" + spaces + "],\n";
448 out << spaces + "\"matrix_type\": \"" << format << "\",\n" + spaces + "\"matrix_element_type\": \"int\",\n";
449 out << spaces + "\"shape\": [" << m->currentBinLabels.size() << "," << lookup.size() << "],\n";
450 out << spaces + "\"data\": [";
452 vector<string> dataRows;
453 if (format == "sparse") {
471 for (int i = 0; i < lookup[0]->getNumBins(); i++) {
473 if (m->control_pressed) { out.close(); return 0; }
475 for (int j = 0; j < lookup.size(); j++) {
476 string binInfo = "[" + toString(i) + "," + toString(j) + "," + toString(lookup[j]->getAbundance(i)) + "]";
477 //only print non zero values
478 if (lookup[j]->getAbundance(i) != 0) { dataRows.push_back(binInfo); }
483 /* "matrix_type": "dense",
484 "matrix_element_type": "int",
486 "data": [[0,0,1,0,0,0],
492 for (int i = 0; i < lookup[0]->getNumBins(); i++) {
494 if (m->control_pressed) { out.close(); return 0; }
496 string binInfo = "[";
497 for (int j = 0; j < lookup.size()-1; j++) {
498 binInfo += toString(lookup[j]->getAbundance(i)) + ",";
500 binInfo += toString(lookup[lookup.size()-1]->getAbundance(i)) + "]";
501 dataRows.push_back(binInfo);
505 for (int i = 0; i < dataRows.size()-1; i++) {
506 out << dataRows[i] << ",\n" + spaces + spaces;
508 out << dataRows[dataRows.size()-1] << "]\n";
515 catch(exception& e) {
516 m->errorOut(e, "MakeBiomCommand", "getBiom");
520 //**********************************************************************************************************************
521 vector<string> MakeBiomCommand::getMetaData(vector<SharedRAbundVector*>& lookup){
523 vector<string> metadata;
525 if (contaxonomyfile == "") { for (int i = 0; i < lookup[0]->getNumBins(); i++) { metadata.push_back("null"); } }
528 //read constaxonomy file storing in a map, otulabel -> taxonomy
529 //constaxonomy file will most likely contain more labels than the shared file, because sharedfile could have been subsampled.
531 m->openInputFile(contaxonomyfile, in);
534 m->getline(in); m->gobble(in);
536 string otuLabel, tax;
538 vector<string> otuLabels;
542 if (m->control_pressed) { in.close(); return metadata; }
544 in >> otuLabel >> size >> tax; m->gobble(in);
546 otuLabels.push_back(otuLabel);
551 //should the labels be Otu001 or PhyloType001
552 string firstBin = m->currentBinLabels[0];
553 string binTag = "Otu";
554 if ((firstBin.find("Otu")) == string::npos) { binTag = "PhyloType"; }
556 //convert list file bin labels to shared file bin labels
559 map<string, string> labelTaxMap;
560 string snumBins = toString(otuLabels.size());
561 for (int i = 0; i < otuLabels.size(); i++) {
563 if (m->control_pressed) { return metadata; }
565 //if there is a bin label use it otherwise make one
566 if (m->isContainingOnlyDigits(otuLabels[i])) {
567 string binLabel = binTag;
568 string sbinNumber = otuLabels[i];
569 if (sbinNumber.length() < snumBins.length()) {
570 int diff = snumBins.length() - sbinNumber.length();
571 for (int h = 0; h < diff; h++) { binLabel += "0"; }
573 binLabel += sbinNumber;
574 labelTaxMap[binLabel] = taxs[i];
575 }else { labelTaxMap[otuLabels[i]] = taxs[i]; }
579 //{"taxonomy":["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}
581 //traverse the binLabels forming the metadata strings and saving them
582 //make sure to sanity check
583 map<string, string>::iterator it;
584 for (int i = 0; i < m->currentBinLabels.size(); i++) {
586 if (m->control_pressed) { return metadata; }
588 it = labelTaxMap.find(m->currentBinLabels[i]);
590 if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentBinLabels[i] + ".\n"); m->control_pressed = true; }
592 vector<string> bootstrapValues;
593 string data = "{\"taxonomy\":[";
595 vector<string> scores;
596 vector<string> taxonomies = parseTax(it->second, scores);
598 for (int j = 0; j < taxonomies.size()-1; j ++) { data += "\"" + taxonomies[j] + "\", "; }
599 data += "\"" + taxonomies[taxonomies.size()-1] + "\"]";
601 //add bootstrap values if available
602 if (scores[0] != "null") {
603 data += ", \"bootstrap\":[";
605 for (int j = 0; j < scores.size()-1; j ++) { data += scores[j] + ", "; }
606 data += scores[scores.size()-1] + "]";
611 metadata.push_back(data);
619 catch(exception& e) {
620 m->errorOut(e, "MakeBiomCommand", "getMetadata");
625 //**********************************************************************************************************************
626 int MakeBiomCommand::getSampleMetaData(vector<SharedRAbundVector*>& lookup){
628 sampleMetadata.clear();
629 if (metadatafile == "") { for (int i = 0; i < lookup.size(); i++) { sampleMetadata.push_back("null"); } }
632 m->openInputFile(metadatafile, in);
634 vector<string> groupNames, metadataLabels;
635 map<string, vector<string> > lines;
637 string headerLine = m->getline(in); m->gobble(in);
638 vector<string> pieces = m->splitWhiteSpace(headerLine);
640 //save names of columns you are reading
641 for (int i = 1; i < pieces.size(); i++) {
642 metadataLabels.push_back(pieces[i]);
644 int count = metadataLabels.size();
646 vector<string> groups = m->getGroups();
651 if (m->control_pressed) { in.close(); return 0; }
654 in >> group; m->gobble(in);
655 groupNames.push_back(group);
657 string line = m->getline(in); m->gobble(in);
658 vector<string> thisPieces = m->splitWhiteSpaceWithQuotes(line);
660 if (thisPieces.size() != count) { m->mothurOut("[ERROR]: expected " + toString(count) + " items of data for sample " + group + " read " + toString(thisPieces.size()) + ", quitting.\n"); }
661 else { if (m->inUsersGroups(group, groups)) { lines[group] = thisPieces; } }
667 map<string, vector<string> >::iterator it;
668 for (int i = 0; i < lookup.size(); i++) {
670 if (m->control_pressed) { return 0; }
672 it = lines.find(lookup[i]->getGroup());
674 if (it == lines.end()) { m->mothurOut("[ERROR]: can't find metadata information for " + lookup[i]->getGroup() + ", quitting.\n"); m->control_pressed = true; }
676 vector<string> values = it->second;
679 for (int j = 0; j < metadataLabels.size()-1; j++) {
680 values[j] = m->removeQuotes(values[j]);
681 data += "\"" + metadataLabels[j] + "\":\"" + values[j] + "\", ";
683 values[metadataLabels.size()-1] = m->removeQuotes(values[metadataLabels.size()-1]);
684 data += "\"" + metadataLabels[metadataLabels.size()-1] + "\":\"" + values[metadataLabels.size()-1] + "\"}";
685 sampleMetadata.push_back(data);
693 catch(exception& e) {
694 m->errorOut(e, "MakeBiomCommand", "getSampleMetaData");
700 /**************************************************************************************************/
701 //returns {Bacteria, Bacteroidetes, ..} and scores is filled with {100, 98, ...} or {null, null, null}
702 vector<string> MakeBiomCommand::parseTax(string tax, vector<string>& scores) {
708 while (tax.find_first_of(';') != -1) {
710 if (m->control_pressed) { return taxs; }
713 taxon = tax.substr(0,tax.find_first_of(';'));
715 int pos = taxon.find_last_of('(');
718 int pos2 = taxon.find_last_of(')');
720 string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1)));
721 if (m->isNumeric1(confidenceScore)) {
722 taxon = taxon.substr(0, pos); //rip off confidence
723 scores.push_back(confidenceScore);
724 }else{ scores.push_back("null"); }
726 }else{ scores.push_back("null"); }
728 //strip "" if they are there
729 pos = taxon.find("\"");
730 if (pos != string::npos) {
732 for (int k = 0; k < taxon.length(); k++) {
733 if (taxon[k] != '\"') { newTax += taxon[k]; }
738 //look for bootstrap value
739 taxs.push_back(taxon);
740 tax = tax.substr(tax.find_first_of(';')+1, tax.length());
745 catch(exception& e) {
746 m->errorOut(e, "MakeBiomCommand", "parseTax");
751 //**********************************************************************************************************************