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"
14 /***********************************************************************/
16 Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
17 rabund(rav), list(lv), dMatrix(dm)
21 /***********************************************************************/
23 void Cluster::getRowColCells(){
25 PCell* smallCell = dMatrix->getSmallestCell(); //find the smallest cell - this routine should probably not be in the SpMat class
27 smallRow = smallCell->row; //get its row
28 smallCol = smallCell->column; //get its column
29 smallDist = smallCell->dist; //get the smallest distance
34 for(MatData currentCell=dMatrix->begin();currentCell!=dMatrix->end();currentCell++){
36 if(&*currentCell == smallCell){ //put the smallest cell first
37 rowCells.insert(rowCells.begin(), currentCell);
38 colCells.insert(colCells.begin(), currentCell);
40 else if(currentCell->row == smallRow){
41 rowCells.push_back(currentCell);
43 else if(currentCell->column == smallRow){
44 rowCells.push_back(currentCell);
46 else if(currentCell->row == smallCol){
47 colCells.push_back(currentCell);
49 else if(currentCell->column == smallCol){
50 colCells.push_back(currentCell);
54 nRowCells = rowCells.size();
55 nColCells = colCells.size();
58 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 cout << "An unknown error has occurred in the Cluster class function getRowColCells. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
67 /***********************************************************************/
69 void Cluster::clusterBins(){
71 // cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol);
73 rabund->set(smallCol, rabund->get(smallRow)+rabund->get(smallCol));
74 rabund->set(smallRow, 0);
75 rabund->setLabel(toString(smallDist));
77 // cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
80 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
84 cout << "An unknown error has occurred in the Cluster class function clusterBins. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
91 /***********************************************************************/
93 void Cluster::clusterNames(){
95 // cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(smallRow) << '\t' << list->get(smallCol);
97 list->set(smallCol, list->get(smallRow)+','+list->get(smallCol));
98 list->set(smallRow, "");
99 list->setLabel(toString(smallDist));
101 // cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
103 catch(exception& e) {
104 cout << "Standard Error: " << e.what() << " has occurred in the Cluster class Function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
108 cout << "An unknown error has occurred in the Cluster class function clusterNames. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
113 /***********************************************************************/