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();
19 //**********************************************************************************************************************
20 void Coverage::getValues(FullMatrix* matrix, vector< vector< vector<float> > >& data, vector<float> dist, string mode) {
23 vector<string> groups;
26 data.resize(dist.size());
27 for (int l = 0; l < data.size(); l++) {
28 data[l].resize(numGroups);
29 for (int k = 0; k < data[l].size(); k++) {
30 data[l][k].push_back(0.0);
34 /**************************************/
35 //get the minimums for each comparision
36 /**************************************/
40 for (int i = 0; i < numGroups; i++) {
41 for (int j = 0; j < numGroups; j++) {
43 //is this "box" one hte user wants analyzed?
44 if ((inUsersGroups(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups) == true) && (inUsersGroups(globaldata->gGroupmap->namesOfGroups[j], globaldata->Groups) == true)) {
46 if (mode == "random") {
47 //create random matrix for this comparison
48 matrix->shuffle(globaldata->gGroupmap->namesOfGroups[i], globaldata->gGroupmap->namesOfGroups[j]);
51 min = matrix->getMins(count); //returns vector of mins for "box" requested ie. groups A, B, 0 = AA, 1 = AB, 2 = BA, 3 = BB;
53 //find the coverage at this distance
54 sort(min.begin(), min.end());
56 //loop through each distance and fill data
57 for (int k = 0; k < data.size(); k++) {
60 //find index in min where value is higher than d
61 for (int m = 0; m < min.size(); m++) {
62 if (min[m] > dist[k]) { index = m; break; }
65 // if you don't find one than all the mins are less than d
66 if (index == -1) { index = min.size(); }
69 data[k][a][b] = 1.0 - ((min.size()-index)/(float)min.size());
74 if (b < numUserGroups-1) { b++; }
75 else{ //you are moving to a new row of "boxes"
82 if (mode == "random") {
83 //restore matrix to original form for next shuffle
92 cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
96 cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
100 //**********************************************************************************************************************