X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trimseqscommand.cpp;h=4128142448b8412314dc2b1d8ce057c6e8527519;hb=3914b0d6480f67df53b1e838f51c4e6155710434;hp=ec136dbe7eb02df1a659111766c5bff8bfc22222;hpb=75cff1a83a64cd46e9dd603e02597a2bb6a76119;p=mothur.git diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index ec136db..4128142 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -24,7 +24,7 @@ vector TrimSeqsCommand::setParameters(){ CommandParameter preorient("checkorient", "Boolean", "", "F", "", "", "","",false,false,true); parameters.push_back(preorient); CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxambig); CommandParameter pmaxhomop("maxhomop", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxhomop); - CommandParameter pminlength("minlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pminlength); + CommandParameter pminlength("minlength", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pminlength); CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxlength); CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs); CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs); @@ -256,7 +256,7 @@ TrimSeqsCommand::TrimSeqsCommand(string option) { temp = validParameter.validFile(parameters, "maxhomop", false); if (temp == "not found") { temp = "0"; } m->mothurConvert(temp, maxHomoP); - temp = validParameter.validFile(parameters, "minlength", false); if (temp == "not found") { temp = "0"; } + temp = validParameter.validFile(parameters, "minlength", false); if (temp == "not found") { temp = "1"; } m->mothurConvert(temp, minLength); temp = validParameter.validFile(parameters, "maxlength", false); if (temp == "not found") { temp = "0"; } @@ -422,7 +422,7 @@ int TrimSeqsCommand::execute(){ if (countfile != "") { CountTable ct; - ct.readTable(countfile); + ct.readTable(countfile, true); nameCount = ct.getNameMap(); outputNames.push_back(trimCountFile); outputNames.push_back(scrapCountFile); @@ -443,7 +443,9 @@ int TrimSeqsCommand::execute(){ outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName); } } - + + if (!pairedOligos) { if (reorient) { m->mothurOut("[WARNING]: You cannot use reorient without paired barcodes or primers, skipping."); m->mothurOutEndLine(); reorient = false; } } + if (m->control_pressed) { return 0; } //fills lines and qlines @@ -538,7 +540,7 @@ int TrimSeqsCommand::execute(){ if (countfile != "") { //create countfile with group info included CountTable* ct = new CountTable(); - ct->readTable(trimCountFile); + ct->readTable(trimCountFile, true); map justTrimmedNames = ct->getNameMap(); delete ct; @@ -713,7 +715,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string int currentSeqsDiffs = 0; Sequence currSeq(inFASTA); m->gobble(inFASTA); - //cout << currSeq.getName() << '\t' << currSeq.getUnaligned().length() << endl; + //cout << currSeq.getName() << '\t' << currSeq.getUnaligned() << endl; Sequence savedSeq(currSeq.getName(), currSeq.getAligned()); QualityScores currQual; QualityScores savedQual; @@ -738,10 +740,12 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string if(numBarcodes != 0){ success = trimOligos->stripBarcode(currSeq, currQual, barcodeIndex); - if(success > bdiffs) { trashCode += 'b'; } + if(success > bdiffs) { + trashCode += 'b'; + } else{ currentSeqsDiffs += success; } } - + //cout << currSeq.getName() << '\t' << currSeq.getUnaligned() << endl; if(numSpacers != 0){ success = trimOligos->stripSpacer(currSeq, currQual); if(success > sdiffs) { trashCode += 's'; } @@ -752,9 +756,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string if(numFPrimers != 0){ success = trimOligos->stripForward(currSeq, currQual, primerIndex, keepforward); if(success > pdiffs) { - //if (pairedOligos) { trashCode += trimOligos->getTrashCode(); } - //else { trashCode += 'f'; } - trashCode += 'f'; + trashCode += 'f'; } else{ currentSeqsDiffs += success; } } @@ -773,20 +775,16 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string int thisBarcodeIndex = 0; int thisPrimerIndex = 0; - + //cout << currSeq.getName() << '\t' << savedSeq.getUnaligned() << endl; if(numBarcodes != 0){ thisSuccess = rtrimOligos->stripBarcode(savedSeq, savedQual, thisBarcodeIndex); - if(thisSuccess > bdiffs) { thisTrashCode += 'b'; } + if(thisSuccess > bdiffs) { thisTrashCode += "b"; } else{ thisCurrentSeqsDiffs += thisSuccess; } } - + //cout << currSeq.getName() << '\t' << savedSeq.getUnaligned() << endl; if(numFPrimers != 0){ thisSuccess = rtrimOligos->stripForward(savedSeq, savedQual, thisPrimerIndex, keepforward); - if(thisSuccess > pdiffs) { - //if (pairedOligos) { thisTrashCode += rtrimOligos->getTrashCode(); } - //else { thisTrashCode += 'f'; } - thisTrashCode += 'f'; - } + if(thisSuccess > pdiffs) { thisTrashCode += "f"; } else{ thisCurrentSeqsDiffs += thisSuccess; } } @@ -804,7 +802,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string savedQual.flipQScores(); currQual.setScores(savedQual.getScores()); } - } + }else { trashCode += "(" + thisTrashCode + ")"; } } if(keepFirst != 0){ @@ -1393,9 +1391,7 @@ int TrimSeqsCommand::setLines(string filename, string qfilename) { string sname = ""; nameStream >> sname; sname = sname.substr(1); - for (int i = 0; i < sname.length(); i++) { - if (sname[i] == ':') { sname[i] = '_'; m->changedSeqNames = true; } - } + m->checkName(sname); map::iterator it = firstSeqNames.find(sname); @@ -1535,7 +1531,7 @@ bool TrimSeqsCommand::getOligos(vector >& fastaFileNames, vector< // get rest of line in case there is a primer name while (!inOligos.eof()) { char c = inOligos.get(); - if (c == 10 || c == 13){ break; } + if (c == 10 || c == 13 || c == -1){ break; } else if (c == 32 || c == 9){;} //space or tab else { group += c; } } @@ -1650,10 +1646,10 @@ bool TrimSeqsCommand::getOligos(vector >& fastaFileNames, vector< if (hasPairedBarcodes || hasPrimer) { pairedOligos = true; if ((primers.size() != 0) || (barcodes.size() != 0) || (linker.size() != 0) || (spacer.size() != 0) || (revPrimer.size() != 0)) { m->control_pressed = true; m->mothurOut("[ERROR]: cannot mix paired primers and barcodes with non paired or linkers and spacers, quitting."); m->mothurOutEndLine(); return 0; } - } + }else if (reorient) { m->mothurOut("[Warning]: cannot use checkorient without paired barcodes or primers, ignoring.\n"); m->mothurOutEndLine(); reorient = false; } if(barcodeNameVector.size() == 0 && primerNameVector[0] == ""){ allFiles = 0; } - + //add in potential combos if(barcodeNameVector.size() == 0){ barcodes[""] = 0;