5 * Created by Pat Schloss on 8/14/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
10 #include "cluster.hpp"
11 #include "rabundvector.hpp"
12 #include "listvector.hpp"
13 #include "sparsematrix.hpp"
15 /***********************************************************************/
17 Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
18 rabund(rav), list(lv), dMatrix(dm)
22 /***********************************************************************/
24 void Cluster::getRowColCells(){
26 PCell* smallCell = dMatrix->getSmallestCell(); //find the smallest cell - this routine should probably not be in the SpMat class
28 smallRow = smallCell->row; //get its row
29 smallCol = smallCell->column; //get its column
30 smallDist = smallCell->dist; //get the smallest distance
35 for(MatData currentCell=dMatrix->begin();currentCell!=dMatrix->end();currentCell++){
37 if(&*currentCell == smallCell){ //put the smallest cell first
38 rowCells.insert(rowCells.begin(), currentCell);
39 colCells.insert(colCells.begin(), currentCell);
41 else if(currentCell->row == smallRow){
42 rowCells.push_back(currentCell);
44 else if(currentCell->column == smallRow){
45 rowCells.push_back(currentCell);
47 else if(currentCell->row == smallCol){
48 colCells.push_back(currentCell);
50 else if(currentCell->column == smallCol){
51 colCells.push_back(currentCell);
55 nRowCells = rowCells.size();
56 nColCells = colCells.size();
59 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
63 cout << "An unknown error has occurred in the Cluster class function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
68 /***********************************************************************/
70 void Cluster::clusterBins(){
72 // cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol);
74 rabund->set(smallCol, rabund->get(smallRow)+rabund->get(smallCol));
75 rabund->set(smallRow, 0);
76 rabund->setLabel(toString(smallDist));
78 // cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
81 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
85 cout << "An unknown error has occurred in the Cluster class function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
92 /***********************************************************************/
94 void Cluster::clusterNames(){
96 // cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(smallRow) << '\t' << list->get(smallCol);
98 list->set(smallCol, list->get(smallRow)+','+list->get(smallCol));
99 list->set(smallRow, "");
100 list->setLabel(toString(smallDist));
102 // cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
104 catch(exception& e) {
105 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
109 cout << "An unknown error has occurred in the Cluster class function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
114 /***********************************************************************/