X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trimflowscommand.cpp;h=00c4d94e1027c63d8a0c324167bb3d7ec8e4c570;hb=43ed0accfbc2852849e104ff7eccdd2c42acd4ec;hp=77dacfe711ea694d7d81cb7536fd15d14cb0ec97;hpb=0ca63a8165baa0afa459e644ebe140ba496d5ba0;p=mothur.git diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index 77dacfe..00c4d94 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -21,7 +21,9 @@ vector TrimFlowsCommand::setParameters(){ CommandParameter pminflows("minflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pminflows); CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs); CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs); - CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs); + CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs); + CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs); + CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs); CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); CommandParameter psignal("signal", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(psignal); CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pnoise); @@ -178,10 +180,17 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { temp = validParameter.validFile(parameters, "pdiffs", false); if (temp == "not found"){ temp = "0"; } m->mothurConvert(temp, pdiffs); - temp = validParameter.validFile(parameters, "tdiffs", false); - if (temp == "not found"){ int tempTotal = pdiffs + bdiffs; temp = toString(tempTotal); } + temp = validParameter.validFile(parameters, "ldiffs", false); if (temp == "not found") { temp = "0"; } + m->mothurConvert(temp, ldiffs); + + temp = validParameter.validFile(parameters, "sdiffs", false); if (temp == "not found") { temp = "0"; } + m->mothurConvert(temp, sdiffs); + + temp = validParameter.validFile(parameters, "tdiffs", false); if (temp == "not found") { int tempTotal = pdiffs + bdiffs + ldiffs + sdiffs; temp = toString(tempTotal); } m->mothurConvert(temp, tdiffs); - if(tdiffs == 0){ tdiffs = bdiffs + pdiffs; } + + if(tdiffs == 0){ tdiffs = bdiffs + pdiffs + ldiffs + sdiffs; } + temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); @@ -226,7 +235,7 @@ int TrimFlowsCommand::execute(){ } vector flowFilePos; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) flowFilePos = getFlowFileBreaks(); for (int i = 0; i < (flowFilePos.size()-1); i++) { lines.push_back(new linePair(flowFilePos[i], flowFilePos[(i+1)])); @@ -295,7 +304,7 @@ int TrimFlowsCommand::execute(){ m->mothurRemove(barcodePrimerComboFileNames[i][j]); } else{ - output << barcodePrimerComboFileNames[i][j] << endl; + output << m->getFullPathName(barcodePrimerComboFileNames[i][j]) << endl; outputNames.push_back(barcodePrimerComboFileNames[i][j]); outputTypes["flow"].push_back(barcodePrimerComboFileNames[i][j]); } @@ -309,7 +318,7 @@ int TrimFlowsCommand::execute(){ flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.files"; m->openOutputFile(flowFilesFileName, output); - output << trimFlowFileName << endl; + output << m->getFullPathName(trimFlowFileName) << endl; output.close(); } @@ -381,9 +390,7 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN TrimOligos trimOligos(pdiffs, bdiffs, primers, barcodes, revPrimer); while(moreSeqs) { - //cout << "driver " << count << endl; - - + if (m->control_pressed) { break; } int success = 1; @@ -404,12 +411,26 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN int primerIndex = 0; int barcodeIndex = 0; + if(numLinkers != 0){ + success = trimOligos.stripLinker(currSeq); + if(success > ldiffs) { trashCode += 'k'; } + else{ currentSeqDiffs += success; } + + } + if(barcodes.size() != 0){ success = trimOligos.stripBarcode(currSeq, barcodeIndex); if(success > bdiffs) { trashCode += 'b'; } else{ currentSeqDiffs += success; } } + if(numSpacers != 0){ + success = trimOligos.stripSpacer(currSeq); + if(success > sdiffs) { trashCode += 's'; } + else{ currentSeqDiffs += success; } + + } + if(numFPrimers != 0){ success = trimOligos.stripForward(currSeq, primerIndex); if(success > pdiffs) { trashCode += 'f'; } @@ -447,7 +468,7 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN //report progress if((count) % 10000 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = flowFile.tellg(); if ((pos == -1) || (pos >= line->end)) { break; } @@ -534,6 +555,10 @@ void TrimFlowsCommand::getOligos(vector >& outFlowFileNames){ barcodes[oligo]=indexBarcode; indexBarcode++; barcodeNameVector.push_back(group); + }else if(type == "LINKER"){ + linker.push_back(oligo); + }else if(type == "SPACER"){ + spacer.push_back(oligo); } else{ m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine(); @@ -599,6 +624,8 @@ void TrimFlowsCommand::getOligos(vector >& outFlowFileNames){ numFPrimers = primers.size(); numRPrimers = revPrimer.size(); + numLinkers = linker.size(); + numSpacers = spacer.size(); } catch(exception& e) { @@ -688,7 +715,7 @@ int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trim processIDS.clear(); int exitCommand = 1; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; //loop through and create all the processes you want