X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=makebiomcommand.cpp;fp=makebiomcommand.cpp;h=a1018833e6268b6d0fe04aa25d4598f37df9cb4d;hb=3a5dd9e428ab93a6dcdce7912e8ebb977be0b893;hp=a19e2e39dd805a40daee5a1ca61c3f045b6899cc;hpb=4283eb0248ca6e7e3e3344647f16166da0e14147;p=mothur.git diff --git a/makebiomcommand.cpp b/makebiomcommand.cpp index a19e2e3..a101883 100644 --- a/makebiomcommand.cpp +++ b/makebiomcommand.cpp @@ -405,6 +405,7 @@ int MakeBiomCommand::getBiom(vector& lookup){ 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 metadata = getMetaData(lookup); if (m->control_pressed) { out.close(); return 0; } @@ -420,11 +421,11 @@ int MakeBiomCommand::getBiom(vector& lookup){ 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": [ @@ -624,8 +625,8 @@ vector MakeBiomCommand::getMetaData(vector& lookup) //********************************************************************************************************************** int MakeBiomCommand::getSampleMetaData(vector& 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);