5 * Created by Sarah Westcott on 3/9/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
12 //**********************************************************************************************************************
13 Coverage::Coverage() {
14 globaldata = GlobalData::getInstance();
15 numUserGroups = globaldata->Groups.size();
16 numGroups = globaldata->gGroupmap->getNumGroups();
18 //**********************************************************************************************************************
19 void Coverage::getValues(FullMatrix* matrix, float d, vector< vector<float> >& data) {
22 vector<string> groups;
25 data.resize(numUserGroups);
26 for (int l = 0; l < data.size(); l++) {
27 data[l].push_back(0.0);
30 /**************************************/
31 //get the minimums for each comparision
32 /**************************************/
36 for (int i = 0; i < numGroups; i++) {
37 for (int j = 0; j < numGroups; j++) {
39 //is this "box" one hte user wants analyzed?
40 if ((inUsersGroups(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups) == true) && (inUsersGroups(globaldata->gGroupmap->namesOfGroups[j], globaldata->Groups) == true)) {
42 min = matrix->getMins(count); //returns vector of mins for "box" requested ie. groups A, B, 0 = AA, 1 = AB, 2 = BA, 3 = BB;
44 //find the coverage at this distance
45 sort(min.begin(), min.end());
46 //cout << "minvector for : " << globaldata->gGroupmap->namesOfGroups[i] + globaldata->gGroupmap->namesOfGroups[j] << endl;
47 //for(int h = 0; h<min.size(); h++) {
48 // cout << min[h] << " ";
52 //find index in min where value is higher than d
53 for (int m = 0; m < min.size(); m++) {
54 if (min[m] > d) { index = m; break; }
57 // if you don't find one than all the mins are less than d
58 if (index == -1) { index = min.size(); }
61 data[a][b] = 1.0 - ((min.size()-index)/(float)min.size());
62 //cout << "D = " << d << "data " << a << b << " = " << data[a][b] << endl;
63 if (b < numUserGroups-1) { b++; }
64 else{ //you are moving to a new row of "boxes"
74 cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
78 cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
82 //**********************************************************************************************************************
83 //For the random matrices
84 void Coverage::getValues(FullMatrix* matrix, float d, vector< vector<float> >& data, string r) {
87 vector<string> groups;
90 data.resize(numUserGroups);
91 for (int l = 0; l < data.size(); l++) {
92 data[l].push_back(0.0);
95 /**************************************/
96 //get the minimums for each comparision
97 /**************************************/
101 for (int i = 0; i < numGroups; i++) {
102 for (int j = 0; j < numGroups; j++) {
104 //is this "box" one hte user wants analyzed?
105 if ((inUsersGroups(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups) == true) && (inUsersGroups(globaldata->gGroupmap->namesOfGroups[j], globaldata->Groups) == true)) {
106 cout << "combo " << a << b << endl;
107 cout << "original matrix mins4rows " << endl;
108 matrix->printMinsForRows(cout);
109 //create random matrix for this comparison
110 matrix->shuffle(count);
112 min = matrix->getMins(count); //returns vector of mins for "box" requested ie. groups A, B, 0 = AA, 1 = AB, 2 = BA, 3 = BB;
113 cout << "shuffled matrix mins4rows " << endl;
114 matrix->printMinsForRows(cout);
116 //find the coverage at this distance
117 sort(min.begin(), min.end());
120 //find index in min where value is higher than d
121 for (int m = 0; m < min.size(); m++) {
122 if (min[m] > d) { index = m; break; }
125 // if you don't find one than all the mins are less than d
126 if (index == -1) { index = min.size(); }
129 data[a][b] = 1.0 - ((min.size()-index)/(float)min.size());
130 cout << "D = " << d << "data " << a << b << " = " << data[a][b] << endl;
131 if (b < numUserGroups-1) { b++; }
132 else{ //you are moving to a new row of "boxes"
139 //restore matrix to original form for next shuffle
141 min = matrix->getMins(count-1);
142 cout << "restored matrix mins4rows " << endl;
143 matrix->printMinsForRows(cout);
147 catch(exception& e) {
148 cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
152 cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
156 //**********************************************************************************************************************