From: pschloss <pschloss>
Date: Fri, 20 Aug 2010 19:25:59 +0000 (+0000)
Subject: fixed filterseqscommand bug where trump wasn't being used
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=94ba64671398f3c9e591df90536833123de0fd34;p=mothur.git

fixed filterseqscommand bug where trump wasn't being used
---

diff --git a/filters.h b/filters.h
index 94f8d33..13607e7 100644
--- a/filters.h
+++ b/filters.h
@@ -46,6 +46,14 @@ public:
 			if(a[i] < threshold && t[i] < threshold && g[i] < threshold && c[i] < threshold){	filter[i] = 0;	}
 		}
 	}
+
+	void mergeFilter(string newFilter){
+		for(int i=0;i<alignmentLength;i++){
+			if(newFilter[i] == '0'){
+				filter[i] = 0;
+			}
+		}
+	}
 	
 	void doVertical() {
 
diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp
index 1ebac0e..f3b543c 100644
--- a/filterseqscommand.cpp
+++ b/filterseqscommand.cpp
@@ -728,10 +728,8 @@ string FilterSeqsCommand::createFilter() {
 		if (pid == 0) { //only one process should output the filter
 #endif
 		F.setNumSeqs(numSeqs);
-				
 		if(isTrue(vertical) == 1)	{	F.doVertical();	}
 		if(soft != 0)				{	F.doSoft();		}
-			
 		filterString = F.getFilter();
 		
 #ifdef USE_MPI
@@ -781,8 +779,8 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair*
 			if (seq.getName() != "") {
 					if (seq.getAligned().length() != alignmentLength) { m->mothurOut("Sequences are not all the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true;  }
 					
-					if(trump != '*'){	F.doTrump(seq);	}
-					if(isTrue(vertical) || soft != 0){	F.getFreqs(seq);	}
+					if(trump != '*')			{	F.doTrump(seq);		}
+					if(isTrue(vertical) || soft != 0)	{	F.getFreqs(seq);	}
 					cout.flush();
 					count++;
 			}
@@ -876,12 +874,14 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename)
 				openOutputFile(filename, out);
 				
 				out << num << endl;
+				out << F.getFilter() << endl;
 				for (int k = 0; k < alignmentLength; k++) {		out << F.a[k] << '\t'; }  out << endl;
 				for (int k = 0; k < alignmentLength; k++) {		out << F.t[k] << '\t'; }  out << endl;
 				for (int k = 0; k < alignmentLength; k++) {		out << F.g[k] << '\t'; }  out << endl;
 				for (int k = 0; k < alignmentLength; k++) {		out << F.c[k] << '\t'; }  out << endl;
 				for (int k = 0; k < alignmentLength; k++) {		out << F.gap[k] << '\t'; }  out << endl;
-				
+
+				cout << F.getFilter() << endl;
 				out.close();
 				
 				exit(0);
@@ -901,7 +901,13 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename)
 			openInputFile(tempFilename, in);
 			
 			int temp, tempNum;
+			string tempFilterString;
+
 			in >> tempNum; gobble(in); num += tempNum;
+
+			in >> tempFilterString;
+			F.mergeFilter(tempFilterString);
+
 			for (int k = 0; k < alignmentLength; k++) {		in >> temp; F.a[k] += temp; }		gobble(in);
 			for (int k = 0; k < alignmentLength; k++) {		in >> temp; F.t[k] += temp; }		gobble(in);
 			for (int k = 0; k < alignmentLength; k++) {		in >> temp; F.g[k] += temp; }		gobble(in);
diff --git a/preclustercommand.cpp b/preclustercommand.cpp
index 2156477..cab2963 100644
--- a/preclustercommand.cpp
+++ b/preclustercommand.cpp
@@ -134,10 +134,9 @@ int PreClusterCommand::execute(){
 
 		//sort seqs by number of identical seqs
 		alignSeqs.sort(comparePriority);
-		
+
 		int count = 0;
 		int i = 0;
-		
 		//think about running through twice...
 		list<seqPNode>::iterator itList;
 		list<seqPNode>::iterator itList2;
@@ -153,14 +152,13 @@ int PreClusterCommand::execute(){
 					//are you within "diff" bases
 					
 					int mismatch = calcMisMatches((*itList).seq.getAligned(), (*itList2).seq.getAligned());
-									
+
 					if (mismatch <= diffs) {
 						//merge
 						(*itList).names += ',' + (*itList2).names;
 						(*itList).numIdentical += (*itList2).numIdentical;
 						
-						alignSeqs.erase(itList2++); 
-
+						itList2 = alignSeqs.erase(itList2); //itList2--;
 						count++;
 					}else{ itList2++; }
 				}else{ itList2++; }