m->mothurOut("Getting conservation... "); cout.flush();
if (consfile == "") {
m->mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush();
- probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + getSimpleName(templateFileName));
+ probabilityProfile = decalc->calcFreq(templateSeqs, templateFileName);
if (m->control_pressed) { return 0; }
m->mothurOut("Done."); m->mothurOutEndLine();
}else { probabilityProfile = readFreq(); m->mothurOut("Done."); }
string noOutliers, outliers;
if ((!filter) && (seqMask == "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.quan";
+ noOutliers = templateFileName + "pintail.quan";
}else if ((!filter) && (seqMask != "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.masked.quan";
+ noOutliers =templateFileName + "pintail.masked.quan";
}else if ((filter) && (seqMask != "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "masked.quan";
+ noOutliers = templateFileName + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan";
}else if ((filter) && (seqMask == "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "quan";
+ noOutliers = templateFileName + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan";
}
decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size());
if (m->control_pressed) { return 0; }
- string outputString = "";
+ string outputString = "#" + m->getVersion() + "\n";
//adjust quantiles
for (int i = 0; i < quantilesMembers.size(); i++) {
}
}else{
- sort(quantilesMembers[i].begin(), quantilesMembers[i].end(), compareQuanMembers);
+ sort(quantilesMembers[i].begin(), quantilesMembers[i].end());
//save 10%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.10)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.10)]);
//save 25%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.25)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.25)]);
//save 50%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.5)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.5)]);
//save 75%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.75)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.75)]);
//save 95%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.95)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.95)]);
//save 99%
- temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.99)].score);
+ temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.99)]);
}
printQuanFile(noOutliers, outputString);
+ //free memory
+ quantilesMembers.clear();
+
m->mothurOut("Done."); m->mothurOutEndLine();
}
}
}
//***************************************************************************************************************
-int Pintail::print(ostream& out, ostream& outAcc) {
+Sequence* Pintail::print(ostream& out, ostream& outAcc) {
try {
+
int index = ceil(deviation);
//is your DE value higher than the 95%
for (int m = 0; m < expectedDistance.size(); m++) { out << expectedDistance[m] << '\t'; }
out << endl;
- return 0;
+ return NULL;
}
catch(exception& e) {
}
#ifdef USE_MPI
//***************************************************************************************************************
-int Pintail::print(MPI_File& out, MPI_File& outAcc) {
+Sequence* Pintail::print(MPI_File& out, MPI_File& outAcc) {
try {
- bool results = false;
+
string outputString = "";
int index = ceil(deviation);
MPI_Status statusAcc;
int length = outAccString.length();
- char buf[length];
- strcpy(buf, outAccString.c_str());
+ char* buf = new char[length];
+ memcpy(buf, outAccString.c_str(), length);
MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc);
-
- results = true;
+ delete buf;
+
+ return NULL;
}
outputString += "Observed\t";
MPI_Status status;
int length = outputString.length();
- char buf2[length];
- strcpy(buf2, outputString.c_str());
+ char* buf2 = new char[length];
+ memcpy(buf2, outputString.c_str(), length);
MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status);
+ delete buf2;
- return results;
+ return NULL;
}
catch(exception& e) {
m->errorOut(e, "Pintail", "print");
MPI_File inMPI;
MPI_Offset size;
MPI_Status status;
+
+ //char* inFileName = new char[consfile.length()];
+ //memcpy(inFileName, consfile.c_str(), consfile.length());
- char inFileName[consfile.length()];
+ char inFileName[1024];
strcpy(inFileName, consfile.c_str());
MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);
MPI_File_get_size(inMPI, &size);
+ //delete inFileName;
- char buffer[size];
+ char* buffer = new char[size];
MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
string tempBuf = buffer;
+ delete buffer;
if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size); }
istringstream iss (tempBuf,istringstream::in);
+ //read version
+ string line = m->getline(iss); m->gobble(iss);
+
while(!iss.eof()) {
iss >> pos >> num;
prob.push_back(Pi);
}
- gobble(iss);
+ m->gobble(iss);
}
MPI_File_close(&inMPI);
#else
ifstream in;
- openInputFile(consfile, in);
+ m->openInputFile(consfile, in);
+
+ //read version
+ string line = m->getline(in); m->gobble(in);
while(!in.eof()){
prob.push_back(Pi);
}
- gobble(in);
+ m->gobble(in);
}
in.close();
void Pintail::createProcessesQuan() {
try {
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- int process = 0;
+ int process = 1;
vector<int> processIDS;
//loop through and create all the processes you want
//write out data to file so parent can read it
ofstream out;
string s = toString(getpid()) + ".temp";
- openOutputFile(s, out);
-
+ m->openOutputFile(s, out);
//output observed distances
for (int i = 0; i < quantilesMembers.size(); i++) {
out << quantilesMembers[i].size() << '\t';
for (int j = 0; j < quantilesMembers[i].size(); j++) {
- out << quantilesMembers[i][j].score << '\t' << quantilesMembers[i][j].member1 << '\t' << quantilesMembers[i][j].member2 << '\t';
+ out << quantilesMembers[i][j] << '\t';
}
out << endl;
}
out.close();
exit(0);
- }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
+ }else {
+ m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine();
+ for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
+ exit(0);
+ }
}
+ //parent does its part
+ quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, templateLines[0]->start, templateLines[0]->end);
+
//force parent to wait until all the processes are done
- for (int i=0;i<processors;i++) {
+ for (int i=0;i<(processors-1);i++) {
int temp = processIDS[i];
wait(&temp);
}
//get data created by processes
- for (int i=0;i<processors;i++) {
+ for (int i=0;i<(processors-1);i++) {
ifstream in;
string s = toString(processIDS[i]) + ".temp";
- openInputFile(s, in);
+ m->openInputFile(s, in);
- vector< vector<quanMember> > quan;
+ vector< vector<float> > quan;
quan.resize(100);
//get quantiles
- for (int m = 0; m < quan.size(); m++) {
+ for (int h = 0; h < quan.size(); h++) {
int num;
in >> num;
- gobble(in);
+ m->gobble(in);
- vector<quanMember> q; float w; int b, n;
+ vector<float> q; float w;
for (int j = 0; j < num; j++) {
- in >> w >> b >> n;
-
- quanMember newMember(w, b, n);
- q.push_back(newMember);
+ in >> w;
+ q.push_back(w);
}
- quan[m] = q;
- gobble(in);
+ quan[h] = q;
+ m->gobble(in);
}
in.close();
remove(s.c_str());
}
-
+
#else
quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size());
#endif
MPI_Offset size;
MPI_Status status;
- char inFileName[quanfile.length()];
+ //char* inFileName = new char[quanfile.length()];
+ //memcpy(inFileName, quanfile.c_str(), quanfile.length());
+
+ char inFileName[1024];
strcpy(inFileName, quanfile.c_str());
MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);
MPI_File_get_size(inMPI, &size);
+ //delete inFileName;
+
- char buffer[size];
+ char* buffer = new char[size];
MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
string tempBuf = buffer;
if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size); }
istringstream iss (tempBuf,istringstream::in);
+ delete buffer;
+
+ //read version
+ string line = m->getline(iss); m->gobble(iss);
while(!iss.eof()) {
iss >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine;
quan.push_back(temp);
- gobble(iss);
+ m->gobble(iss);
}
MPI_File_close(&inMPI);
#else
ifstream in;
- openInputFile(quanfile, in);
+ m->openInputFile(quanfile, in);
+
+ //read version
+ string line = m->getline(in); m->gobble(in);
while(!in.eof()){
quan.push_back(temp);
- gobble(in);
+ m->gobble(in);
}
in.close();
#endif
MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
+
+ //char* FileName = new char[file.length()];
+ //memcpy(FileName, file.c_str(), file.length());
- char FileName[file.length()];
+ char FileName[1024];
strcpy(FileName, file.c_str());
if (pid == 0) {
MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outQuan); //comm, filename, mode, info, filepointer
int length = outputString.length();
- char buf[length];
- strcpy(buf, outputString.c_str());
+ char* buf = new char[length];
+ memcpy(buf, outputString.c_str(), length);
MPI_File_write(outQuan, buf, length, MPI_CHAR, &status);
-
+ delete buf;
+
MPI_File_close(&outQuan);
}
+
+ //delete FileName;
#else
ofstream outQuan;
- openOutputFile(file, outQuan);
+ m->openOutputFile(file, outQuan);
outQuan << outputString;