+ m->errorOut(e, "Slayer", "getSNPS");
+ exit(1);
+ }
+}
+/***********************************************************************/
+int Slayer::bootstrapSNPS(vector<snps> left, vector<snps> right, float& BSA, float& BSB, int numIters) {
+ try {
+
+ srand((unsigned)time( NULL ));
+
+ int count_A = 0; // sceneario QLA,QRB supported
+ int count_B = 0; // sceneario QLB,QRA supported
+
+ int numLeft = max(1, int(left.size() * percentSNPSample/(float)100 + 0.5));
+ int numRight = max(1, int(right.size() * percentSNPSample/(float)100 + 0.5));
+
+ for (int i = 0; i < numIters; i++) {
+ //random sampling with replacement.
+
+ if (m->control_pressed) { return 0; }
+
+ vector<snps> selectedLeft;
+
+ for (int j = 0; j < numLeft; j++) {
+ int index = int(rand() % left.size());
+ selectedLeft.push_back(left[index]);
+ }
+
+ vector<snps> selectedRight;
+ for (int j = 0; j < numRight; j++) {
+ int index = int(rand() % right.size());
+ selectedRight.push_back(right[index]);
+ }
+
+ /* A ------------------------------------------
+ # QLA QRA
+ # Q ------------------------------------------
+ # |
+ # |
+ # Q ------------------------------------------
+ # QLB QRB
+ # B ------------------------------------------ */
+
+
+ float QLA = snpQA(selectedLeft);
+ float QRA = snpQA(selectedRight);
+
+ float QLB = snpQB(selectedLeft);
+ float QRB = snpQB(selectedRight);
+
+ //in original - not used - not sure why?
+ //float ALB = snpAB(selectedLeft);
+ //float ARB = snpAB(selectedRight);
+
+ if ((QLA > QLB) && (QRB > QRA)) {
+ count_A++;
+ }
+
+ if ((QLB > QLA) && (QRA > QRB)) {
+ count_B++;
+ }
+
+//cout << "selected left snp: \n";
+//for (int j = 0; j < selectedLeft.size(); j++) { cout << selectedLeft[j].parentAChar; }
+//cout << endl;
+//for (int j = 0; j < selectedLeft.size(); j++) { cout << selectedLeft[j].queryChar; }
+//cout << endl;
+//for (int j = 0; j < selectedLeft.size(); j++) { cout << selectedLeft[j].parentBChar; }
+//cout << endl;
+//cout << "selected right snp: \n";
+//for (int j = 0; j < selectedRight.size(); j++) { cout << selectedRight[j].parentAChar; }
+//cout << endl;
+//for (int i = 0; i < selectedRight.size(); i++) { cout << selectedRight[i].queryChar; }
+//cout << endl;
+//for (int i = 0; i < selectedRight.size(); i++) { cout << selectedRight[i].parentBChar; }
+//cout << endl;
+ }
+
+
+
+
+ BSA = (float) count_A / (float) iters * 100;
+ BSB = (float) count_B / (float) iters * 100;
+//cout << "bsa = " << BSA << " bsb = " << BSB << endl;
+
+ //run borderline bootstrap values longer
+ //if (numIters < 1000) {
+ //are you within 10 points of min bootstrap value cutoff
+ // if (((abs((double)(BSA - minBS))) <= 5) || ((abs((double)(BSB - minBS))) <= 5)) {
+ // m->mothurOut("extending bootstrap for " + myQuery.getName()); m->mothurOutEndLine();
+ // bootstrapSNPS(left, right, BSA, BSB, 1000);
+ // }
+ //}
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Slayer", "bootstrapSNPS");
+ exit(1);
+ }
+}
+/***********************************************************************/
+float Slayer::snpQA(vector<snps> data) {
+ try {
+
+ int numIdentical = 0;
+
+ for (int i = 0; i < data.size(); i++) {
+ if (data[i].parentAChar == data[i].queryChar) {
+ numIdentical++;
+ }
+ }
+
+ float percentID = (numIdentical / (float) data.size()) * 100;
+
+ return percentID;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Slayer", "snpQA");
+ exit(1);
+ }
+}
+/***********************************************************************/
+float Slayer::snpQB(vector<snps> data) {
+ try {
+
+ int numIdentical = 0;
+
+ for (int i = 0; i < data.size(); i++) {
+ if (data[i].parentBChar == data[i].queryChar) {
+ numIdentical++;
+ }
+ }
+
+ float percentID = (numIdentical / (float) data.size()) * 100;
+
+ return percentID;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Slayer", "snpQB");
+ exit(1);
+ }
+}
+/***********************************************************************/
+float Slayer::snpAB(vector<snps> data) {
+ try {
+ int numIdentical = 0;
+
+ for (int i = 0; i < data.size(); i++) {
+ if (data[i].parentAChar == data[i].parentBChar) {
+ numIdentical++;
+ }
+ }
+
+ float percentID = (numIdentical / (float) data.size()) * 100;
+
+ return percentID;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Slayer", "snpAB");