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";
out << spaces + "\"type\": \"OTU table\",\n" + spaces + "\"generated_by\": \"" << mothurString << "\",\n" + spaces + "\"date\": \"" << dateString << "\",\n";
+ int numBins = lookup[0]->getNumBins();
vector<string> metadata = getMetaData(lookup);
if (m->control_pressed) { out.close(); return 0; }
out << spaces + "\"rows\":[\n";
string rowFront = spaces + spaces + "{\"id\":\"";
string rowBack = "\", \"metadata\":";
- for (int i = 0; i < m->currentBinLabels.size()-1; i++) {
+ for (int i = 0; i < numBins-1; i++) {
if (m->control_pressed) { out.close(); return 0; }
out << rowFront << m->currentBinLabels[i] << rowBack << metadata[i] << "},\n";
}
- out << rowFront << m->currentBinLabels[(m->currentBinLabels.size()-1)] << rowBack << metadata[(m->currentBinLabels.size()-1)] << "}\n" + spaces + "],\n";
+ out << rowFront << m->currentBinLabels[(numBins-1)] << rowBack << metadata[(numBins-1)] << "}\n" + spaces + "],\n";
//get column info
/*"columns": [
//**********************************************************************************************************************
int MakeBiomCommand::getSampleMetaData(vector<SharedRAbundVector*>& lookup){
try {
-
- if (metadatafile == "") { for (int i = 0; i < lookup.size(); i++) { sampleMetadata.push_back("null"); } }
+ sampleMetadata.clear();
+ if (metadatafile == "") { for (int i = 0; i < lookup.size(); i++) { sampleMetadata.push_back("null"); } }
else {
ifstream in;
m->openInputFile(metadatafile, in);