X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=mothurout.cpp;h=1f1c96b6f203e4f1fa8b1dca2e018c735caa6b9f;hp=96c7305b6a1fb50f42f9c2a650d0c854ccbb6f2c;hb=b25ede2ad307ae76f8a610443e0ec3ec69621ce7;hpb=b8ff3bca0560a53832723f4621fcddef7ec4e499 diff --git a/mothurout.cpp b/mothurout.cpp index 96c7305..1f1c96b 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -796,6 +796,39 @@ bool MothurOut::dirCheck(string& dirName){ } } +//********************************************************************************************************************** + +map > MothurOut::parseClasses(string classes){ + try { + map > parts; + + //treatment-age + vector pieces; splitAtDash(classes, pieces); // -> treatment, age + + for (int i = 0; i < pieces.size(); i++) { + string category = ""; string value = ""; + bool foundOpen = false; + for (int j = 0; j < pieces[i].length(); j++) { + if (control_pressed) { return parts; } + + if (pieces[i][j] == '<') { foundOpen = true; } + else if (pieces[i][j] == '>') { j += pieces[i].length(); } + else { + if (!foundOpen) { category += pieces[i][j]; } + else { value += pieces[i][j]; } + } + } + vector values; splitAtChar(value, values, '|'); + parts[category] = values; + } + + return parts; + } + catch(exception& e) { + errorOut(e, "MothurOut", "parseClasses"); + exit(1); + } +} /***********************************************************************/ string MothurOut::hasPath(string longName){