GCC_OPTIMIZATION_LEVEL = 3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ INSTALL_MODE_FLAG = "a-w,a+rX";
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ INSTALL_MODE_FLAG = "a-w,a+rX";
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
#include "parsimony.h"
/**************************************************************************************************/
+
EstOutput Parsimony::getValues(Tree* t) {
try {
globaldata = GlobalData::getInstance();
else if(iSize > rcSize || iSize > lcSize){
score++;
}
- cout << i << ' ' << score << ": ";
- t->tree[i].printNode();
}
- //string hold;
- //cin >> hold;
data[0] = score;
void Tree::randomLabels(string groupA, string groupB) {
try {
- for(int i = 0; i < numLeaves; i++) {
- int z;
- //get random index to switch with
- z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
-
- //you only want to randomize the nodes that are from a group the user wants analyzed, so
- //if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them.
- if (((tree[z].getGroup() == groupA) || (tree[z].getGroup() == groupB)) && ((tree[i].getGroup() == groupA) || (tree[i].getGroup() == groupB))) {
- //switches node i and node z's info.
- map<string,int> lib_hold = tree[z].pGroups;
- tree[z].pGroups = (tree[i].pGroups);
- tree[i].pGroups = (lib_hold);
-
- string zgroup = tree[z].getGroup();
- tree[z].setGroup(tree[i].getGroup());
- tree[i].setGroup(zgroup);
-
- string zname = tree[z].getName();
- tree[z].setName(tree[i].getName());
- tree[i].setName(zname);
+ int numSeqsA = globaldata->gTreemap->seqsPerGroup[groupA];
+ int numSeqsB = globaldata->gTreemap->seqsPerGroup[groupB];
+
+ vector<string> randomGroups(numSeqsA+numSeqsB, groupA);
+ for(int i=numSeqsA;i<randomGroups.size();i++){
+ randomGroups[i] = groupB;
+ }
+ random_shuffle(randomGroups.begin(), randomGroups.end());
- map<string,int> gcount_hold = tree[z].pcount;
- tree[z].pcount = (tree[i].pcount);
- tree[i].pcount = (gcount_hold);
+ int randomCounter = 0;
+ for(int i=0;i<numLeaves;i++){
+ if(tree[i].getGroup() == groupA || tree[i].getGroup() == groupB){
+ tree[i].setGroup(randomGroups[randomCounter]);
+ tree[i].pcount.clear();
+ tree[i].pcount[randomGroups[randomCounter]] = 1;
+ tree[i].pGroups.clear();
+ tree[i].pGroups[randomGroups[randomCounter]] = 1;
+ randomCounter++;
}
}
- }
+ }
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function randomLabels. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
printBranch(tree[node].getRChild());
out << ")";
}else { //you are a leaf
- out << tree[node].getName() << ":" << tree[node].getBranchLength();
+ out << tree[node].getGroup() << ":" << tree[node].getBranchLength();
}
}
//get scores for random trees
for (int j = 0; j < iters; j++) {
- int n = 1;
+// int n = 1;
int count = 0;
for (int r=0; r<numGroups; r++) {
- for (int l = n; l < numGroups; l++) {
+ for (int l = r+1; l < numGroups; l++) {
//copy T[i]'s info.
randT->getCopy(T[i]);
//get wscore of random tree
randomData = weighted->getValues(randT, tmap->namesOfGroups[r], tmap->namesOfGroups[l]);
}
+// randT->createNewickFile("hold"+toString(r)+toString(l)+toString(j));
//save scores
rScores[count].push_back(randomData[0]);
validScores[count][randomData[0]] = randomData[0];
count++;
}
- n++;
+// n++;
}
}
removeValidScoresDuplicates();
-
//find the signifigance of the score for summary file
for (int f = 0; f < numComp; f++) {
//sort random scores
//so if you have 1000 random trees the index returned is 100
//then there are 900 trees with a score greater then you.
//giving you a signifigance of 0.900
- int index = findIndex(userData[f]); if (index == -1) { cout << "error in UnifracWeightedCommand" << endl; exit(1); } //error code
+ int index = findIndex(userData[f], f); if (index == -1) { cout << "error in UnifracWeightedCommand" << endl; exit(1); } //error code
//the signifigance is the number of trees with the users score or higher
WScoreSig.push_back((iters-index)/(float)iters);
}
/***********************************************************/
-int UnifracWeightedCommand::findIndex(float score) {
+int UnifracWeightedCommand::findIndex(float score, int index) {
try{
- for (int e = 0; e < numComp; e++) {
- for (int i = 0; i < rScores[e].size(); i++) {
-//cout << rScores[e][i] << " number " << i << endl;
- if (rScores[e][i] >= score) { return i; }
- }
+ for (int i = 0; i < rScores[index].size(); i++) {
+ if (rScores[index][i] >= score) { return i; }
}
- return -1;
+ return rScores[index].size();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function findIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
void printWSummaryFile();
// void printWeightedFile();
void removeValidScoresDuplicates();
- int findIndex(float);
+ int findIndex(float, int);
void setGroups();
};