X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=groupmap.cpp;h=9e9955671e41a6cfff3dc882e29ccbc4de9414ca;hb=4169642e8a8d45f71a4a7241ee02f1b1aae29520;hp=0e0be0e8cf2799527e2664bb79b1cdded09e215c;hpb=87537e4ee46cae9b7041ae0ed4dbbc229936d37c;p=mothur.git diff --git a/groupmap.cpp b/groupmap.cpp index 0e0be0e..9e99556 100644 --- a/groupmap.cpp +++ b/groupmap.cpp @@ -46,6 +46,32 @@ int GroupMap::readMap() { fileHandle.close(); return error; } +/************************************************************/ +int GroupMap::readDesignMap() { + string seqName, seqGroup; + int error = 0; + + while(fileHandle){ + fileHandle >> seqName; m->gobble(fileHandle); //read from first column + fileHandle >> seqGroup; //read from second column + + if (m->control_pressed) { fileHandle.close(); return 1; } + + setNamesOfGroups(seqGroup); + + it = groupmap.find(seqName); + + if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 group named " + seqName + ", group names must be unique. Please correct."); m->mothurOutEndLine(); } + else { + groupmap[seqName] = seqGroup; //store data in map + seqsPerGroup[seqGroup]++; //increment number of seqs in that group + } + m->gobble(fileHandle); + } + fileHandle.close(); + return error; +} + /************************************************************/ int GroupMap::getNumGroups() { return namesOfGroups.size(); } /************************************************************/ @@ -135,4 +161,25 @@ vector GroupMap::getNamesSeqs(){ } } /************************************************************/ +vector GroupMap::getNamesSeqs(vector picked){ + try { + + vector names; + + for (it = groupmap.begin(); it != groupmap.end(); it++) { + //if you are belong to one the the groups in the picked vector add you + if (m->inUsersGroups(it->second, picked)) { + names.push_back(it->first); + } + } + + return names; + } + catch(exception& e) { + m->errorOut(e, "GroupMap", "getNamesSeqs"); + exit(1); + } +} + +/************************************************************/