From bffbd9ad0d837bc9523d95e7b35c34cfd2631046 Mon Sep 17 00:00:00 2001 From: pschloss Date: Sun, 7 Jun 2009 02:23:44 +0000 Subject: [PATCH] modified trim.seqs command --- alignment.cpp | 2 +- alignment.hpp | 2 +- globaldata.cpp | 15 --------------- globaldata.hpp | 5 +---- needlemanoverlap.hpp | 1 + trimseqscommand.cpp | 29 +++++++++-------------------- trimseqscommand.h | 12 +++++------- validparameter.cpp | 2 +- 8 files changed, 19 insertions(+), 49 deletions(-) diff --git a/alignment.cpp b/alignment.cpp index 55ba1a1..95e9dc2 100644 --- a/alignment.cpp +++ b/alignment.cpp @@ -41,7 +41,7 @@ void Alignment::traceBack(){ // This traceback routine is used by the dynamic AlignmentCell currentCell = alignment[row][column]; // Start the traceback from the bottom-right corner of the // matrix - + if(currentCell.prevCell == 'x'){ seqAaln = seqBaln = "NOALIGNMENT"; }//If there's an 'x' in the bottom- else{ // right corner bail out because it means nothing got aligned while(currentCell.prevCell != 'x'){ // while the previous cell isn't an 'x', keep going... diff --git a/alignment.hpp b/alignment.hpp index b317556..c033d62 100644 --- a/alignment.hpp +++ b/alignment.hpp @@ -25,7 +25,7 @@ public: Alignment(); virtual void align(string, string) = 0; - float getAlignmentScore(); +// float getAlignmentScore(); string getSeqAAln(); string getSeqBAln(); int getCandidateStartPos(); diff --git a/globaldata.cpp b/globaldata.cpp index bf28cc6..c42969e 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -102,9 +102,6 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if(key == "maxlength") { maxLength = value; } if(key == "flip" ) { flip = value; } if(key == "oligos" ) { oligoFile = value; } - if(key == "forward" ) { forMismatch = value; } - if(key == "reverse" ) { revMismatch = value; } - if(key == "barcode" ) { barMismatch = value; } if(key == "line") {//stores lines to be used in a vector lines.clear(); @@ -183,9 +180,6 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if(key == "maxlength") { maxLength = value; } if(key == "flip" ) { flip = value; } if(key == "oligos" ) { oligoFile = value; } - if(key == "forward" ) { forMismatch = value; } - if(key == "reverse" ) { revMismatch = value; } - if(key == "barcode" ) { barMismatch = value; } if(key == "line") {//stores lines to be used in a vector @@ -347,9 +341,6 @@ string GlobalData::getMinLength() { return minLength; } string GlobalData::getMaxLength() { return maxLength; } string GlobalData::getFlip() { return flip; } string GlobalData::getOligosFile() { return oligoFile; } -string GlobalData::getForwardMismatch() { return forMismatch; } -string GlobalData::getReverseMismatch() { return revMismatch; } -string GlobalData::getBarcodeMismatch() { return barMismatch; } void GlobalData::setListFile(string file) { listfile = file; inputFileName = file; } @@ -433,9 +424,6 @@ void GlobalData::clear() { minLength = "-1"; maxLength = "-1"; flip = "0"; - forMismatch = "0"; - revMismatch = "0"; - barMismatch = "0"; oligoFile = ""; } @@ -479,9 +467,6 @@ void GlobalData::reset() { minLength = "-1"; maxLength = "-1"; flip = "0"; - forMismatch = "0"; - revMismatch = "0"; - barMismatch = "0"; oligoFile = ""; } diff --git a/globaldata.hpp b/globaldata.hpp index 2a57310..89089ad 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -92,9 +92,6 @@ public: string getMinLength(); string getMaxLength(); string getFlip(); - string getForwardMismatch(); - string getReverseMismatch(); - string getBarcodeMismatch(); string getOligosFile(); void setListFile(string); @@ -126,7 +123,7 @@ public: private: - string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups, cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, hard, scale, countends, processors, candidatefile, search, ksize, align, match, size, mismatch, gapopen, gapextend, minLength, maxLength, startPos, endPos, maxAmbig, maxHomoPolymer, flip, forMismatch, revMismatch, barMismatch, oligoFile; + string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups, cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, hard, scale, countends, processors, candidatefile, search, ksize, align, match, size, mismatch, gapopen, gapextend, minLength, maxLength, startPos, endPos, maxAmbig, maxHomoPolymer, flip, oligoFile; static GlobalData* _uniqueInstance; diff --git a/needlemanoverlap.hpp b/needlemanoverlap.hpp index 57d3284..a5e2140 100644 --- a/needlemanoverlap.hpp +++ b/needlemanoverlap.hpp @@ -22,6 +22,7 @@ */ #include "mothur.h" +#include "alignment.hpp" /**************************************************************************************************/ diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 40b3b4f..95a85ac 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -7,7 +7,6 @@ * */ -#include "sequence.hpp" #include "trimseqscommand.h" //*************************************************************************************************************** @@ -15,11 +14,7 @@ TrimSeqsCommand::TrimSeqsCommand(){ try { - oligos = 0; - forwardPrimerMismatch = 0; - reversePrimerMismatch = 0; - barcodeMismatch = 0; - + oligos = 0; totalBarcodeCount = 0; matchBarcodeCount = 0; @@ -28,18 +23,10 @@ TrimSeqsCommand::TrimSeqsCommand(){ cout << "you need to at least enter a fasta file name" << endl; } - if(isTrue(globaldata->getFlip())) { flip = 1; } - - if(globaldata->getOligosFile() != ""){ - oligos = 1; - forwardPrimerMismatch = atoi(globaldata->getForwardMismatch().c_str()); - reversePrimerMismatch = atoi(globaldata->getReverseMismatch().c_str()); - barcodeMismatch = atoi(globaldata->getBarcodeMismatch().c_str()); - } - - if(!flip && !oligos) { cout << "what was the point?" << endl; } + if(isTrue(globaldata->getFlip())) { flip = 1; } + if(globaldata->getOligosFile() != "") { oligos = 1; } + if(!flip && !oligos) { cout << "huh?" << endl; } - } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the TrimSeqsCommand class Function TrimSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -80,6 +67,7 @@ int TrimSeqsCommand::execute(){ while(!inFASTA.eof()){ Sequence currSeq(inFASTA); + string origSeq = currSeq.getUnaligned(); string group; string trashCode = ""; @@ -103,6 +91,7 @@ int TrimSeqsCommand::execute(){ } else{ currSeq.setName(currSeq.getName() + '|' + trashCode); + currSeq.setUnaligned(origSeq); currSeq.printSequence(scrapFASTA); } @@ -210,8 +199,8 @@ bool TrimSeqsCommand::stripForward(Sequence& seq){ success = 1; break; } - } + totalFPrimerCount++; return success; @@ -238,8 +227,8 @@ bool TrimSeqsCommand::stripReverse(Sequence& seq){ success = 1; break; } - - } + } + totalRPrimerCount++; return success; diff --git a/trimseqscommand.h b/trimseqscommand.h index 0a34ff3..565d528 100644 --- a/trimseqscommand.h +++ b/trimseqscommand.h @@ -13,6 +13,7 @@ #include "mothur.h" #include "command.hpp" #include "globaldata.hpp" +#include "sequence.hpp" class TrimSeqsCommand : public Command { public: @@ -27,18 +28,15 @@ private: bool stripReverse(Sequence&); GlobalData* globaldata; - - int totalBarcodeCount, matchBarcodeCount; - int totalFPrimerCount, matchFPrimerCount; - int totalRPrimerCount, matchRPrimerCount; - + + int totalBarcodeCount, matchBarcodeCount; // to be removed + int totalFPrimerCount, matchFPrimerCount; // to be removed + int totalRPrimerCount, matchRPrimerCount; // to be removed bool oligos, flip; - int forwardPrimerMismatch, reversePrimerMismatch, barcodeMismatch; int numFPrimers, numRPrimers; vector forPrimer, revPrimer; map barcodes; - }; #endif diff --git a/validparameter.cpp b/validparameter.cpp index bd16984..4335c0d 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -285,7 +285,7 @@ void ValidParameters::initCommandParameters() { string reverseseqsArray[] = {"fasta"}; commandParameters["reverse.seqs"] = addParameters(reverseseqsArray, sizeof(reverseseqsArray)/sizeof(string)); - string trimseqsArray[] = {"fasta", "flip", "oligos", "forward", "reverse", "barcode"}; + string trimseqsArray[] = {"fasta", "flip", "oligos"}; commandParameters["trim.seqs"] = addParameters(trimseqsArray, sizeof(trimseqsArray)/sizeof(string)); string vennArray[] = {"groups","line","label","calc"}; -- 2.39.2