#include "pintail.h"
#include "ignoregaps.h"
+#include "eachgapdist.h"
//********************************************************************************************************************
//sorts lowest to highest
int index = ceil(deviation[i]);
+ if (index == 0) { index=1; }
+
//is your DE value higher than the 95%
string chimera;
- if (DE[i] > quantiles[index][4]) { chimera = "Yes"; }
+ if (DE[i] > quantiles[index-1][4]) { chimera = "Yes"; }
else { chimera = "No"; }
out << querySeqs[i]->getName() << '\t' << "div: " << deviation[i] << "\tstDev: " << DE[i] << "\tchimera flag: " << chimera << endl;
templateLines.push_back(new linePair(0, templateSeqs.size()));
#endif
- distcalculator = new ignoreGaps();
+ distcalculator = new eachGapDist();
decalc = new DeCalculator();
//if the user does enter a mask then you want to keep all the spots in the alignment
mothurOut("Done."); mothurOutEndLine();
}else { createProcessesPairs(); }
-
+/*string o = "foronlinepintailpairs-eachgap";
+ofstream out7;
+openOutputFile(o, out7);
+
+for (int i = 0; i < bestfit.size(); i++) {
+ out7 << querySeqs[i]->getName() << endl;
+ out7 << querySeqs[i]->getUnaligned() << endl << endl;
+
+ out7 << bestfit[i]->getName() << endl;
+ out7 << bestfit[i]->getUnaligned() << endl << endl << endl;
+}
+out7.close();/*/
//find P
mothurOut("Getting conservation... "); cout.flush();
if (consfile == "") {
}
}
-
+
+ if (filter) {
+ vector<Sequence*> temp = templateSeqs;
+ for (int i = 0; i < querySeqs.size(); i++) { temp.push_back(querySeqs[i]); }
+
+ createFilter(temp);
+
+ runFilter(querySeqs);
+ runFilter(templateSeqs);
+ runFilter(bestfit);
+ }
+
+
if (processors == 1) {
for (int j = 0; j < bestfit.size(); j++) {
//quantiles are used to determine whether the de values found indicate a chimera
//if you have to calculate them, its time intensive because you are finding the de and deviation values for each
//combination of sequences in the template
- if (quanfile != "") { quantiles = readQuantiles(); }
+ if (quanfile != "") { quantiles = readQuantiles(); }
else {
mothurOut("Calculating quantiles for your template. This can take a while... I will output the quantiles to a .quan file that you can input them using the quantiles parameter next time you run this command. Providing the .quan file will dramatically improve speed. "); cout.flush();
if (processors == 1) {
quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size());
}else { createProcessesQuan(); }
+
+ ofstream out4, out5;
+ string noOutliers, outliers;
-
-
- //decided against this because we were having trouble setting the sensitivity... may want to revisit this...
- //quantiles = decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size());
-
- ofstream out4;
- string o;
-
- o = getRootName(templateFile) + "quan";
+ noOutliers = getRootName(templateFile) + "pintail.quanNOOUTLIERS";
+ outliers = getRootName(templateFile) + "pintail.quanYESOUTLIERS";
- openOutputFile(o, out4);
+ openOutputFile(outliers, out4);
//adjust quantiles
for (int i = 0; i < quantilesMembers.size(); i++) {
out4.close();
+ decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size());
+
+ openOutputFile(noOutliers, out5);
+
+ //adjust quantiles
+ for (int i = 0; i < quantilesMembers.size(); i++) {
+ vector<float> temp;
+
+ if (quantilesMembers[i].size() == 0) {
+ //in case this is not a distance found in your template files
+ for (int g = 0; g < 6; g++) {
+ temp.push_back(0.0);
+ }
+ }else{
+
+ sort(quantilesMembers[i].begin(), quantilesMembers[i].end(), compareQuanMembers);
+
+ //save 10%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.10)].score);
+ //save 25%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.25)].score);
+ //save 50%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.5)].score);
+ //save 75%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.75)].score);
+ //save 95%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.95)].score);
+ //save 99%
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.99)].score);
+
+ }
+
+ //output quan value
+ out5 << i+1 << '\t';
+ for (int u = 0; u < temp.size(); u++) { out5 << temp[u] << '\t'; }
+ out5 << endl;
+
+ quantiles[i] = temp;
+
+ }
+
mothurOut("Done."); mothurOutEndLine();
}
}
}
-//***************************************************************************************************************
-
-vector< vector<float> > Pintail::readQuantiles() {
- try {
-
- ifstream in;
- openInputFile(quanfile, in);
-
- vector< vector<float> > quan;
-
- int num; float ten, twentyfive, fifty, seventyfive, ninetyfive, ninetynine;
-
- while(!in.eof()){
-
- in >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine;
-
- vector <float> temp;
-
- temp.push_back(ten);
- temp.push_back(twentyfive);
- temp.push_back(fifty);
- temp.push_back(seventyfive);
- temp.push_back(ninetyfive);
- temp.push_back(ninetynine);
-
- quan.push_back(temp);
-
- gobble(in);
- }
-
- in.close();
- return quan;
-
- }
- catch(exception& e) {
- errorOut(e, "Pintail", "readQuantiles");
- exit(1);
- }
-}
//***************************************************************************************************************
//calculate the distances from each query sequence to all sequences in the template to find the closest sequence
vector<Sequence*> Pintail::findPairs(int start, int end) {