X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=trimseqscommand.h;h=14eed17e236a333583d461d61482a1d541c6a9cf;hp=882f716357515b008c06889f3f1559a4e4525cd5;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=2a29fceeeb8754c3fd97ba830d2fbed5c4349ee8 diff --git a/trimseqscommand.h b/trimseqscommand.h index 882f716..14eed17 100644 --- a/trimseqscommand.h +++ b/trimseqscommand.h @@ -55,7 +55,7 @@ private: bool abort, createGroup; string fastaFile, oligoFile, qFileName, groupfile, nameFile, countfile, outputDir; - bool flip, allFiles, qtrim, keepforward, pairedOligos, reorient; + bool flip, allFiles, qtrim, keepforward, pairedOligos, reorient, logtransform; int numFPrimers, numRPrimers, numLinkers, numSpacers, maxAmbig, maxHomoP, minLength, maxLength, processors, tdiffs, bdiffs, pdiffs, ldiffs, sdiffs, comboStarts; int qWindowSize, qWindowStep, keepFirst, removeLast; double qRollAverage, qThreshold, qWindowAverage, qAverage; @@ -98,7 +98,7 @@ struct trimData { vector > qualFileNames; vector > nameFileNames; unsigned long long lineStart, lineEnd, qlineStart, qlineEnd; - bool flip, allFiles, qtrim, keepforward, createGroup, pairedOligos, reorient; + bool flip, allFiles, qtrim, keepforward, createGroup, pairedOligos, reorient, logtransform; int numFPrimers, numRPrimers, numLinkers, numSpacers, maxAmbig, maxHomoP, minLength, maxLength, tdiffs, bdiffs, pdiffs, ldiffs, sdiffs; int qWindowSize, qWindowStep, keepFirst, removeLast, count; double qRollAverage, qThreshold, qWindowAverage, qAverage; @@ -121,7 +121,7 @@ struct trimData { trimData(string fn, string qn, string nf, string cf, string tn, string sn, string tqn, string sqn, string tnn, string snn, string tcn, string scn,string gn, vector > ffn, vector > qfn, vector > nfn, unsigned long long lstart, unsigned long long lend, unsigned long long qstart, unsigned long long qend, MothurOut* mout, int pd, int bd, int ld, int sd, int td, map pri, map bar, vector revP, vector li, vector spa, map pbr, map ppr, bool po, vector priNameVector, vector barNameVector, bool cGroup, bool aFiles, bool keepF, int keepfi, int removeL, - int WindowStep, int WindowSize, int WindowAverage, bool trim, double Threshold, double Average, double RollAverage, + int WindowStep, int WindowSize, int WindowAverage, bool trim, double Threshold, double Average, double RollAverage, bool lt, int minL, int maxA, int maxH, int maxL, bool fli, bool reo, map nm, map ncount) { filename = fn; qFileName = qn; @@ -174,6 +174,7 @@ struct trimData { qThreshold = Threshold; qAverage = Average; qRollAverage = RollAverage; + logtransform = lt; minLength = minL; maxAmbig = maxA; maxHomoP = maxH; @@ -276,6 +277,19 @@ static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ oligosPair tempPair(trimOligos->reverseOligo((it->second).reverse), (trimOligos->reverseOligo((it->second).forward))); //reverseBarcode, rc ForwardBarcode rpairedBarcodes[it->first] = tempPair; } + + int index = rpairedBarcodes.size(); + for (map::iterator it = pDataArray->barcodes.begin(); it != pDataArray->barcodes.end(); it++) { + oligosPair tempPair("", trimOligos->reverseOligo((it->first))); //reverseBarcode, rc ForwardBarcode + rpairedBarcodes[index] = tempPair; index++; + } + + index = rpairedPrimers.size(); + for (map::iterator it = pDataArray->primers.begin(); it != pDataArray->primers.end(); it++) { + oligosPair tempPair("", trimOligos->reverseOligo((it->first))); //reverseBarcode, rc ForwardBarcode + rpairedPrimers[index] = tempPair; index++; + } + rtrimOligos = new TrimOligos(pDataArray->pdiffs, pDataArray->bdiffs, 0, 0, rpairedPrimers, rpairedBarcodes); numBarcodes = rpairedBarcodes.size(); } @@ -299,11 +313,14 @@ static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ int currentSeqsDiffs = 0; Sequence currSeq(inFASTA); pDataArray->m->gobble(inFASTA); + Sequence savedSeq(currSeq.getName(), currSeq.getAligned()); - QualityScores currQual; + QualityScores currQual; QualityScores savedQual; if(pDataArray->qFileName != ""){ currQual = QualityScores(qFile); pDataArray->m->gobble(qFile); + savedQual.setName(currQual.getName()); savedQual.setScores(currQual.getScores()); } + string origSeq = currSeq.getUnaligned(); if (origSeq != "") { @@ -353,13 +370,13 @@ static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ int thisPrimerIndex = 0; if(numBarcodes != 0){ - thisSuccess = rtrimOligos->stripBarcode(currSeq, currQual, thisBarcodeIndex); + thisSuccess = rtrimOligos->stripBarcode(savedSeq, savedQual, thisBarcodeIndex); if(thisSuccess > pDataArray->bdiffs) { thisTrashCode += 'b'; } else{ thisCurrentSeqsDiffs += thisSuccess; } } if(pDataArray->numFPrimers != 0){ - thisSuccess = rtrimOligos->stripForward(currSeq, currQual, thisPrimerIndex, pDataArray->keepforward); + thisSuccess = rtrimOligos->stripForward(savedSeq, savedQual, thisPrimerIndex, pDataArray->keepforward); if(thisSuccess > pDataArray->pdiffs) { thisTrashCode += 'f'; } else{ thisCurrentSeqsDiffs += thisSuccess; } } @@ -372,11 +389,13 @@ static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ currentSeqsDiffs = thisCurrentSeqsDiffs; barcodeIndex = thisBarcodeIndex; primerIndex = thisPrimerIndex; - currSeq.reverseComplement(); + savedSeq.reverseComplement(); + currSeq.setAligned(savedSeq.getAligned()); if(pDataArray->qFileName != ""){ - currQual.flipQScores(); + savedQual.flipQScores(); + currQual.setScores(savedQual.getScores()); } - } + }else { trashCode += "(" + thisTrashCode + ")"; } } @@ -411,9 +430,9 @@ static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ int origLength = currSeq.getNumBases(); if(pDataArray->qThreshold != 0) { success = currQual.stripQualThreshold(currSeq, pDataArray->qThreshold); } - else if(pDataArray->qAverage != 0) { success = currQual.cullQualAverage(currSeq, pDataArray->qAverage); } - else if(pDataArray->qRollAverage != 0) { success = currQual.stripQualRollingAverage(currSeq, pDataArray->qRollAverage); } - else if(pDataArray->qWindowAverage != 0){ success = currQual.stripQualWindowAverage(currSeq, pDataArray->qWindowStep, pDataArray->qWindowSize, pDataArray->qWindowAverage); } + else if(pDataArray->qAverage != 0) { success = currQual.cullQualAverage(currSeq, pDataArray->qAverage, pDataArray->logtransform); } + else if(pDataArray->qRollAverage != 0) { success = currQual.stripQualRollingAverage(currSeq, pDataArray->qRollAverage, pDataArray->logtransform); } + else if(pDataArray->qWindowAverage != 0){ success = currQual.stripQualWindowAverage(currSeq, pDataArray->qWindowStep, pDataArray->qWindowSize, pDataArray->qWindowAverage, pDataArray->logtransform); } else { success = 1; } //you don't want to trim, if it fails above then scrap it