int front = 0;
for (int i = 0; i < q.length(); i++) {
+//cout << "query = " << q[i] << " subject = " << s[i] << endl;
if (isalpha(q[i]) && isalpha(s[i])) { front = i; break; }
}
-
+//cout << endl << endl;
int back = 0;
for (int i = q.length(); i >= 0; i--) {
+//cout << "query = " << q[i] << " subject = " << s[i] << endl;
if (isalpha(q[i]) && isalpha(s[i])) { back = i; break; }
}
//count bases
int numBases = 0;
for (int l = 0; l < seq.length(); l++) { if (isalpha(seq[l])) { numBases++; } }
-
+//cout << "num Bases = " << numBases << endl;
//save start of seq
win.push_back(front);
-
+//cout << front << '\t';
//move ahead increment bases at a time until all bases are in a window
int countBases = 0;
int totalBases = 0; //used to eliminate window of blanks at end of sequence
for (int m = front; m < (back - size) ; m++) {
//count number of bases you see
- if (isalpha(seq[m])) { countBases++; totalBases++; }
+ if (isalpha(seq[m])) { countBases++; }
//if you have seen enough bases to make a new window
if (countBases >= increment) {
+ //total bases is the number of bases in a window already.
+ totalBases += countBases;
+//cout << "total bases = " << totalBases << endl;
win.push_back(m); //save spot in alignment
+//cout << m << '\t';
countBases = 0; //reset bases you've seen in this window
}
//no need to continue if all your bases are in a window
if (totalBases == numBases) { break; }
}
-
+
+
+ //get last window if needed
+ if (totalBases < numBases) { win.push_back(back-size); cout << back-size << endl;}
+//cout << endl << endl;
+
return win;
}
openOutputFile(freqfile, outFreq);
+ string length = toString(seqs.size()); //if there are 5000 seqs in the template then set precision to 3
+ int precision = length.length() - 1;
+
+ //format output
+ outFreq.setf(ios::fixed, ios::floatfield); outFreq.setf(ios::showpoint);
+
//at each position in the sequence
for (int i = 0; i < seqs[0]->getAligned().length(); i++) {
int highest = 0;
for (int m = 0; m < freq.size(); m++) { if (freq[m] > highest) { highest = freq[m]; } }
- float highFreq;
- //subtract gaps to "ignore them"
- if ( (seqs.size() - gaps) == 0 ) { highFreq = 1.0; }
- else { highFreq = highest / (float) (seqs.size() - gaps); }
-
+ float highFreq = highest / (float) (seqs.size());
+
float Pi;
Pi = (highFreq - 0.25) / 0.75;
if (Pi < 0) { Pi = 0.0; }
//saves this for later
- outFreq << i+1 << '\t' << highFreq << endl;
-
+ outFreq << setprecision(precision) << i << '\t' << highFreq << endl;
+
if (h.count(i) > 0) {
- cout << i+1 << '\t' << highFreq << endl;
prob.push_back(Pi);
}
}
exit(1);
}
}
+//***************************************************************************************************************
+void DeCalculator::removeObviousOutliers(vector< vector<float> >& quantiles) {
+ try {
+
+
+ for (int i = 0; i < quantiles.size(); i++) {
+
+ //find mean of this quantile score
+ float average = findAverage(quantiles[i]);
+
+ vector<float> newQuanI;
+ //look at each value in quantiles to see if it is an outlier
+ for (int j = 0; j < quantiles[i].size(); j++) {
+
+ float highCutoff, lowCutOff;
+
+
+
+ }
+
+ }
+
+ }
+ catch(exception& e) {
+ errorOut(e, "DeCalculator", "removeObviousOutliers");
+ exit(1);
+ }
+}
+
+//***************************************************************************************************************
+float DeCalculator::findAverage(vector<float> myVector) {
+ try{
+
+ float total = 0.0;
+ for (int i = 0; i < myVector.size(); i++) { total += myVector[i]; }
+
+ float average = total / (float) myVector.size();
+
+ return average;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "DeCalculator", "findAverage");
+ exit(1);
+ }
+}
//***************************************************************************************************************
float DeCalculator::getCoef(vector<float> obs, vector<float> qav) {
for (int j = 0; j < obs.size(); j++) { obsAverage += obs[j]; }
obsAverage = obsAverage / (float) obs.size();
//cout << "sum ai / m = " << probAverage << endl;
-//cout << "sum oi / m = " << obsAverage << endl;
+//cout << "sum oi / m = " << obsAverage << endl;
+
float coef = obsAverage / probAverage;
return coef;