X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parselistcommand.cpp;h=d9925ad40ecd02cc1580e7d087b6b5acb3514831;hb=cfb66eb46a9678a751a8f21f3ea740dffd525f5e;hp=8a848e768fd5c4c2775bec636be6acf64dd5d2ac;hpb=20a2d0350a737a434c89f303662d64a8eeea7b05;p=mothur.git diff --git a/parselistcommand.cpp b/parselistcommand.cpp index 8a848e7..d9925ad 100644 --- a/parselistcommand.cpp +++ b/parselistcommand.cpp @@ -27,12 +27,7 @@ ParseListCommand::ParseListCommand(){ } //set fileroot - if(globaldata->getFileRoot() != ""){ - fileroot = globaldata->getFileRoot(); - } - else{ - fileroot = getRootName(globaldata->getDistFile()); - } + fileroot = getRootName(globaldata->getListFile()); //open output list files for (i=0; igetNumGroups(); i++) {//opens an output file for each group @@ -91,13 +86,13 @@ void ParseListCommand::parse(int index) { int ParseListCommand::execute(){ try{ globaldata = GlobalData::getInstance(); + int count = 1; //read in listfile read = new ReadPhilFile(globaldata->inputFileName); read->read(&*globaldata); input = globaldata->ginput; - //list = input->getListVector(); - list = globaldata->glist; + list = globaldata->gSharedList; //read in group map info. groupMap = new GroupMap(globaldata->getGroupFile()); @@ -107,29 +102,41 @@ int ParseListCommand::execute(){ int i; //create new list vectors to fill with parsed data for (i=0; igetNumGroups(); i++) { - groupOfLists[groupMap->namesOfGroups[i]] = new ListVector(); + groupOfLists[groupMap->namesOfGroups[i]] = new SharedListVector(); } //parses and sets each groups listvector while(list != NULL){ label = list->getLabel(); - for(i=0; isize(); i++) { - parse(i); //parses data[i] list of sequence names - for (it=listGroups.begin(); it != listGroups.end(); it++) { //loop through map and set new list vectors - seq = it->second; - seq = seq.substr(1, seq.length()); //rips off extra comma - groupOfLists[it->first]->push_back(seq); //sets new listvector for each group + + if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(label) == 1){ + + for(i=0; isize(); i++) { + parse(i); //parses data[i] list of sequence names + for (it=listGroups.begin(); it != listGroups.end(); it++) { //loop through map and set new list vectors + seq = it->second; + seq = seq.substr(1, seq.length()); //rips off extra comma + groupOfLists[it->first]->push_back(seq); //sets new listvector for each group + } + listGroups.clear(); } - listGroups.clear(); - } - //prints each new list file - for (i=0; igetNumGroups(); i++) { - groupOfLists[groupMap->namesOfGroups[i]]->setLabel(label); - groupOfLists[groupMap->namesOfGroups[i]]->print(*(filehandles[groupMap->namesOfGroups[i]])); - groupOfLists[groupMap->namesOfGroups[i]]->clear(); + //prints each new list file + for (i=0; igetNumGroups(); i++) { + groupOfLists[groupMap->namesOfGroups[i]]->setLabel(label); + groupOfLists[groupMap->namesOfGroups[i]]->print(*(filehandles[groupMap->namesOfGroups[i]])); + groupOfLists[groupMap->namesOfGroups[i]]->clear(); + } + + cout << label << '\t' << count << endl; } - list = input->getListVector(); + + list = input->getSharedListVector(); + count++; } + + //set groupmap for .shared commands + globaldata->gGroupmap = groupMap; + return 0; } catch(exception& e) { @@ -146,7 +153,6 @@ int ParseListCommand::execute(){ ParseListCommand::~ParseListCommand(){ delete list; - delete groupMap; delete input; delete read; }