From: westcott <westcott>
Date: Tue, 23 Feb 2010 19:41:26 +0000 (+0000)
Subject: added warning about merging with something above cutoff to cluster. working on chimeras
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2397df97b12cd5d21ea10dc4248c18a5803ddd41;p=mothur.git

added warning about merging with something above cutoff to cluster. working on chimeras
---

diff --git a/averagelinkage.cpp b/averagelinkage.cpp
index 7522d2a..2acbacc 100644
--- a/averagelinkage.cpp
+++ b/averagelinkage.cpp
@@ -11,8 +11,8 @@
 
 /***********************************************************************/
 
-AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-	Cluster(rav, lv, dm, c)
+AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+	Cluster(rav, lv, dm, c, s)
 {
 	saveRow = -1;
 	saveCol = -1;
diff --git a/cluster.cpp b/cluster.cpp
index 4009ed0..e360624 100644
--- a/cluster.cpp
+++ b/cluster.cpp
@@ -14,8 +14,8 @@
 
 /***********************************************************************/
 
-Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-rabund(rav), list(lv), dMatrix(dm)
+Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string m) :
+rabund(rav), list(lv), dMatrix(dm), method(m)
 {
 /*
 	cout << "sizeof(MatData): " << sizeof(MatData) << endl;
@@ -212,7 +212,7 @@ void Cluster::update(double& cutOFF){
 					}		
 				}
 				//if not merged it you need it for warning 
-				if (!merged) {  
+				if ((!merged) && (method == "average")) {  
 					mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine(); 
 					if (cutOFF > rowCells[i]->dist) {  cutOFF = rowCells[i]->dist;  mothurOut("changing cutoff to " + toString(cutOFF));  mothurOutEndLine(); }
 
@@ -228,9 +228,11 @@ void Cluster::update(double& cutOFF){
 		// could be avoided
 		for (int i=nColCells-1;i>=0;i--) {
 			if (foundCol[i] == 0) {
-				if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
-					mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
-					if (cutOFF > colCells[i]->dist) {  cutOFF = colCells[i]->dist;  mothurOut("changing cutoff to " + toString(cutOFF));  mothurOutEndLine(); }
+				if (method == "average") {
+					if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
+						mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
+						if (cutOFF > colCells[i]->dist) {  cutOFF = colCells[i]->dist;  mothurOut("changing cutoff to " + toString(cutOFF));  mothurOutEndLine(); }
+					}
 				}
 				removeCell(colCells[i], -1, i);
 			}
diff --git a/cluster.hpp b/cluster.hpp
index 685c843..6d7fc47 100644
--- a/cluster.hpp
+++ b/cluster.hpp
@@ -13,7 +13,7 @@ typedef vector<MatData> MatVec;
 class Cluster {
 	
 public:
-	Cluster(RAbundVector*, ListVector*, SparseMatrix*, float);
+	Cluster(RAbundVector*, ListVector*, SparseMatrix*, float, string);
     virtual void update(double&);				
 	virtual string getTag() = 0;
 	virtual void setMapWanted(bool m);  
@@ -39,6 +39,7 @@ protected:
 	bool mapWanted;
 	float cutoff;
 	map<string, int> seq2Bin;
+	string method;
 	
 	vector<MatVec> seqVec;		// contains vectors of cells related to a certain sequence
 	MatVec rowCells;
@@ -51,7 +52,7 @@ protected:
 
 class CompleteLinkage : public Cluster {
 public:
-	CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+	CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
 	bool updateDistance(MatData& colCell, MatData& rowCell);
 	string getTag();
 	
@@ -63,7 +64,7 @@ private:
 
 class SingleLinkage : public Cluster {
 public:
-	SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+	SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
     void update();
 	bool updateDistance(MatData& colCell, MatData& rowCell);
 	string getTag();
@@ -76,7 +77,7 @@ private:
 
 class AverageLinkage : public Cluster {
 public:
-	AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+	AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
 	bool updateDistance(MatData& colCell, MatData& rowCell);
 	string getTag();
 	
diff --git a/clustercommand.cpp b/clustercommand.cpp
index be7cc51..d14af10 100644
--- a/clustercommand.cpp
+++ b/clustercommand.cpp
@@ -84,9 +84,9 @@ ClusterCommand::ClusterCommand(string option){
 				}
 				
 				//create cluster
-				if (method == "furthest")	{	cluster = new CompleteLinkage(rabund, list, matrix, cutoff); }
-				else if(method == "nearest"){	cluster = new SingleLinkage(rabund, list, matrix, cutoff); }
-				else if(method == "average"){	cluster = new AverageLinkage(rabund, list, matrix, cutoff);	}
+				if (method == "furthest")	{	cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
+				else if(method == "nearest"){	cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
+				else if(method == "average"){	cluster = new AverageLinkage(rabund, list, matrix, cutoff, method);	}
 				tag = cluster->getTag();
 				
 				if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
diff --git a/completelinkage.cpp b/completelinkage.cpp
index a09af90..df6371a 100644
--- a/completelinkage.cpp
+++ b/completelinkage.cpp
@@ -3,8 +3,8 @@
 
 /***********************************************************************/
 
-CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-	Cluster(rav, lv, dm, c)
+CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+	Cluster(rav, lv, dm, c, s)
 {}
 
 /***********************************************************************/
diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp
index fba2959..d240de6 100644
--- a/mgclustercommand.cpp
+++ b/mgclustercommand.cpp
@@ -183,9 +183,9 @@ int MGClusterCommand::execute(){
 			delete read;
 		
 			//create cluster
-			if (method == "furthest")	{	cluster = new CompleteLinkage(rabund, list, distMatrix, cutoff); }
-			else if(method == "nearest"){	cluster = new SingleLinkage(rabund, list, distMatrix, cutoff); }
-			else if(method == "average"){	cluster = new AverageLinkage(rabund, list, distMatrix, cutoff);	}
+			if (method == "furthest")	{	cluster = new CompleteLinkage(rabund, list, distMatrix, cutoff, method); }
+			else if(method == "nearest"){	cluster = new SingleLinkage(rabund, list, distMatrix, cutoff, method); }
+			else if(method == "average"){	cluster = new AverageLinkage(rabund, list, distMatrix, cutoff, method);	}
 			cluster->setMapWanted(true);
 			
 			//cluster using cluster classes
diff --git a/singlelinkage.cpp b/singlelinkage.cpp
index 9f015db..1762615 100644
--- a/singlelinkage.cpp
+++ b/singlelinkage.cpp
@@ -5,8 +5,8 @@
 
 /***********************************************************************/
 
-SingleLinkage::SingleLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-Cluster(rav, lv, dm, c)
+SingleLinkage::SingleLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+Cluster(rav, lv, dm, c, s)
 {}