X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=chimerapintailcommand.cpp;h=c5c678e78a344eed06ea0308c0df6178e7f22a51;hb=5a4ac4f954c4b4445bcee272f1f8220ddcc9c1e4;hp=01a905f40d4c69514230ad033367cc02982cd3db;hpb=19fcbbdba99658f5eca244803280f9ee7f9f6607;p=mothur.git diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index 01a905f..c5c678e 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -69,6 +69,27 @@ string ChimeraPintailCommand::getHelpString(){ } } //********************************************************************************************************************** +string ChimeraPintailCommand::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 == "chimera") { outputFileName = "pintail.chimeras"; } + else if (type == "accnos") { outputFileName = "pintail.accnos"; } + 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, "ChimeraPintailCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** ChimeraPintailCommand::ChimeraPintailCommand(){ try { abort = true; calledHelp = true; @@ -225,13 +246,13 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option) { temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); - convert(temp, processors); + m->mothurConvert(temp, processors); temp = validParameter.validFile(parameters, "window", false); if (temp == "not found") { temp = "0"; } - convert(temp, window); + m->mothurConvert(temp, window); temp = validParameter.validFile(parameters, "increment", false); if (temp == "not found") { temp = "25"; } - convert(temp, increment); + m->mothurConvert(temp, increment); temp = validParameter.validFile(parameters, "save", false); if (temp == "not found"){ temp = "f"; } save = m->isTrue(temp); @@ -392,17 +413,16 @@ int ChimeraPintailCommand::execute(){ } } } - chimera = new Pintail(fastaFileNames[s], templatefile, filter, processors, maskfile, consfile, quanfile, window, increment, outputDir); if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]); }//if user entered a file with a path then preserve it string outputFileName, accnosFileName; if (maskfile != "") { - outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + ".pintail.chimeras"; - accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + ".pintail.accnos"; + outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + getOutputFileNameTag("chimera"); + accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + getOutputFileNameTag("accnos"); }else { - outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "pintail.chimeras"; - accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "pintail.accnos"; + outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera"); + accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos"); } if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } @@ -417,7 +437,7 @@ int ChimeraPintailCommand::execute(){ #ifdef USE_MPI int pid, numSeqsPerProcessor; int tag = 2001; - vector MPIPos; + vector MPIPos; MPI_Status status; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are @@ -487,14 +507,15 @@ int ChimeraPintailCommand::execute(){ MPI_File_close(&outMPIAccnos); MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case #else - vector positions = m->divideFile(fastaFileNames[s], processors); - - for (int i = 0; i < (positions.size()-1); i++) { - lines.push_back(new linePair(positions[i], positions[(i+1)])); - } - + //break up file - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + vector positions = m->divideFile(fastaFileNames[s], processors); + + for (int i = 0; i < (positions.size()-1); i++) { + lines.push_back(new linePair(positions[i], positions[(i+1)])); + } + if(processors == 1){ numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); @@ -532,6 +553,7 @@ int ChimeraPintailCommand::execute(){ } #else + lines.push_back(new linePair(0, 1000)); numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } @@ -610,8 +632,8 @@ int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - unsigned long int pos = inFASTA.tellg(); + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else if (inFASTA.eof()) { break; } @@ -636,7 +658,7 @@ int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string } //********************************************************************************************************************** #ifdef USE_MPI -int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector& MPIPos){ +int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector& MPIPos){ try { MPI_Status status; @@ -696,7 +718,7 @@ int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fi int ChimeraPintailCommand::createProcesses(string outputFileName, string filename, string accnos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int num = 0;