X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trimseqscommand.cpp;h=ba368fc8569fdfde5d3587ffc5a1e65240e8acdf;hb=9b53f130ac9af5e95444ce2e817fce25ed19ff03;hp=29b8733721a2b710468f960ac474c99734a181df;hpb=ea4f373c28543cd1002b0dd7dc6e55c526647d59;p=mothur.git diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 29b8733..ba368fc 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -114,7 +114,7 @@ string TrimSeqsCommand::getOutputFileNameTag(string type, string inputName=""){ else if (type == "fasta") { outputFileName = "fasta"; } else if (type == "group") { outputFileName = "groups"; } else if (type == "name") { outputFileName = "names"; } - else if (type == "count") { outputFileName = "count.table"; } + else if (type == "count") { outputFileName = "count_table"; } else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } } return outputFileName; @@ -660,7 +660,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string int count = 0; bool moreSeqs = 1; - TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, rbarcodes, revPrimer, linker, spacer); + TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimer, linker, spacer); while (moreSeqs) { @@ -704,12 +704,6 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string if(success > bdiffs) { trashCode += 'b'; } else{ currentSeqsDiffs += success; } } - - if(rbarcodes.size() != 0){ - success = trimOligos.stripRBarcode(currSeq, currQual, barcodeIndex); - if(success > bdiffs) { trashCode += 'b'; } - else{ currentSeqsDiffs += success; } - } if(numSpacers != 0){ success = trimOligos.stripSpacer(currSeq, currQual); @@ -1042,10 +1036,10 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName HANDLE hThreadArray[processors-1]; //Create processor worker threads. - for( int i=0; i > tempFASTAFileNames = fastaFileNames; vector > tempPrimerQualFileNames = qualFileNames; vector > tempNameFileNames = nameFileNames; @@ -1087,14 +1081,14 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName tempFASTAFileNames, tempPrimerQualFileNames, tempNameFileNames, - lines[i].start, lines[i].end, qLines[i].start, qLines[i].end, m, - pdiffs, bdiffs, ldiffs, sdiffs, tdiffs, primers, barcodes, rbarcodes, revPrimer, linker, spacer, + lines[h].start, lines[h].end, qLines[h].start, qLines[h].end, m, + pdiffs, bdiffs, ldiffs, sdiffs, tdiffs, primers, barcodes, revPrimer, linker, spacer, primerNameVector, barcodeNameVector, createGroup, allFiles, keepforward, keepFirst, removeLast, qWindowStep, qWindowSize, qWindowAverage, qtrim, qThreshold, qAverage, qRollAverage, minLength, maxAmbig, maxHomoP, maxLength, flip, nameMap, nameCount); pDataArray.push_back(tempTrim); - hThreadArray[i] = CreateThread(NULL, 0, MyTrimThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]); + hThreadArray[h] = CreateThread(NULL, 0, MyTrimThreadFunction, pDataArray[h], 0, &dwThreadIdArray[h]); } //parent do my part @@ -1109,8 +1103,32 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName m->openOutputFile(trimNameFileName, temp); temp.close(); m->openOutputFile(scrapNameFileName, temp); temp.close(); } + vector > tempFASTAFileNames = fastaFileNames; + vector > tempPrimerQualFileNames = qualFileNames; + vector > tempNameFileNames = nameFileNames; + if(allFiles){ + ofstream temp; + string extension = toString(processors-1) + ".temp"; + for(int i=0;iopenOutputFile(tempFASTAFileNames[i][j], temp); temp.close(); + + if(qFileName != ""){ + tempPrimerQualFileNames[i][j] += extension; + m->openOutputFile(tempPrimerQualFileNames[i][j], temp); temp.close(); + } + if(nameFile != ""){ + tempNameFileNames[i][j] += extension; + m->openOutputFile(tempNameFileNames[i][j], temp); temp.close(); + } + } + } + } + } - driverCreateTrim(filename, qFileName, (trimFASTAFileName + toString(processors-1) + ".temp"), (scrapFASTAFileName + toString(processors-1) + ".temp"), (trimQualFileName + toString(processors-1) + ".temp"), (scrapQualFileName + toString(processors-1) + ".temp"), (trimNameFileName + toString(processors-1) + ".temp"), (scrapNameFileName + toString(processors-1) + ".temp"), (trimCountFileName + toString(processors-1) + ".temp"), (scrapCountFileName + toString(processors-1) + ".temp"), (groupFile + toString(processors-1) + ".temp"), fastaFileNames, qualFileNames, nameFileNames, lines[processors-1], qLines[processors-1]); + driverCreateTrim(filename, qFileName, (trimFASTAFileName + toString(processors-1) + ".temp"), (scrapFASTAFileName + toString(processors-1) + ".temp"), (trimQualFileName + toString(processors-1) + ".temp"), (scrapQualFileName + toString(processors-1) + ".temp"), (trimNameFileName + toString(processors-1) + ".temp"), (scrapNameFileName + toString(processors-1) + ".temp"), (trimCountFileName + toString(processors-1) + ".temp"), (scrapCountFileName + toString(processors-1) + ".temp"), (groupFile + toString(processors-1) + ".temp"), tempFASTAFileNames, tempPrimerQualFileNames, tempNameFileNames, lines[processors-1], qLines[processors-1]); processIDS.push_back(processors-1); @@ -1435,40 +1453,11 @@ bool TrimSeqsCommand::getOligos(vector >& fastaFileNames, vector< } else if(type == "BARCODE"){ inOligos >> group; - - //barcode lines can look like BARCODE atgcatgc groupName - for 454 seqs - //or BARCODE atgcatgc atgcatgc groupName - for illumina data that has forward and reverse info - string temp = ""; - while (!inOligos.eof()) { - char c = inOligos.get(); - if (c == 10 || c == 13){ break; } - else if (c == 32 || c == 9){;} //space or tab - else { temp += c; } - } - //then this is illumina data with 4 columns - if (temp != "") { - - for(int i=0;idebug) { m->mothurOut("[DEBUG]: reading reverse " + group + ", and group = " + temp + ".\n"); } - - string reverseBarcode = reverseOligo(group); //reverse barcode - //check for repeat barcodes - map::iterator itBar = rbarcodes.find(reverseBarcode); - if (itBar != rbarcodes.end()) { m->mothurOut("reverse barcode " + group + " is in your oligos file already."); m->mothurOutEndLine(); } - - group = temp; - rbarcodes[reverseBarcode]=indexBarcode; - }else { if (m->debug) { m->mothurOut("[DEBUG]: reading group " + group + ".\n"); } } - //check for repeat barcodes map::iterator itBar = barcodes.find(oligo); if (itBar != barcodes.end()) { m->mothurOut("barcode " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); } - + barcodes[oligo]=indexBarcode; indexBarcode++; barcodeNameVector.push_back(group); }else if(type == "LINKER"){