X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=seqsummarycommand.cpp;h=c328a041267d01e21ed2e99780f18de486571685;hb=cbaa068e77aeb15bb06f0695a36d8f757977ed64;hp=37d0fdfe10fdbe3eb11d3c7f74cbc84389acead9;hpb=5d00ef3e809832f08efdd691a9eace8ac20feb07;p=mothur.git diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 37d0fdf..c328a04 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -45,6 +45,26 @@ string SeqSummaryCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** +string SeqSummaryCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //is this a type this command creates + it = outputTypes.find(type); + if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } + else { + if (type == "summary") { outputFileName = "summary"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } + } + return outputFileName; + } + catch(exception& e) { + m->errorOut(e, "SeqSummaryCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** SeqSummaryCommand::SeqSummaryCommand(){ @@ -155,7 +175,7 @@ int SeqSummaryCommand::execute(){ //set current fasta to fastafile m->setFastaFile(fastafile); - string summaryFile = outputDir + m->getSimpleName(fastafile) + ".summary"; + string summaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary"); int numSeqs = 0; @@ -286,11 +306,12 @@ int SeqSummaryCommand::execute(){ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case #else vector positions; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafile, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); } #else positions = m->setFilePosFasta(fastafile, numSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numSeqs / processors; @@ -413,7 +434,7 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vector::iterator it = nameMap.find(current.getName()); - if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } + if (it == nameMap.end()) { m->mothurOut("[ERROR]: '" + current.getName() + "' is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } else { num = it->second; } } @@ -433,7 +454,7 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vector= filePos->end)) { break; } #else @@ -529,7 +550,7 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& startPosition, int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { @@ -612,7 +633,7 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& startPosition, string extension = ""; if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); } // Allocate memory for thread data. - seqSumData* tempSum = new seqSumData(&startPosition, &endPosition, &seqLength, &ambigBases, &longHomoPolymer, filename, (sumFile+extension), m, lines[i]->start, lines[i]->end, namefile, nameMap); + seqSumData* tempSum = new seqSumData(filename, (sumFile+extension), m, lines[i]->start, lines[i]->end, namefile, nameMap); pDataArray.push_back(tempSum); //MySeqSumThreadFunction is in header. It must be global or static to work with the threads. @@ -630,6 +651,11 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& startPosition, //Close all thread handles and free memory allocations. for(int i=0; i < pDataArray.size(); i++){ num += pDataArray[i]->count; + for (int k = 0; k < pDataArray[i]->startPosition.size(); k++) { startPosition.push_back(pDataArray[i]->startPosition[k]); } + for (int k = 0; k < pDataArray[i]->endPosition.size(); k++) { endPosition.push_back(pDataArray[i]->endPosition[k]); } + for (int k = 0; k < pDataArray[i]->seqLength.size(); k++) { seqLength.push_back(pDataArray[i]->seqLength[k]); } + for (int k = 0; k < pDataArray[i]->ambigBases.size(); k++) { ambigBases.push_back(pDataArray[i]->ambigBases[k]); } + for (int k = 0; k < pDataArray[i]->longHomoPolymer.size(); k++) { longHomoPolymer.push_back(pDataArray[i]->longHomoPolymer[k]); } CloseHandle(hThreadArray[i]); delete pDataArray[i]; }