+void ChimeraCheckRDP::getCutoff() {
+ try{
+
+ vector<float> temp;
+
+ //store all is scores for all windows
+ for (int i = 0; i < IS.size(); i++) {
+ for (int j = 0; j < IS[i].size(); j++) {
+ temp.push_back(IS[i][j].score);
+ }
+ }
+
+ //sort them
+ sort(temp.begin(), temp.end());
+
+ //get 95%
+ chimeraCutoff = temp[int(temp.size() * 0.95)];
+
+ }
+ catch(exception& e) {
+ errorOut(e, "ChimeraCheckRDP", "getCutoff");
+ exit(1);
+ }
+}
+
+//***************************************************************************************************************
+void ChimeraCheckRDP::makeSVGpic(vector<sim> info, int query) {
+ try{
+
+ string file = querySeqs[query]->getName() + ".chimeracheck.svg";
+ ofstream outsvg;
+ openOutputFile(file, outsvg);
+
+ int width = (info.size()*5) + 150;
+
+ outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 " + toString(width) + "\">\n";
+ outsvg << "<g>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"25\">Plotted IS values for " + querySeqs[query]->getName() + "</text>\n";
+
+ outsvg << "<line x1=\"75\" y1=\"600\" x2=\"" + toString((info.size()*5) + 75) + "\" y2=\"600\" stroke=\"black\" stroke-width=\"2\"/>\n";
+ outsvg << "<line x1=\"75\" y1=\"600\" x2=\"75\" y2=\"125\" stroke=\"black\" stroke-width=\"2\"/>\n";
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"80\" y=\"620\">" + toString(info[0].midpoint) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((info.size()*5) + 75) + "\" y=\"620\">" + toString(info[info.size()-1].midpoint) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"650\">Base Positions</text>\n";
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"580\">0</text>\n";
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"350\">IS</text>\n";
+
+
+ //find max is score
+ float biggest = 0.0;
+ for (int i = 0; i < info.size(); i++) {
+ if (info[i].score > biggest) {
+ biggest = info[i].score;
+ }
+ }
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"135\">" + toString(biggest) + "</text>\n";
+
+ int scaler2 = 500 / biggest;
+
+
+ outsvg << "<polyline fill=\"none\" stroke=\"red\" stroke-width=\"2\" points=\"";
+ //160,200 180,230 200,210 234,220\"/> ";
+ for (int i = 0; i < info.size(); i++) {
+ if(info[i].score < 0) { info[i].score = 0; }
+ outsvg << ((i*5) + 75) << "," << (600 - (info[i].score * scaler2)) << " ";
+ }
+
+ outsvg << "\"/> ";
+ outsvg << "</g>\n</svg>\n";
+
+ outsvg.close();
+
+ }
+ catch(exception& e) {
+ errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
+ exit(1);
+ }
+}
+//***************************************************************************************************************
+void ChimeraCheckRDP::createProcessesIS() {
+ try {
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ int process = 0;
+ vector<int> processIDS;
+
+ //loop through and create all the processes you want
+ while (process != processors) {
+ int pid = fork();
+
+ if (pid > 0) {
+ processIDS.push_back(pid);
+ process++;
+ }else if (pid == 0){
+
+ for (int i = lines[process]->start; i < lines[process]->end; i++) {
+ IS[i] = findIS(i);
+ }
+
+ //write out data to file so parent can read it
+ ofstream out;
+ string s = toString(getpid()) + ".temp";
+ openOutputFile(s, out);
+
+ //output pairs
+ for (int i = lines[process]->start; i < lines[process]->end; i++) {
+ out << IS[i].size() << endl;
+ for (int j = 0; j < IS[i].size(); j++) {
+ out << IS[i][j].leftParent << '\t'<< IS[i][j].rightParent << '\t' << IS[i][j].midpoint << '\t' << IS[i][j].score << endl;
+ }
+ }
+
+ out.close();
+
+ exit(0);
+ }else { mothurOut("unable to spawn the necessary processes."); mothurOutEndLine(); exit(0); }
+ }
+
+ //force parent to wait until all the processes are done
+ for (int i=0;i<processors;i++) {
+ int temp = processIDS[i];
+ wait(&temp);
+ }
+
+ //get data created by processes
+ for (int i=0;i<processors;i++) {
+ ifstream in;
+ string s = toString(processIDS[i]) + ".temp";
+ openInputFile(s, in);
+
+ //get pairs
+ for (int k = lines[i]->start; k < lines[i]->end; k++) {
+
+ int size;
+ in >> size; gobble(in);
+
+ string left, right;
+ int mid;
+ float score;
+
+ IS[k].clear();
+
+ for (int j = 0; j < size; j++) {
+ in >> left >> right >> mid >> score; gobble(in);
+
+ sim temp;
+ temp.leftParent = left;
+ temp.rightParent = right;
+ temp.midpoint = mid;
+ temp.score = score;
+
+ IS[k].push_back(temp);
+ }
+ }
+
+ in.close();
+ remove(s.c_str());
+ }
+#else
+ for (int i = 0; i < querySeqs.size(); i++) {
+ IS[i] = findIS(i);
+ }
+#endif
+ }
+ catch(exception& e) {
+ errorOut(e, "ChimeraCheckRDP", "createProcessesIS");
+ exit(1);
+ }
+}
+
+//***************************************************************************************************************
+