X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=ccode.cpp;h=00cd3f1948e009a86456e32bbcde2a40c6f889ac;hp=5fdf5d140fc731bdd714ed56923901a720fcdac9;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=2bbb7273d4bf5209f098c764551c6e072d60df36 diff --git a/ccode.cpp b/ccode.cpp index 5fdf5d1..00cd3f1 100644 --- a/ccode.cpp +++ b/ccode.cpp @@ -11,12 +11,13 @@ #include "ignoregaps.h" #include "eachgapdist.h" - //*************************************************************************************************************** Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int numW, string o) : Chimera() { + try { + fastafile = filename; outputDir = o; - templateFileName = temp; templateSeqs = readSeqs(temp); + templateFileName = temp; templateSeqs = readSeqs(temp); setMask(mask); filter = f; window = win; @@ -25,18 +26,21 @@ Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int num distCalc = new eachGapDist(); decalc = new DeCalculator(); - mapInfo = outputDir + getRootName(getSimpleName(fastafile)) + "mapinfo"; + mapInfo = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "mapinfo"; #ifdef USE_MPI - char* inFileName = new char[mapInfo.length()]; - memcpy(inFileName, mapInfo.c_str(), mapInfo.length()); + //char* inFileName = new char[mapInfo.length()]; + //memcpy(inFileName, mapInfo.c_str(), mapInfo.length()); + + char inFileName[1024]; + strcpy(inFileName, mapInfo.c_str()); int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; MPI_File_open(MPI_COMM_WORLD, inFileName, outMode, MPI_INFO_NULL, &outMap); //comm, filename, mode, info, filepointer - delete inFileName; + //delete inFileName; int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are @@ -46,7 +50,7 @@ Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int num MPI_Status status; int length = outString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outString.c_str(), length); MPI_File_write_shared(outMap, buf2, length, MPI_CHAR, &status); @@ -55,11 +59,16 @@ Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int num #else ofstream out2; - openOutputFile(mapInfo, out2); + m->openOutputFile(mapInfo, out2); out2 << "Place in masked, filtered and trimmed sequence\tPlace in original alignment" << endl; out2.close(); #endif + } + catch(exception& e) { + m->errorOut(e, "Ccode", "Ccode"); + exit(1); + } } //*************************************************************************************************************** Ccode::~Ccode() { @@ -71,11 +80,11 @@ Ccode::~Ccode() { #endif } //*************************************************************************************************************** -int Ccode::print(ostream& out, ostream& outAcc) { +Sequence Ccode::print(ostream& out, ostream& outAcc) { try { ofstream out2; - openOutputFileAppend(mapInfo, out2); + m->openOutputFileAppend(mapInfo, out2); out2 << querySeq->getName() << endl; for (it = spotMap.begin(); it!= spotMap.end(); it++) { @@ -152,7 +161,7 @@ int Ccode::print(ostream& out, ostream& outAcc) { //free memory for (int i = 0; i < closest.size(); i++) { delete closest[i].seq; } - return results; + return *querySeq; } catch(exception& e) { m->errorOut(e, "Ccode", "print"); @@ -161,7 +170,7 @@ int Ccode::print(ostream& out, ostream& outAcc) { } #ifdef USE_MPI //*************************************************************************************************************** -int Ccode::print(MPI_File& out, MPI_File& outAcc) { +Sequence Ccode::print(MPI_File& out, MPI_File& outAcc) { try { string outMapString = ""; @@ -238,7 +247,7 @@ int Ccode::print(MPI_File& out, MPI_File& outAcc) { MPI_Status status; int length = outString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outString.c_str(), length); MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status); @@ -250,7 +259,7 @@ int Ccode::print(MPI_File& out, MPI_File& outAcc) { MPI_Status statusAcc; length = outAccString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outAccString.c_str(), length); MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc); @@ -260,7 +269,7 @@ int Ccode::print(MPI_File& out, MPI_File& outAcc) { //free memory for (int i = 0; i < closest.size(); i++) { delete closest[i].seq; } - return results; + return *querySeq; } catch(exception& e) { m->errorOut(e, "Ccode", "print"); @@ -272,11 +281,13 @@ int Ccode::printMapping(string& output) { try { MPI_Status status; int length = output.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, output.c_str(), length); MPI_File_write_shared(outMap, buf, length, MPI_CHAR, &status); delete buf; + + return 0; } catch(exception& e) {