From 818dcf9513122fa52616a7722f4893f77685a621 Mon Sep 17 00:00:00 2001 From: westcott Date: Wed, 24 Feb 2010 11:07:33 +0000 Subject: [PATCH] finished chimera changes --- chimera.cpp | 2 +- chimera.h | 5 ++--- chimeraseqscommand.cpp | 9 --------- pintail.cpp | 9 +++------ sharedcommand.cpp | 24 ++++++++++++++++++++++-- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/chimera.cpp b/chimera.cpp index 85b0b38..e7253ec 100644 --- a/chimera.cpp +++ b/chimera.cpp @@ -47,7 +47,7 @@ string Chimera::createFilter(vector seqs, float t) { if(gaps[i] == seqs.size()) { filterString[i] = '0'; numColRemoved++; } else if (((a[i] < threshold) && (t[i] < threshold) && (g[i] < threshold) && (c[i] < threshold))) { filterString[i] = '0'; numColRemoved++; } - cout << "a = " << a[i] << " t = " << t[i] << " g = " << g[i] << " c = " << c[i] << endl; + //cout << "a = " << a[i] << " t = " << t[i] << " g = " << g[i] << " c = " << c[i] << endl; } mothurOut("Filter removed " + toString(numColRemoved) + " columns."); mothurOutEndLine(); diff --git a/chimera.h b/chimera.h index f893d63..8c00aec 100644 --- a/chimera.h +++ b/chimera.h @@ -92,7 +92,7 @@ class Chimera { Chimera(string); Chimera(string, bool, string); Chimera(string, string); - virtual ~Chimera(){}; + virtual ~Chimera(){ for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i]; } }; virtual void setFilter(bool f) { filter = f; } virtual void setCorrection(bool c) { correction = c; } virtual void setProcessors(int p) { processors = p; } @@ -111,9 +111,8 @@ class Chimera { virtual void setMinBS(int b) { minBS = b; } virtual void setMinSNP(int s) { minSNP = s; } virtual void setIters(int i) { iters = i; } - virtual void setTemplateSeqs(vector t) { templateSeqs = t; } virtual bool getUnaligned() { return unaligned; } - virtual void setTemplateFile(string t) { templateFileName = t; } + virtual void setTemplateFile(string t) { templateFileName = t; templateSeqs = readSeqs(t); } virtual int getLength() { return length; } virtual void setCons(string){}; diff --git a/chimeraseqscommand.cpp b/chimeraseqscommand.cpp index d34149d..1758cf6 100644 --- a/chimeraseqscommand.cpp +++ b/chimeraseqscommand.cpp @@ -315,20 +315,12 @@ int ChimeraSeqsCommand::execute(){ string accnosFileName = outputDir + getRootName(getSimpleName(fastafile)) + method + maskfile + ".accnos"; - vector templateSeqs; if ((method != "bellerophon") && (method != "chimeracheck")) { - templateSeqs = chimera->readSeqs(templatefile); if (chimera->getUnaligned()) { mothurOut("Your template sequences are different lengths, please correct."); mothurOutEndLine(); - //free memory - for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i]; } delete chimera; return 0; } - - //set options - chimera->setTemplateSeqs(templateSeqs); - }else if (method == "bellerophon") {//run bellerophon separately since you need to read entire fastafile to run it chimera->getChimeras(); @@ -435,7 +427,6 @@ int ChimeraSeqsCommand::execute(){ remove(outputFileName.c_str()); rename(tempHeader.c_str(), outputFileName.c_str()); - for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i]; } delete chimera; if (method == "chimeracheck") { remove(accnosFileName.c_str()); mothurOutEndLine(); mothurOut("This method does not determine if a sequence is chimeric, but allows you to make that determination based on the IS values."); mothurOutEndLine(); } diff --git a/pintail.cpp b/pintail.cpp index 63a9014..90c97c5 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -80,8 +80,6 @@ void Pintail::doPrep() { bool reRead = false; //create filter if needed for later if (filter) { - -cout << "filter" << endl; //read in all query seqs ifstream in; @@ -100,10 +98,9 @@ cout << "filter" << endl; //merge query seqs and template seqs temp = templateSeqs; for (int i = 0; i < tempQuerySeqs.size(); i++) { temp.push_back(tempQuerySeqs[i]); } -cout << temp.size() << endl; + if (seqMask != "") { reRead = true; - cout << "masked " << seqMask << endl; //mask templates for (int i = 0; i < temp.size(); i++) { decalc->runMask(temp[i]); @@ -111,9 +108,9 @@ cout << temp.size() << endl; } mergedFilterString = createFilter(temp, 0.5); - cout << "here" << endl; + //reread template seqs - //for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i]; } + for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i]; } } diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 1fe2300..4cc0ea7 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -289,6 +289,9 @@ void SharedCommand::createMisMatchFile() { openOutputFile(outputMisMatchName, outMisMatch); + map listNames; + map::iterator itList; + //go through list and if group returns "not found" output it for (int i = 0; i < SharedList->getNumBins(); i++) { @@ -298,13 +301,22 @@ void SharedCommand::createMisMatchFile() { string name = names.substr(0,names.find_first_of(',')); names = names.substr(names.find_first_of(',')+1, names.length()); string group = groupMap->getGroup(name); - + if(group == "not found") { outMisMatch << name << endl; } + + itList = listNames.find(name); + if (itList != listNames.end()) { mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); } + else { listNames[name] = name; } } //get last name string group = groupMap->getGroup(names); - if(group == "not found") { outMisMatch << names << endl; } + if(group == "not found") { outMisMatch << names << endl; } + + itList = listNames.find(names); + if (itList != listNames.end()) { mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); } + else { listNames[names] = names; } + } outMisMatch.close(); @@ -316,6 +328,7 @@ void SharedCommand::createMisMatchFile() { mothurOut("For a list of names that are in your group file and not in your list file, please refer to " + outputMisMatchName + "."); mothurOutEndLine(); map namesInList; + map::iterator itList; //go through listfile and get names for (int i = 0; i < SharedList->getNumBins(); i++) { @@ -326,9 +339,16 @@ void SharedCommand::createMisMatchFile() { string name = names.substr(0,names.find_first_of(',')); names = names.substr(names.find_first_of(',')+1, names.length()); + itList = namesInList.find(name); + if (itList != namesInList.end()) { mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); } + namesInList[name] = name; + } + itList = namesInList.find(names); + if (itList != namesInList.end()) { mothurOut(names + " is in your list file more than once. Sequence names must be unique. please correct."); mothurOutEndLine(); } + //get last name namesInList[names] = names; } -- 2.39.2